michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function getStyle(node, property) { michael@0: return node.style.getPropertyValue(property); michael@0: } michael@0: michael@0: let doc; michael@0: let inspector; michael@0: michael@0: let test = asyncTest(function*() { michael@0: let style = "div { margin: 10px; padding: 3px } #div1 { margin-top: 5px } #div2 { border-bottom: 1em solid black; } #div3 { padding: 2em; }"; michael@0: let html = "
" michael@0: michael@0: let content = yield loadTab("data:text/html," + encodeURIComponent(html)); michael@0: doc = content.document; michael@0: michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: let toolbox = yield gDevTools.showToolbox(target, "inspector"); michael@0: inspector = toolbox.getCurrentPanel(); michael@0: michael@0: inspector.sidebar.select("layoutview"); michael@0: yield inspector.sidebar.once("layoutview-ready"); michael@0: yield runTests(); michael@0: // TODO: Closing the toolbox in this test leaks - bug 994314 michael@0: // yield gDevTools.closeToolbox(target); michael@0: }); michael@0: michael@0: addTest("Test that adding a border applies a border style when necessary", michael@0: function*() { michael@0: let node = doc.getElementById("div1"); michael@0: is(getStyle(node, "border-top-width"), "", "Should have the right border"); michael@0: is(getStyle(node, "border-top-style"), "", "Should have the right border"); michael@0: let view = yield selectNode(node); michael@0: michael@0: let span = view.document.querySelector(".border.top > span"); michael@0: is(span.textContent, 0, "Should have the right value in the box model."); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(span, {}, view); michael@0: let editor = view.document.querySelector(".styleinspector-propertyeditor"); michael@0: ok(editor, "Should have opened the editor."); michael@0: is(editor.value, "0", "Should have the right value in the editor."); michael@0: michael@0: EventUtils.synthesizeKey("1", {}, view); michael@0: yield waitForUpdate(); michael@0: michael@0: is(editor.value, "1", "Should have the right value in the editor."); michael@0: is(getStyle(node, "border-top-width"), "1px", "Should have the right border"); michael@0: is(getStyle(node, "border-top-style"), "solid", "Should have the right border"); michael@0: michael@0: EventUtils.synthesizeKey("VK_ESCAPE", {}, view); michael@0: yield waitForUpdate(); michael@0: michael@0: is(getStyle(node, "border-top-width"), "", "Should be the right padding.") michael@0: is(getStyle(node, "border-top-style"), "", "Should have the right border"); michael@0: is(span.textContent, 0, "Should have the right value in the box model."); michael@0: });