michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test outerHTML edition via the markup-view michael@0: michael@0: loadHelperScript("helper_outerhtml_test_runner.js"); michael@0: michael@0: const TEST_DATA = [ michael@0: { michael@0: selector: "#badMarkup1", michael@0: oldHTML: '
badMarkup1
', michael@0: newHTML: '
badMarkup1
hanging', michael@0: validate: function(pageNode, selectedNode) { michael@0: is(pageNode, selectedNode, "Original element is selected"); michael@0: michael@0: let textNode = pageNode.nextSibling; michael@0: michael@0: is(textNode.nodeName, "#text", "Sibling is a text element"); michael@0: is(textNode.data, " hanging", "New text node has expected text content"); michael@0: } michael@0: }, michael@0: { michael@0: selector: "#badMarkup2", michael@0: oldHTML: '
badMarkup2
', michael@0: newHTML: '
badMarkup2
hanging
', michael@0: validate: function(pageNode, selectedNode) { michael@0: is(pageNode, selectedNode, "Original element is selected"); michael@0: michael@0: let textNode = pageNode.nextSibling; michael@0: michael@0: is(textNode.nodeName, "#text", "Sibling is a text element"); michael@0: is(textNode.data, " hanging", "New text node has expected text content"); michael@0: } michael@0: }, michael@0: { michael@0: selector: "#badMarkup3", michael@0: oldHTML: '
badMarkup3
', michael@0: newHTML: '
badMarkup3 Emphasized and strong
', michael@0: validate: function(pageNode, selectedNode) { michael@0: is(pageNode, selectedNode, "Original element is selected"); michael@0: michael@0: let em = getNode("#badMarkup3 em"); michael@0: let strong = getNode("#badMarkup3 strong"); michael@0: michael@0: is(em.textContent, "Emphasized and strong", " was auto created"); michael@0: is(strong.textContent, " and strong", " was auto created"); michael@0: } michael@0: }, michael@0: { michael@0: selector: "#badMarkup4", michael@0: oldHTML: '
badMarkup4
', michael@0: newHTML: '
badMarkup4

', michael@0: validate: function(pageNode, selectedNode) { michael@0: is(pageNode, selectedNode, "Original element is selected"); michael@0: michael@0: let div = getNode("#badMarkup4"); michael@0: let p = getNode("#badMarkup4 p"); michael@0: michael@0: is(div.textContent, "badMarkup4", "textContent is correct"); michael@0: is(div.tagName, "DIV", "did not change to

tag"); michael@0: is(p.textContent, "", "The

tag has no children"); michael@0: is(p.tagName, "P", "Created an empty

tag"); michael@0: } michael@0: }, michael@0: { michael@0: selector: "#badMarkup5", michael@0: oldHTML: '

badMarkup5

', michael@0: newHTML: '

badMarkup5

with a nested div

', michael@0: validate: function(pageNode, selectedNode) { michael@0: is(pageNode, selectedNode, "Original element is selected"); michael@0: michael@0: let p = getNode("#badMarkup5"); michael@0: let nodiv = getNode("#badMarkup5 div"); michael@0: let div = getNode("#badMarkup5 ~ div"); michael@0: michael@0: ok(!nodiv, "The invalid markup got created as a sibling"); michael@0: is(p.textContent, "badMarkup5 ", "The

tag does not take in the

content"); michael@0: is(p.tagName, "P", "Did not change to a
tag"); michael@0: is(div.textContent, "with a nested div", "textContent is correct"); michael@0: is(div.tagName, "DIV", "Did not change to

tag"); michael@0: } michael@0: } michael@0: ]; michael@0: michael@0: const TEST_URL = "data:text/html," + michael@0: "" + michael@0: "" + michael@0: "" + michael@0: [outer.oldHTML for (outer of TEST_DATA)].join("\n") + michael@0: "" + michael@0: ""; michael@0: michael@0: let test = asyncTest(function*() { michael@0: let {inspector} = yield addTab(TEST_URL).then(openInspector); michael@0: inspector.markup._frame.focus(); michael@0: yield runEditOuterHTMLTests(TEST_DATA, inspector); michael@0: });