1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_sidebarstate.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let doc; 1.8 +let inspector; 1.9 + 1.10 +function createDocument() 1.11 +{ 1.12 + doc.body.innerHTML = '<h1>Sidebar state test</h1>'; 1.13 + doc.title = "Sidebar State Test"; 1.14 + 1.15 + openInspector(function(panel) { 1.16 + inspector = panel; 1.17 + inspector.sidebar.select("ruleview"); 1.18 + inspectorRuleViewOpened(); 1.19 + }); 1.20 +} 1.21 + 1.22 +function inspectorRuleViewOpened() 1.23 +{ 1.24 + is(inspector.sidebar.getCurrentTabID(), "ruleview", "Rule View is selected by default"); 1.25 + 1.26 + // Select the computed view and turn off the inspector. 1.27 + inspector.sidebar.select("computedview"); 1.28 + 1.29 + gDevTools.once("toolbox-destroyed", inspectorClosed); 1.30 + let target = TargetFactory.forTab(gBrowser.selectedTab); 1.31 + gDevTools.closeToolbox(target); 1.32 +} 1.33 + 1.34 +function inspectorClosed() 1.35 +{ 1.36 + openInspector(function(panel) { 1.37 + inspector = panel; 1.38 + 1.39 + if (inspector.sidebar.getCurrentTabID()) { 1.40 + info("Default sidebar already selected.") 1.41 + testNewDefaultTab(); 1.42 + } else { 1.43 + info("Default sidebar still to be selected, adding select listener."); 1.44 + inspector.sidebar.once("select", testNewDefaultTab); 1.45 + } 1.46 + }); 1.47 +} 1.48 + 1.49 +function testNewDefaultTab() 1.50 +{ 1.51 + is(inspector.sidebar.getCurrentTabID(), "computedview", "Computed view is selected by default."); 1.52 + 1.53 + finishTest(); 1.54 +} 1.55 + 1.56 + 1.57 +function finishTest() 1.58 +{ 1.59 + doc = inspector = null; 1.60 + gBrowser.removeCurrentTab(); 1.61 + finish(); 1.62 +} 1.63 + 1.64 +function test() 1.65 +{ 1.66 + waitForExplicitFinish(); 1.67 + gBrowser.selectedTab = gBrowser.addTab(); 1.68 + gBrowser.selectedBrowser.addEventListener("load", function() { 1.69 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.70 + doc = content.document; 1.71 + waitForFocus(createDocument, content); 1.72 + }, true); 1.73 + 1.74 + content.location = "data:text/html;charset=utf-8,browser_inspector_sidebarstate.js"; 1.75 +}