1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/layoutview/test/browser_editablemodel_border.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function getStyle(node, property) { 1.8 + return node.style.getPropertyValue(property); 1.9 +} 1.10 + 1.11 +let doc; 1.12 +let inspector; 1.13 + 1.14 +let test = asyncTest(function*() { 1.15 + let style = "div { margin: 10px; padding: 3px } #div1 { margin-top: 5px } #div2 { border-bottom: 1em solid black; } #div3 { padding: 2em; }"; 1.16 + let html = "<style>" + style + "</style><div id='div1'></div><div id='div2'></div><div id='div3'></div>" 1.17 + 1.18 + let content = yield loadTab("data:text/html," + encodeURIComponent(html)); 1.19 + doc = content.document; 1.20 + 1.21 + let target = TargetFactory.forTab(gBrowser.selectedTab); 1.22 + let toolbox = yield gDevTools.showToolbox(target, "inspector"); 1.23 + inspector = toolbox.getCurrentPanel(); 1.24 + 1.25 + inspector.sidebar.select("layoutview"); 1.26 + yield inspector.sidebar.once("layoutview-ready"); 1.27 + yield runTests(); 1.28 + // TODO: Closing the toolbox in this test leaks - bug 994314 1.29 + // yield gDevTools.closeToolbox(target); 1.30 +}); 1.31 + 1.32 +addTest("Test that adding a border applies a border style when necessary", 1.33 +function*() { 1.34 + let node = doc.getElementById("div1"); 1.35 + is(getStyle(node, "border-top-width"), "", "Should have the right border"); 1.36 + is(getStyle(node, "border-top-style"), "", "Should have the right border"); 1.37 + let view = yield selectNode(node); 1.38 + 1.39 + let span = view.document.querySelector(".border.top > span"); 1.40 + is(span.textContent, 0, "Should have the right value in the box model."); 1.41 + 1.42 + EventUtils.synthesizeMouseAtCenter(span, {}, view); 1.43 + let editor = view.document.querySelector(".styleinspector-propertyeditor"); 1.44 + ok(editor, "Should have opened the editor."); 1.45 + is(editor.value, "0", "Should have the right value in the editor."); 1.46 + 1.47 + EventUtils.synthesizeKey("1", {}, view); 1.48 + yield waitForUpdate(); 1.49 + 1.50 + is(editor.value, "1", "Should have the right value in the editor."); 1.51 + is(getStyle(node, "border-top-width"), "1px", "Should have the right border"); 1.52 + is(getStyle(node, "border-top-style"), "solid", "Should have the right border"); 1.53 + 1.54 + EventUtils.synthesizeKey("VK_ESCAPE", {}, view); 1.55 + yield waitForUpdate(); 1.56 + 1.57 + is(getStyle(node, "border-top-width"), "", "Should be the right padding.") 1.58 + is(getStyle(node, "border-top-style"), "", "Should have the right border"); 1.59 + is(span.textContent, 0, "Should have the right value in the box model."); 1.60 +});