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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/* -*- 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 basic functionality of sources filtering (file search).
*/
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
function test() {
// Debug test slaves are a bit slow at this test.
requestLongerTimeout(3);
let options = {
source: EXAMPLE_URL + "code_script-switching-01.js",
line: 1
};
initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
const gTab = aTab;
const gPanel = aPanel;
const gDebugger = gPanel.panelWin;
const gSources = gDebugger.DebuggerView.Sources;
const gSearchView = gDebugger.DebuggerView.Filtering.FilteredSources;
const gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
Task.spawn(function* () {
// move searches to yields
// not sure what to do with the error...
yield bogusSearch();
yield firstSearch();
yield secondSearch();
yield thirdSearch();
yield fourthSearch();
yield fifthSearch();
yield sixthSearch();
yield seventhSearch();
return closeDebuggerAndFinish(gPanel)
.then(null, aError => {
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
});
});
function bogusSearch() {
let finished = promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 1),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_NOT_FOUND)
]);
setText(gSearchBox, "BOGUS");
return finished.then(() => promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 1),
verifyContents({ itemCount: 0, hidden: true })
]));
}
function firstSearch() {
let finished = promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 1),
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-02.js")
]);
setText(gSearchBox, "-02.js");
return finished.then(() => promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 1),
verifyContents({ itemCount: 1, hidden: false })
]));
}
function secondSearch() {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-01.js")
])
.then(() => {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForCaretUpdated(gPanel, 5)
])
.then(() => promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 5),
verifyContents({ itemCount: 1, hidden: false })
]));
typeText(gSearchBox, ":5");
return finished;
});
setText(gSearchBox, ".*-01\.js");
return finished;
}
function thirdSearch() {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-02.js")
])
.then(() => {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForCaretUpdated(gPanel, 6, 6)
])
.then(() => promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 6, 6),
verifyContents({ itemCount: 1, hidden: false })
]));
typeText(gSearchBox, "#deb");
return finished;
});
setText(gSearchBox, ".*-02\.js");
return finished;
}
function fourthSearch() {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-01.js")
])
.then(() => {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForCaretUpdated(gPanel, 2, 9),
])
.then(() => promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 2, 9),
verifyContents({ itemCount: 1, hidden: false })
// ...because we simply searched for ":" in the current file.
]));
typeText(gSearchBox, "#:"); // # has precedence.
return finished;
});
setText(gSearchBox, ".*-01\.js");
return finished;
}
function fifthSearch() {
let finished = promise.all([
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-02.js")
])
.then(() => {
let finished = promise.all([
once(gDebugger, "popuphidden"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_NOT_FOUND),
waitForCaretUpdated(gPanel, 1, 3)
])
.then(() => promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 1, 3),
verifyContents({ itemCount: 0, hidden: true })
// ...because the searched label includes ":5", so nothing is found.
]));
typeText(gSearchBox, ":5#*"); // # has precedence.
return finished;
});
setText(gSearchBox, ".*-02\.js");
return finished;
}
function sixthSearch() {
let finished = promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 1, 3),
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForCaretUpdated(gPanel, 5)
]);
backspaceText(gSearchBox, 2);
return finished.then(() => promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 5),
verifyContents({ itemCount: 1, hidden: false })
]));
}
function seventhSearch() {
let finished = promise.all([
ensureSourceIs(gPanel, "-02.js"),
ensureCaretAt(gPanel, 5),
once(gDebugger, "popupshown"),
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
waitForSourceShown(gPanel, "-01.js"),
]);
backspaceText(gSearchBox, 6);
return finished.then(() => promise.all([
ensureSourceIs(gPanel, "-01.js"),
ensureCaretAt(gPanel, 2, 9),
verifyContents({ itemCount: 2, hidden: false })
]));
}
function verifyContents(aArgs) {
is(gSources.visibleItems.length, 2,
"The unmatched sources in the widget should not be hidden.");
is(gSearchView.itemCount, aArgs.itemCount,
"No sources should be displayed in the sources container after a bogus search.");
is(gSearchView.hidden, aArgs.hidden,
"No sources should be displayed in the sources container after a bogus search.");
}
});
}
|