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