/* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /* import-globals-from helper_outerhtml_test_runner.js */ "use strict"; // Test outerHTML edition via the markup-view requestLongerTimeout(2); loadHelperScript("helper_outerhtml_test_runner.js"); const TEST_DATA = [{ selector: "#one", oldHTML: '
First Div
', newHTML: '
First Div
', validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { let text = yield testActor.getProperty("#one", "textContent"); is(text, "First Div", "New div has expected text content"); let num = yield testActor.getNumberOfElementMatches("#one em"); is(num, 0, "No em remaining"); } }, { selector: "#removedChildren", oldHTML: "
removedChild " + "Italic Bold Underline Normal
", newHTML: "
removedChild
" }, { selector: "#addedChildren", oldHTML: '
addedChildren
', newHTML: "
addedChildren " + "Italic Bold Underline Normal
" }, { selector: "#addedAttribute", oldHTML: '
addedAttribute
', newHTML: "
" + "addedAttribute
", validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let html = yield testActor.getProperty("#addedAttribute", "outerHTML"); is(html, "
addedAttribute
", "Attributes have been added"); } }, { selector: "#changedTag", oldHTML: '
changedTag
', newHTML: '

changedTag

' }, { selector: "#siblings", oldHTML: '
siblings
', newHTML: '
before sibling
' + '
siblings (updated)
' + '
after sibling
', validate: function* ({selectedNodeFront, inspector, testActor}) { let beforeSiblingFront = yield getNodeFront("#siblings-before-sibling", inspector); is(beforeSiblingFront, selectedNodeFront, "Sibling has been selected"); let text = yield testActor.getProperty("#siblings", "textContent"); is(text, "siblings (updated)", "New div has expected text content"); let beforeText = yield testActor.getProperty("#siblings-before-sibling", "textContent"); is(beforeText, "before sibling", "Sibling has been inserted"); let afterText = yield testActor.getProperty("#siblings-after-sibling", "textContent"); is(afterText, "after sibling", "Sibling has been inserted"); } }]; const TEST_URL = "data:text/html," + "" + "" + "" + TEST_DATA.map(outer => outer.oldHTML).join("\n") + "" + ""; add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); inspector.markup._frame.focus(); yield runEditOuterHTMLTests(TEST_DATA, inspector, testActor); });