|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let doc; |
|
5 let inspector; |
|
6 |
|
7 function createDocument() |
|
8 { |
|
9 doc.body.innerHTML = '<h1>Sidebar state test</h1>'; |
|
10 doc.title = "Sidebar State Test"; |
|
11 |
|
12 openInspector(function(panel) { |
|
13 inspector = panel; |
|
14 inspector.sidebar.select("ruleview"); |
|
15 inspectorRuleViewOpened(); |
|
16 }); |
|
17 } |
|
18 |
|
19 function inspectorRuleViewOpened() |
|
20 { |
|
21 is(inspector.sidebar.getCurrentTabID(), "ruleview", "Rule View is selected by default"); |
|
22 |
|
23 // Select the computed view and turn off the inspector. |
|
24 inspector.sidebar.select("computedview"); |
|
25 |
|
26 gDevTools.once("toolbox-destroyed", inspectorClosed); |
|
27 let target = TargetFactory.forTab(gBrowser.selectedTab); |
|
28 gDevTools.closeToolbox(target); |
|
29 } |
|
30 |
|
31 function inspectorClosed() |
|
32 { |
|
33 openInspector(function(panel) { |
|
34 inspector = panel; |
|
35 |
|
36 if (inspector.sidebar.getCurrentTabID()) { |
|
37 info("Default sidebar already selected.") |
|
38 testNewDefaultTab(); |
|
39 } else { |
|
40 info("Default sidebar still to be selected, adding select listener."); |
|
41 inspector.sidebar.once("select", testNewDefaultTab); |
|
42 } |
|
43 }); |
|
44 } |
|
45 |
|
46 function testNewDefaultTab() |
|
47 { |
|
48 is(inspector.sidebar.getCurrentTabID(), "computedview", "Computed view is selected by default."); |
|
49 |
|
50 finishTest(); |
|
51 } |
|
52 |
|
53 |
|
54 function finishTest() |
|
55 { |
|
56 doc = inspector = null; |
|
57 gBrowser.removeCurrentTab(); |
|
58 finish(); |
|
59 } |
|
60 |
|
61 function test() |
|
62 { |
|
63 waitForExplicitFinish(); |
|
64 gBrowser.selectedTab = gBrowser.addTab(); |
|
65 gBrowser.selectedBrowser.addEventListener("load", function() { |
|
66 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
67 doc = content.document; |
|
68 waitForFocus(createDocument, content); |
|
69 }, true); |
|
70 |
|
71 content.location = "data:text/html;charset=utf-8,browser_inspector_sidebarstate.js"; |
|
72 } |