Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 7c1e9ab

Browse files
committed
Add named-evals test
1 parent 7ca69e4 commit 7c1e9ab

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

src/test/mochitest/browser.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ skip-if = true # regular failures during release in Bug 1415300
120120
[browser_dbg-sourcemaps3.js]
121121
[browser_dbg-sourcemaps-bogus.js]
122122
[browser_dbg-sources.js]
123+
[browser_dbg-sources-named-eval.js]
123124
[browser_dbg-tabs.js]
124125
[browser_dbg-tabs-pretty-print.js]
125126
[browser_dbg-toggling-tools.js]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
* http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
// Make sure named eval sources appear in the list.
5+
6+
async function waitForSourceCount(dbg, i) {
7+
// We are forced to wait until the DOM nodes appear because the
8+
// source tree batches its rendering.
9+
await waitUntil(() => {
10+
return findAllElements(dbg, "sourceNodes").length === i;
11+
});
12+
}
13+
14+
function getLabel(dbg, index) {
15+
return findElement(dbg, "sourceNode", index).textContent.trim();
16+
}
17+
18+
add_task(async function() {
19+
const dbg = await initDebugger("doc-sources.html");
20+
const { selectors: { getSelectedSource }, getState } = dbg;
21+
22+
await waitForSources(dbg, "simple1", "simple2", "nested-source", "long.js");
23+
24+
ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
25+
content.eval("window.evaledFunc = function() {} //# sourceURL=evaled.js");
26+
});
27+
28+
await waitForSourceCount(dbg, 3);
29+
30+
is(getLabel(dbg, 3), "evaled.js", "the eval script exists");
31+
});

src/test/mochitest/browser_dbg-sources.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ async function waitForSourceCount(dbg, i) {
1111
});
1212
}
1313

14+
async function assertSourceCount(dbg, count) {
15+
await waitForSourceCount(dbg, count);
16+
is(findAllElements(dbg, "sourceNodes").length, count, `${count} sources`);
17+
}
18+
1419
function getLabel(dbg, index) {
1520
return findElement(dbg, "sourceNode", index).textContent.trim();
1621
}
@@ -22,13 +27,13 @@ add_task(async function() {
2227
await waitForSources(dbg, "simple1", "simple2", "nested-source", "long.js");
2328

2429
// Expand nodes and make sure more sources appear.
25-
is(findAllElements(dbg, "sourceNodes").length, 2);
26-
30+
assertSourceCount(dbg, 2);
2731
await clickElement(dbg, "sourceArrow", 2);
28-
is(findAllElements(dbg, "sourceNodes").length, 7);
2932

33+
assertSourceCount(dbg, 7);
3034
await clickElement(dbg, "sourceArrow", 3);
31-
is(findAllElements(dbg, "sourceNodes").length, 8);
35+
36+
assertSourceCount(dbg, 8);
3237

3338
// Select a source.
3439
ok(
@@ -58,20 +63,4 @@ add_task(async function() {
5863

5964
await waitForSourceCount(dbg, 9);
6065
is(getLabel(dbg, 7), "math.min.js", "The dynamic script exists");
61-
62-
// Make sure named eval sources appear in the list.
63-
});
64-
65-
add_task(async function() {
66-
const dbg = await initDebugger("doc-sources.html");
67-
const { selectors: { getSelectedSource }, getState } = dbg;
68-
69-
await waitForSources(dbg, "simple1", "simple2", "nested-source", "long.js");
70-
71-
ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
72-
content.eval("window.evaledFunc = function() {} //# sourceURL=evaled.js");
73-
});
74-
await waitForSourceCount(dbg, 3);
75-
76-
is(getLabel(dbg, 3), "evaled.js", "the eval script exists");
7766
});

0 commit comments

Comments
 (0)