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.

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

mercurial