browser/devtools/markupview/test/browser_markupview_html_edit_01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Test outerHTML edition via the markup-view
michael@0 8
michael@0 9 loadHelperScript("helper_outerhtml_test_runner.js");
michael@0 10
michael@0 11 const TEST_DATA = [
michael@0 12 {
michael@0 13 selector: "#one",
michael@0 14 oldHTML: '<div id="one">First <em>Div</em></div>',
michael@0 15 newHTML: '<div id="one">First Div</div>',
michael@0 16 validate: function(pageNode, selectedNode) {
michael@0 17 is(pageNode.textContent, "First Div", "New div has expected text content");
michael@0 18 ok(!getNode("#one em"), "No em remaining")
michael@0 19 }
michael@0 20 },
michael@0 21 {
michael@0 22 selector: "#removedChildren",
michael@0 23 oldHTML: '<div id="removedChildren">removedChild <i>Italic <b>Bold <u>Underline</u></b></i> Normal</div>',
michael@0 24 newHTML: '<div id="removedChildren">removedChild</div>'
michael@0 25 },
michael@0 26 {
michael@0 27 selector: "#addedChildren",
michael@0 28 oldHTML: '<div id="addedChildren">addedChildren</div>',
michael@0 29 newHTML: '<div id="addedChildren">addedChildren <i>Italic <b>Bold <u>Underline</u></b></i> Normal</div>'
michael@0 30 },
michael@0 31 {
michael@0 32 selector: "#addedAttribute",
michael@0 33 oldHTML: '<div id="addedAttribute">addedAttribute</div>',
michael@0 34 newHTML: '<div id="addedAttribute" class="important" disabled checked>addedAttribute</div>',
michael@0 35 validate: function(pageNode, selectedNode) {
michael@0 36 is(pageNode, selectedNode, "Original element is selected");
michael@0 37 is(pageNode.outerHTML, '<div id="addedAttribute" class="important" disabled="" checked="">addedAttribute</div>',
michael@0 38 "Attributes have been added");
michael@0 39 }
michael@0 40 },
michael@0 41 {
michael@0 42 selector: "#changedTag",
michael@0 43 oldHTML: '<div id="changedTag">changedTag</div>',
michael@0 44 newHTML: '<p id="changedTag" class="important">changedTag</p>'
michael@0 45 },
michael@0 46 {
michael@0 47 selector: "#siblings",
michael@0 48 oldHTML: '<div id="siblings">siblings</div>',
michael@0 49 newHTML: '<div id="siblings-before-sibling">before sibling</div>' +
michael@0 50 '<div id="siblings">siblings (updated)</div>' +
michael@0 51 '<div id="siblings-after-sibling">after sibling</div>',
michael@0 52 validate: function(pageNode, selectedNode) {
michael@0 53 let beforeSiblingNode = getNode("#siblings-before-sibling");
michael@0 54 let afterSiblingNode = getNode("#siblings-after-sibling");
michael@0 55
michael@0 56 is(beforeSiblingNode, selectedNode, "Sibling has been selected");
michael@0 57 is(pageNode.textContent, "siblings (updated)", "New div has expected text content");
michael@0 58 is(beforeSiblingNode.textContent, "before sibling", "Sibling has been inserted");
michael@0 59 is(afterSiblingNode.textContent, "after sibling", "Sibling has been inserted");
michael@0 60 }
michael@0 61 }
michael@0 62 ];
michael@0 63
michael@0 64 const TEST_URL = "data:text/html," +
michael@0 65 "<!DOCTYPE html>" +
michael@0 66 "<head><meta charset='utf-8' /></head>" +
michael@0 67 "<body>" +
michael@0 68 [outer.oldHTML for (outer of TEST_DATA)].join("\n") +
michael@0 69 "</body>" +
michael@0 70 "</html>";
michael@0 71
michael@0 72 let test = asyncTest(function*() {
michael@0 73 let {inspector} = yield addTab(TEST_URL).then(openInspector);
michael@0 74 inspector.markup._frame.focus();
michael@0 75 yield runEditOuterHTMLTests(TEST_DATA, inspector);
michael@0 76 });

mercurial