browser/devtools/layoutview/test/browser_editablemodel_border.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function getStyle(node, property) {
     5   return node.style.getPropertyValue(property);
     6 }
     8 let doc;
     9 let inspector;
    11 let test = asyncTest(function*() {
    12   let style = "div { margin: 10px; padding: 3px } #div1 { margin-top: 5px } #div2 { border-bottom: 1em solid black; } #div3 { padding: 2em; }";
    13   let html = "<style>" + style + "</style><div id='div1'></div><div id='div2'></div><div id='div3'></div>"
    15   let content = yield loadTab("data:text/html," + encodeURIComponent(html));
    16   doc = content.document;
    18   let target = TargetFactory.forTab(gBrowser.selectedTab);
    19   let toolbox = yield gDevTools.showToolbox(target, "inspector");
    20   inspector = toolbox.getCurrentPanel();
    22   inspector.sidebar.select("layoutview");
    23   yield inspector.sidebar.once("layoutview-ready");
    24   yield runTests();
    25   // TODO: Closing the toolbox in this test leaks - bug 994314
    26   // yield gDevTools.closeToolbox(target);
    27 });
    29 addTest("Test that adding a border applies a border style when necessary",
    30 function*() {
    31   let node = doc.getElementById("div1");
    32   is(getStyle(node, "border-top-width"), "", "Should have the right border");
    33   is(getStyle(node, "border-top-style"), "", "Should have the right border");
    34   let view = yield selectNode(node);
    36   let span = view.document.querySelector(".border.top > span");
    37   is(span.textContent, 0, "Should have the right value in the box model.");
    39   EventUtils.synthesizeMouseAtCenter(span, {}, view);
    40   let editor = view.document.querySelector(".styleinspector-propertyeditor");
    41   ok(editor, "Should have opened the editor.");
    42   is(editor.value, "0", "Should have the right value in the editor.");
    44   EventUtils.synthesizeKey("1", {}, view);
    45   yield waitForUpdate();
    47   is(editor.value, "1", "Should have the right value in the editor.");
    48   is(getStyle(node, "border-top-width"), "1px", "Should have the right border");
    49   is(getStyle(node, "border-top-style"), "solid", "Should have the right border");
    51   EventUtils.synthesizeKey("VK_ESCAPE", {}, view);
    52   yield waitForUpdate();
    54   is(getStyle(node, "border-top-width"), "", "Should be the right padding.")
    55   is(getStyle(node, "border-top-style"), "", "Should have the right border");
    56   is(span.textContent, 0, "Should have the right value in the box model.");
    57 });

mercurial