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.

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

mercurial