browser/devtools/markupview/test/browser_markupview_html_edit_01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/markupview/test/browser_markupview_html_edit_01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* vim: set ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Test outerHTML edition via the markup-view
    1.11 +
    1.12 +loadHelperScript("helper_outerhtml_test_runner.js");
    1.13 +
    1.14 +const TEST_DATA = [
    1.15 +  {
    1.16 +    selector: "#one",
    1.17 +    oldHTML: '<div id="one">First <em>Div</em></div>',
    1.18 +    newHTML: '<div id="one">First Div</div>',
    1.19 +    validate: function(pageNode, selectedNode) {
    1.20 +      is(pageNode.textContent, "First Div", "New div has expected text content");
    1.21 +      ok(!getNode("#one em"), "No em remaining")
    1.22 +    }
    1.23 +  },
    1.24 +  {
    1.25 +    selector: "#removedChildren",
    1.26 +    oldHTML: '<div id="removedChildren">removedChild <i>Italic <b>Bold <u>Underline</u></b></i> Normal</div>',
    1.27 +    newHTML: '<div id="removedChildren">removedChild</div>'
    1.28 +  },
    1.29 +  {
    1.30 +    selector: "#addedChildren",
    1.31 +    oldHTML: '<div id="addedChildren">addedChildren</div>',
    1.32 +    newHTML: '<div id="addedChildren">addedChildren <i>Italic <b>Bold <u>Underline</u></b></i> Normal</div>'
    1.33 +  },
    1.34 +  {
    1.35 +    selector: "#addedAttribute",
    1.36 +    oldHTML: '<div id="addedAttribute">addedAttribute</div>',
    1.37 +    newHTML: '<div id="addedAttribute" class="important" disabled checked>addedAttribute</div>',
    1.38 +    validate: function(pageNode, selectedNode) {
    1.39 +      is(pageNode, selectedNode, "Original element is selected");
    1.40 +      is(pageNode.outerHTML, '<div id="addedAttribute" class="important" disabled="" checked="">addedAttribute</div>',
    1.41 +            "Attributes have been added");
    1.42 +    }
    1.43 +  },
    1.44 +  {
    1.45 +    selector: "#changedTag",
    1.46 +    oldHTML: '<div id="changedTag">changedTag</div>',
    1.47 +    newHTML: '<p id="changedTag" class="important">changedTag</p>'
    1.48 +  },
    1.49 +  {
    1.50 +    selector: "#siblings",
    1.51 +    oldHTML: '<div id="siblings">siblings</div>',
    1.52 +    newHTML: '<div id="siblings-before-sibling">before sibling</div>' +
    1.53 +             '<div id="siblings">siblings (updated)</div>' +
    1.54 +             '<div id="siblings-after-sibling">after sibling</div>',
    1.55 +    validate: function(pageNode, selectedNode) {
    1.56 +      let beforeSiblingNode = getNode("#siblings-before-sibling");
    1.57 +      let afterSiblingNode = getNode("#siblings-after-sibling");
    1.58 +
    1.59 +      is(beforeSiblingNode, selectedNode, "Sibling has been selected");
    1.60 +      is(pageNode.textContent, "siblings (updated)", "New div has expected text content");
    1.61 +      is(beforeSiblingNode.textContent, "before sibling", "Sibling has been inserted");
    1.62 +      is(afterSiblingNode.textContent, "after sibling", "Sibling has been inserted");
    1.63 +    }
    1.64 +  }
    1.65 +];
    1.66 +
    1.67 +const TEST_URL = "data:text/html," +
    1.68 +  "<!DOCTYPE html>" +
    1.69 +  "<head><meta charset='utf-8' /></head>" +
    1.70 +  "<body>" +
    1.71 +  [outer.oldHTML for (outer of TEST_DATA)].join("\n") +
    1.72 +  "</body>" +
    1.73 +  "</html>";
    1.74 +
    1.75 +let test = asyncTest(function*() {
    1.76 +  let {inspector} = yield addTab(TEST_URL).then(openInspector);
    1.77 +  inspector.markup._frame.focus();
    1.78 +  yield runEditOuterHTMLTests(TEST_DATA, inspector);
    1.79 +});

mercurial