|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function getStyle(node, property) { |
|
5 return node.style.getPropertyValue(property); |
|
6 } |
|
7 |
|
8 let doc; |
|
9 let inspector; |
|
10 |
|
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>" |
|
14 |
|
15 let content = yield loadTab("data:text/html," + encodeURIComponent(html)); |
|
16 doc = content.document; |
|
17 |
|
18 let target = TargetFactory.forTab(gBrowser.selectedTab); |
|
19 let toolbox = yield gDevTools.showToolbox(target, "inspector"); |
|
20 inspector = toolbox.getCurrentPanel(); |
|
21 |
|
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 }); |
|
28 |
|
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); |
|
35 |
|
36 let span = view.document.querySelector(".border.top > span"); |
|
37 is(span.textContent, 0, "Should have the right value in the box model."); |
|
38 |
|
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."); |
|
43 |
|
44 EventUtils.synthesizeKey("1", {}, view); |
|
45 yield waitForUpdate(); |
|
46 |
|
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"); |
|
50 |
|
51 EventUtils.synthesizeKey("VK_ESCAPE", {}, view); |
|
52 yield waitForUpdate(); |
|
53 |
|
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 }); |