1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +function test() 1.9 +{ 1.10 + waitForExplicitFinish(); 1.11 + 1.12 + gBrowser.selectedTab = gBrowser.addTab(); 1.13 + gBrowser.selectedBrowser.addEventListener("load", function onLoad() { 1.14 + gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); 1.15 + openScratchpad(runTests); 1.16 + }, true); 1.17 + 1.18 + content.location = "data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>"; 1.19 +} 1.20 + 1.21 +function runTests() 1.22 +{ 1.23 + let sp = gScratchpadWindow.Scratchpad; 1.24 + 1.25 + sp.setText("({ a: 'foobarBug636725' })"); 1.26 + 1.27 + sp.inspect().then(function() { 1.28 + let sidebar = sp.sidebar; 1.29 + ok(sidebar.visible, "sidebar is open"); 1.30 + 1.31 + 1.32 + let found = false; 1.33 + 1.34 + outer: for (let scope of sidebar.variablesView) { 1.35 + for (let [, obj] of scope) { 1.36 + for (let [, prop] of obj) { 1.37 + if (prop.name == "a" && prop.value == "foobarBug636725") { 1.38 + found = true; 1.39 + break outer; 1.40 + } 1.41 + } 1.42 + } 1.43 + } 1.44 + 1.45 + ok(found, "found the property"); 1.46 + 1.47 + let tabbox = sidebar._sidebar._tabbox; 1.48 + is(tabbox.width, 300, "Scratchpad sidebar width is correct"); 1.49 + ok(!tabbox.hasAttribute("hidden"), "Scratchpad sidebar visible"); 1.50 + sidebar.hide(); 1.51 + ok(tabbox.hasAttribute("hidden"), "Scratchpad sidebar hidden"); 1.52 + sp.inspect().then(function() { 1.53 + is(tabbox.width, 300, "Scratchpad sidebar width is still correct"); 1.54 + ok(!tabbox.hasAttribute("hidden"), "Scratchpad sidebar visible again"); 1.55 + finish(); 1.56 + }); 1.57 + }); 1.58 +}