diff -r 000000000000 -r 6474c204b198 browser/devtools/markupview/test/browser_markupview_html_edit_01.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/devtools/markupview/test/browser_markupview_html_edit_01.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,76 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test outerHTML edition via the markup-view + +loadHelperScript("helper_outerhtml_test_runner.js"); + +const TEST_DATA = [ + { + selector: "#one", + oldHTML: '
First Div
', + newHTML: '
First Div
', + validate: function(pageNode, selectedNode) { + is(pageNode.textContent, "First Div", "New div has expected text content"); + ok(!getNode("#one em"), "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(pageNode, selectedNode) { + is(pageNode, selectedNode, "Original element is selected"); + is(pageNode.outerHTML, '
addedAttribute
', + "Attributes have been added"); + } + }, + { + selector: "#changedTag", + oldHTML: '
changedTag
', + newHTML: '

changedTag

' + }, + { + selector: "#siblings", + oldHTML: '
siblings
', + newHTML: '
before sibling
' + + '
siblings (updated)
' + + '
after sibling
', + validate: function(pageNode, selectedNode) { + let beforeSiblingNode = getNode("#siblings-before-sibling"); + let afterSiblingNode = getNode("#siblings-after-sibling"); + + is(beforeSiblingNode, selectedNode, "Sibling has been selected"); + is(pageNode.textContent, "siblings (updated)", "New div has expected text content"); + is(beforeSiblingNode.textContent, "before sibling", "Sibling has been inserted"); + is(afterSiblingNode.textContent, "after sibling", "Sibling has been inserted"); + } + } +]; + +const TEST_URL = "data:text/html," + + "" + + "" + + "" + + [outer.oldHTML for (outer of TEST_DATA)].join("\n") + + "" + + ""; + +let test = asyncTest(function*() { + let {inspector} = yield addTab(TEST_URL).then(openInspector); + inspector.markup._frame.focus(); + yield runEditOuterHTMLTests(TEST_DATA, inspector); +});