Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 4 | |
michael@0 | 5 | function getStyle(node, property) { |
michael@0 | 6 | return node.style.getPropertyValue(property); |
michael@0 | 7 | } |
michael@0 | 8 | |
michael@0 | 9 | let doc; |
michael@0 | 10 | let inspector; |
michael@0 | 11 | |
michael@0 | 12 | let test = asyncTest(function*() { |
michael@0 | 13 | let style = "div { margin: 10px; padding: 3px } #div1 { margin-top: 5px } #div2 { border-bottom: 1em solid black; } #div3 { padding: 2em; }"; |
michael@0 | 14 | let html = "<style>" + style + "</style><div id='div1'></div><div id='div2'></div><div id='div3'></div>" |
michael@0 | 15 | |
michael@0 | 16 | let content = yield loadTab("data:text/html," + encodeURIComponent(html)); |
michael@0 | 17 | doc = content.document; |
michael@0 | 18 | |
michael@0 | 19 | let target = TargetFactory.forTab(gBrowser.selectedTab); |
michael@0 | 20 | let toolbox = yield gDevTools.showToolbox(target, "inspector"); |
michael@0 | 21 | inspector = toolbox.getCurrentPanel(); |
michael@0 | 22 | |
michael@0 | 23 | inspector.sidebar.select("layoutview"); |
michael@0 | 24 | yield inspector.sidebar.once("layoutview-ready"); |
michael@0 | 25 | yield runTests(); |
michael@0 | 26 | // TODO: Closing the toolbox in this test leaks - bug 994314 |
michael@0 | 27 | // yield gDevTools.closeToolbox(target); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | addTest("When all properties are set on the node editing one should work", |
michael@0 | 31 | function*() { |
michael@0 | 32 | let node = doc.getElementById("div1"); |
michael@0 | 33 | node.style.padding = "5px"; |
michael@0 | 34 | let view = yield selectNode(node); |
michael@0 | 35 | |
michael@0 | 36 | let span = view.document.querySelector(".padding.bottom > span"); |
michael@0 | 37 | is(span.textContent, 5, "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, "5px", "Should have the right value in the editor."); |
michael@0 | 43 | |
michael@0 | 44 | EventUtils.synthesizeKey("7", {}, view); |
michael@0 | 45 | yield waitForUpdate(); |
michael@0 | 46 | |
michael@0 | 47 | is(editor.value, "7", "Should have the right value in the editor."); |
michael@0 | 48 | is(getStyle(node, "padding-bottom"), "7px", "Should have updated the padding"); |
michael@0 | 49 | |
michael@0 | 50 | EventUtils.synthesizeKey("VK_RETURN", {}, view); |
michael@0 | 51 | yield waitForUpdate(); |
michael@0 | 52 | |
michael@0 | 53 | is(getStyle(node, "padding-bottom"), "7px", "Should be the right padding.") |
michael@0 | 54 | is(span.textContent, 7, "Should have the right value in the box model."); |
michael@0 | 55 | }); |
michael@0 | 56 | |
michael@0 | 57 | addTest("When all properties are set on the node editing one should work", |
michael@0 | 58 | function*() { |
michael@0 | 59 | let node = doc.getElementById("div1"); |
michael@0 | 60 | node.style.padding = "5px"; |
michael@0 | 61 | let view = yield selectNode(node); |
michael@0 | 62 | |
michael@0 | 63 | let span = view.document.querySelector(".padding.left > span"); |
michael@0 | 64 | is(span.textContent, 5, "Should have the right value in the box model."); |
michael@0 | 65 | |
michael@0 | 66 | EventUtils.synthesizeMouseAtCenter(span, {}, view); |
michael@0 | 67 | let editor = view.document.querySelector(".styleinspector-propertyeditor"); |
michael@0 | 68 | ok(editor, "Should have opened the editor."); |
michael@0 | 69 | is(editor.value, "5px", "Should have the right value in the editor."); |
michael@0 | 70 | |
michael@0 | 71 | EventUtils.synthesizeKey("8", {}, view); |
michael@0 | 72 | yield waitForUpdate(); |
michael@0 | 73 | |
michael@0 | 74 | is(editor.value, "8", "Should have the right value in the editor."); |
michael@0 | 75 | is(getStyle(node, "padding-left"), "8px", "Should have updated the padding"); |
michael@0 | 76 | |
michael@0 | 77 | EventUtils.synthesizeKey("VK_ESCAPE", {}, view); |
michael@0 | 78 | yield waitForUpdate(); |
michael@0 | 79 | |
michael@0 | 80 | is(getStyle(node, "padding-left"), "5px", "Should be the right padding.") |
michael@0 | 81 | is(span.textContent, 5, "Should have the right value in the box model."); |
michael@0 | 82 | }); |
michael@0 | 83 | |
michael@0 | 84 | addTest("When all properties are set on the node deleting one should work", |
michael@0 | 85 | function*() { |
michael@0 | 86 | let node = doc.getElementById("div1"); |
michael@0 | 87 | node.style.padding = "5px"; |
michael@0 | 88 | let view = yield selectNode(node); |
michael@0 | 89 | |
michael@0 | 90 | let span = view.document.querySelector(".padding.left > span"); |
michael@0 | 91 | is(span.textContent, 5, "Should have the right value in the box model."); |
michael@0 | 92 | |
michael@0 | 93 | EventUtils.synthesizeMouseAtCenter(span, {}, view); |
michael@0 | 94 | let editor = view.document.querySelector(".styleinspector-propertyeditor"); |
michael@0 | 95 | ok(editor, "Should have opened the editor."); |
michael@0 | 96 | is(editor.value, "5px", "Should have the right value in the editor."); |
michael@0 | 97 | |
michael@0 | 98 | EventUtils.synthesizeKey("VK_DELETE", {}, view); |
michael@0 | 99 | yield waitForUpdate(); |
michael@0 | 100 | |
michael@0 | 101 | is(editor.value, "", "Should have the right value in the editor."); |
michael@0 | 102 | is(getStyle(node, "padding-left"), "", "Should have updated the padding"); |
michael@0 | 103 | |
michael@0 | 104 | EventUtils.synthesizeKey("VK_RETURN", {}, view); |
michael@0 | 105 | yield waitForUpdate(); |
michael@0 | 106 | |
michael@0 | 107 | is(getStyle(node, "padding-left"), "", "Should be the right padding.") |
michael@0 | 108 | is(span.textContent, 3, "Should have the right value in the box model."); |
michael@0 | 109 | }); |
michael@0 | 110 | |
michael@0 | 111 | addTest("When all properties are set on the node deleting one then cancelling should work", |
michael@0 | 112 | function*() { |
michael@0 | 113 | let node = doc.getElementById("div1"); |
michael@0 | 114 | node.style.padding = "5px"; |
michael@0 | 115 | let view = yield selectNode(node); |
michael@0 | 116 | |
michael@0 | 117 | let span = view.document.querySelector(".padding.left > span"); |
michael@0 | 118 | is(span.textContent, 5, "Should have the right value in the box model."); |
michael@0 | 119 | |
michael@0 | 120 | EventUtils.synthesizeMouseAtCenter(span, {}, view); |
michael@0 | 121 | let editor = view.document.querySelector(".styleinspector-propertyeditor"); |
michael@0 | 122 | ok(editor, "Should have opened the editor."); |
michael@0 | 123 | is(editor.value, "5px", "Should have the right value in the editor."); |
michael@0 | 124 | |
michael@0 | 125 | EventUtils.synthesizeKey("VK_DELETE", {}, view); |
michael@0 | 126 | yield waitForUpdate(); |
michael@0 | 127 | |
michael@0 | 128 | is(editor.value, "", "Should have the right value in the editor."); |
michael@0 | 129 | is(getStyle(node, "padding-left"), "", "Should have updated the padding"); |
michael@0 | 130 | |
michael@0 | 131 | EventUtils.synthesizeKey("VK_ESCAPE", {}, view); |
michael@0 | 132 | yield waitForUpdate(); |
michael@0 | 133 | |
michael@0 | 134 | is(getStyle(node, "padding-left"), "5px", "Should be the right padding.") |
michael@0 | 135 | is(span.textContent, 5, "Should have the right value in the box model."); |
michael@0 | 136 | }); |