/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; // Test that outerHTML editing keybindings work as expected and that the // root element can be edited correctly. const TEST_URL = "data:image/svg+xml," + '' + '' + ""; requestLongerTimeout(2); add_task(async function () { const { inspector } = await openInspectorForURL(TEST_URL); inspector.markup._frame.focus(); info("Check that editing the element works like other nodes"); await testDocumentElement(inspector); info("Check (again) that editing the element works like other nodes"); await testDocumentElement2(inspector); }); async function testDocumentElement(inspector) { const currentDocElementOuterHTML = await SpecialPowers.spawn( gBrowser.selectedBrowser, [], () => content.document.documentElement.outerHTML ); const docElementSVG = '' + '' + ""; const docElementFront = await inspector.markup.walker.documentElement(); const onReselected = inspector.markup.once("reselectedonremoved"); await inspector.markup.updateNodeOuterHTML( docElementFront, docElementSVG, currentDocElementOuterHTML ); await onReselected; is( await getContentPageElementAttribute("svg", "width"), "200", " width has been updated" ); is( await getContentPageElementAttribute("svg", "height"), "200", " height has been updated" ); is( await getContentPageElementProperty("svg", "outerHTML"), docElementSVG, " markup has been updated" ); } async function testDocumentElement2(inspector) { const currentDocElementOuterHTML = await SpecialPowers.spawn( gBrowser.selectedBrowser, [], () => content.document.documentElement.outerHTML ); const docElementSVG = '' + '' + ""; const docElementFront = await inspector.markup.walker.documentElement(); const onReselected = inspector.markup.once("reselectedonremoved"); inspector.markup.updateNodeOuterHTML( docElementFront, docElementSVG, currentDocElementOuterHTML ); await onReselected; is( await getContentPageElementAttribute("svg", "width"), "300", " width has been updated" ); is( await getContentPageElementAttribute("svg", "height"), "300", " height has been updated" ); is( await getContentPageElementProperty("svg", "outerHTML"), docElementSVG, " markup has been updated" ); }