|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the debugger panes collapse properly. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gPrefs, gOptions; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 gPrefs = gDebugger.Prefs; |
|
20 gOptions = gDebugger.DebuggerView.Options; |
|
21 |
|
22 testPanesState(); |
|
23 |
|
24 gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false }); |
|
25 |
|
26 testInstrumentsPaneCollapse(); |
|
27 testPanesStartupPref(); |
|
28 |
|
29 closeDebuggerAndFinish(gPanel); |
|
30 }); |
|
31 } |
|
32 |
|
33 function testPanesState() { |
|
34 let instrumentsPane = |
|
35 gDebugger.document.getElementById("instruments-pane"); |
|
36 let instrumentsPaneToggleButton = |
|
37 gDebugger.document.getElementById("instruments-pane-toggle"); |
|
38 |
|
39 ok(instrumentsPane.hasAttribute("pane-collapsed") && |
|
40 instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
41 "The debugger view instruments pane should initially be hidden."); |
|
42 is(gPrefs.panesVisibleOnStartup, false, |
|
43 "The debugger view instruments pane should initially be preffed as hidden."); |
|
44 isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
45 "The options menu item should not be checked."); |
|
46 } |
|
47 |
|
48 function testInstrumentsPaneCollapse() { |
|
49 let instrumentsPane = |
|
50 gDebugger.document.getElementById("instruments-pane"); |
|
51 let instrumentsPaneToggleButton = |
|
52 gDebugger.document.getElementById("instruments-pane-toggle"); |
|
53 |
|
54 let width = parseInt(instrumentsPane.getAttribute("width")); |
|
55 is(width, gPrefs.instrumentsWidth, |
|
56 "The instruments pane has an incorrect width."); |
|
57 is(instrumentsPane.style.marginLeft, "0px", |
|
58 "The instruments pane has an incorrect left margin."); |
|
59 is(instrumentsPane.style.marginRight, "0px", |
|
60 "The instruments pane has an incorrect right margin."); |
|
61 ok(!instrumentsPane.hasAttribute("animated"), |
|
62 "The instruments pane has an incorrect animated attribute."); |
|
63 ok(!instrumentsPane.hasAttribute("pane-collapsed") && |
|
64 !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
65 "The instruments pane should at this point be visible."); |
|
66 |
|
67 gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true }); |
|
68 |
|
69 is(gPrefs.panesVisibleOnStartup, false, |
|
70 "The debugger view panes should still initially be preffed as hidden."); |
|
71 isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
72 "The options menu item should still not be checked."); |
|
73 |
|
74 let margin = -(width + 1) + "px"; |
|
75 is(width, gPrefs.instrumentsWidth, |
|
76 "The instruments pane has an incorrect width after collapsing."); |
|
77 is(instrumentsPane.style.marginLeft, margin, |
|
78 "The instruments pane has an incorrect left margin after collapsing."); |
|
79 is(instrumentsPane.style.marginRight, margin, |
|
80 "The instruments pane has an incorrect right margin after collapsing."); |
|
81 ok(instrumentsPane.hasAttribute("animated"), |
|
82 "The instruments pane has an incorrect attribute after an animated collapsing."); |
|
83 ok(instrumentsPane.hasAttribute("pane-collapsed") && |
|
84 instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
85 "The instruments pane should not be visible after collapsing."); |
|
86 |
|
87 gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false }); |
|
88 |
|
89 is(gPrefs.panesVisibleOnStartup, false, |
|
90 "The debugger view panes should still initially be preffed as hidden."); |
|
91 isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
92 "The options menu item should still not be checked."); |
|
93 |
|
94 is(width, gPrefs.instrumentsWidth, |
|
95 "The instruments pane has an incorrect width after uncollapsing."); |
|
96 is(instrumentsPane.style.marginLeft, "0px", |
|
97 "The instruments pane has an incorrect left margin after uncollapsing."); |
|
98 is(instrumentsPane.style.marginRight, "0px", |
|
99 "The instruments pane has an incorrect right margin after uncollapsing."); |
|
100 ok(!instrumentsPane.hasAttribute("animated"), |
|
101 "The instruments pane has an incorrect attribute after an unanimated uncollapsing."); |
|
102 ok(!instrumentsPane.hasAttribute("pane-collapsed") && |
|
103 !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
104 "The instruments pane should be visible again after uncollapsing."); |
|
105 } |
|
106 |
|
107 function testPanesStartupPref() { |
|
108 let instrumentsPane = |
|
109 gDebugger.document.getElementById("instruments-pane"); |
|
110 let instrumentsPaneToggleButton = |
|
111 gDebugger.document.getElementById("instruments-pane-toggle"); |
|
112 |
|
113 is(gPrefs.panesVisibleOnStartup, false, |
|
114 "The debugger view panes should still initially be preffed as hidden."); |
|
115 |
|
116 ok(!instrumentsPane.hasAttribute("pane-collapsed") && |
|
117 !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
118 "The debugger instruments pane should at this point be visible."); |
|
119 is(gPrefs.panesVisibleOnStartup, false, |
|
120 "The debugger view panes should initially be preffed as hidden."); |
|
121 isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
122 "The options menu item should still not be checked."); |
|
123 |
|
124 gOptions._showPanesOnStartupItem.setAttribute("checked", "true"); |
|
125 gOptions._toggleShowPanesOnStartup(); |
|
126 |
|
127 ok(!instrumentsPane.hasAttribute("pane-collapsed") && |
|
128 !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
129 "The debugger instruments pane should at this point be visible."); |
|
130 is(gPrefs.panesVisibleOnStartup, true, |
|
131 "The debugger view panes should now be preffed as visible."); |
|
132 is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
133 "The options menu item should now be checked."); |
|
134 |
|
135 gOptions._showPanesOnStartupItem.setAttribute("checked", "false"); |
|
136 gOptions._toggleShowPanesOnStartup(); |
|
137 |
|
138 ok(!instrumentsPane.hasAttribute("pane-collapsed") && |
|
139 !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), |
|
140 "The debugger instruments pane should at this point be visible."); |
|
141 is(gPrefs.panesVisibleOnStartup, false, |
|
142 "The debugger view panes should now be preffed as hidden."); |
|
143 isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", |
|
144 "The options menu item should now be unchecked."); |
|
145 } |
|
146 |
|
147 registerCleanupFunction(function() { |
|
148 gTab = null; |
|
149 gDebuggee = null; |
|
150 gPanel = null; |
|
151 gDebugger = null; |
|
152 gPrefs = null; |
|
153 gOptions = null; |
|
154 }); |