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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that outline panel can sort functions alphabetically.
"use strict";
// Test that the outline panel updates correctly when a source is selected
// This scenario covers the case where the outline panel always focused.
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
openOutlinePanel(dbg, false);
is(
findAllElements(dbg, "outlineItems").length,
0,
" There are no outline items when no source is selected"
);
await selectSource(dbg, "simple1.js", 1);
info("Wait for all the outline list to load");
await waitForElementWithSelector(dbg, ".outline-list");
assertOutlineItems(dbg, [
"λmain()",
"λdoEval()",
"λevaledFunc()",
"λdoNamedEval()",
// evaledFunc is set twice
"λevaledFunc()",
"class MyClass",
"λconstructor(a, b)",
"λtest()",
"λ#privateFunc(a, b)",
"class Klass",
"λconstructor()",
"λtest()",
]);
});
// Test that the outline panel updates correctly when a source is selected
// This scenario covers the case where the outline panel gets un-selected and selected again
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
openOutlinePanel(dbg, false);
is(
findAllElements(dbg, "outlineItems").length,
0,
" There are no outline items when no source is selected"
);
is(
findElementWithSelector(dbg, ".outline-pane-info").innerText,
"No file selected",
"The correct message is displayed when there are no outline items"
);
const sourcesTab = findElementWithSelector(dbg, ".sources-tab a");
EventUtils.synthesizeMouseAtCenter(sourcesTab, {}, sourcesTab.ownerGlobal);
await waitForSourcesInSourceTree(dbg, [], { noExpand: true });
await selectSource(dbg, "simple1.js", 1);
await openOutlinePanel(dbg);
assertOutlineItems(dbg, [
"λmain()",
"λdoEval()",
"λevaledFunc()",
"λdoNamedEval()",
// evaledFunc is set twice
"λevaledFunc()",
"class MyClass",
"λconstructor(a, b)",
"λtest()",
"λ#privateFunc(a, b)",
"class Klass",
"λconstructor()",
"λtest()",
]);
info("Sort the list");
findElementWithSelector(dbg, ".outline-footer button").click();
// Button becomes active to show alphabetization
is(
findElementWithSelector(dbg, ".outline-footer button").className,
"active",
"Alphabetize button is highlighted when active"
);
info("Check that the list was sorted as expected");
assertOutlineItems(dbg, [
"λdoEval()",
"λdoNamedEval()",
// evaledFunc is set twice
"λevaledFunc()",
"λevaledFunc()",
"λmain()",
"class Klass",
"λconstructor()",
"λtest()",
"class MyClass",
"λ#privateFunc(a, b)",
"λconstructor(a, b)",
"λtest()",
]);
});
// Test empty panel when source has no function or class symbols
add_task(async function () {
const dbg = await initDebugger("doc-on-load.html", "top-level.js");
await selectSource(dbg, "top-level.js", 1);
openOutlinePanel(dbg, false);
await waitFor(
() =>
dbg.win.document.querySelector(".outline-pane-info").innerText ==
"No functions"
);
is(
findAllElements(dbg, "outlineItems").length,
0,
" There are no outline items when no source is selected"
);
});
|