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

Commit a08b83a

Browse files
loganfsmythjasonLaster
authored andcommitted
Add test already added in MC bug 1450145. (#5856)
1 parent e997e6b commit a08b83a

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

src/test/mochitest/browser.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ support-files =
130130

131131
[browser_dbg-asm.js]
132132
[browser_dbg-async-stepping.js]
133+
[browser_dbg-babel-breakpoint-console.js]
133134
[browser_dbg-babel-scopes.js]
134135
[browser_dbg-babel-stepping.js]
135136
[browser_dbg-babel-preview.js]
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
async function evalInConsoleAtPoint(dbg, fixture, { line, column }, statements) {
3+
const { selectors: { getBreakpoint, getBreakpoints }, getState } = dbg;
4+
5+
const filename = `fixtures/${fixture}/input.js`;
6+
await waitForSources(dbg, filename);
7+
8+
ok(true, "Original sources exist");
9+
const source = findSource(dbg, filename);
10+
11+
await selectSource(dbg, source);
12+
13+
// Test that breakpoint is not off by a line.
14+
await addBreakpoint(dbg, source, line);
15+
16+
is(getBreakpoints(getState()).size, 1, "One breakpoint exists");
17+
ok(
18+
getBreakpoint(getState(), { sourceId: source.id, line, column }),
19+
"Breakpoint has correct line"
20+
);
21+
22+
const fnName = fixture.replace(/-([a-z])/g, (s, c) => c.toUpperCase());
23+
24+
const invokeResult = invokeInTab(fnName);
25+
26+
let invokeFailed = await Promise.race([
27+
waitForPaused(dbg),
28+
invokeResult.then(() => new Promise(() => {}), () => true)
29+
]);
30+
31+
if (invokeFailed) {
32+
return invokeResult;
33+
}
34+
35+
assertPausedLocation(dbg);
36+
37+
await assertConsoleEval(dbg, statements);
38+
39+
await removeBreakpoint(dbg, source.id, line, column);
40+
41+
is(getBreakpoints(getState()).size, 0, "Breakpoint reverted");
42+
43+
await resume(dbg);
44+
45+
// If the invoke errored later somehow, capture here so the error is reported nicely.
46+
await invokeResult;
47+
48+
ok(true, `Ran tests for ${fixture} at line ${line} column ${column}`);
49+
}
50+
51+
async function assertConsoleEval(dbg, statements) {
52+
const jsterm = (await dbg.toolbox.selectTool("webconsole")).hud.jsterm;
53+
54+
for (const [index, statement] of statements.entries()) {
55+
await dbg.client.evaluate(`
56+
window.TEST_RESULT = false;
57+
`);
58+
await jsterm.execute(`
59+
TEST_RESULT = ${statement};
60+
`);
61+
62+
const result = await dbg.client.evaluate(`window.TEST_RESULT`);
63+
is(result.result, true, `'${statement}' evaluates to true`);
64+
}
65+
}
66+
67+
add_task(async function() {
68+
await pushPref("devtools.debugger.features.map-scopes", true);
69+
70+
const dbg = await initDebugger("doc-babel.html");
71+
72+
await evalInConsoleAtPoint(dbg, "eval-source-maps", { line: 14, column: 4 }, [
73+
"one === 1",
74+
"two === 4",
75+
"three === 5",
76+
]);
77+
78+
await evalInConsoleAtPoint(dbg, "imported-bindings", { line: 20, column: 2 }, [
79+
`aDefault === "a-default"`,
80+
`anAliased === "an-original"`,
81+
`aNamed === "a-named"`,
82+
`aDefault2 === "a-default2"`,
83+
`anAliased2 === "an-original2"`,
84+
`aNamed2 === "a-named2"`,
85+
`aDefault3 === "a-default3"`,
86+
`anAliased3 === "an-original3"`,
87+
`aNamed3 === "a-named3"`,
88+
]);
89+
90+
await evalInConsoleAtPoint(dbg, "shadowed-vars", { line: 18, column: 6 }, [
91+
`aVar === "var3"`,
92+
`aLet === "let3"`,
93+
`aConst === "const3"`,
94+
]);
95+
});

0 commit comments

Comments
 (0)