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

Commit b6083ee

Browse files
committed
[PausePoints] Add additional syntax (#5777)
1 parent e34c89b commit b6083ee

29 files changed

+543
-173
lines changed

src/actions/ast.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import {
1919
getFramework,
2020
getPausePoints
2121
} from "../workers/parser";
22+
2223
import { PROMISE } from "./utils/middleware/promise";
24+
import { isGeneratedId } from "devtools-source-map";
2325

2426
import type { SourceId } from "../types";
2527
import type { ThunkArgs } from "./types";
@@ -100,7 +102,10 @@ export function setPausePoints(sourceId: SourceId) {
100102
}
101103

102104
const pausePoints = await getPausePoints(source.id);
103-
await client.setPausePoints(source.id, pausePoints);
105+
106+
if (isGeneratedId(source.id)) {
107+
await client.setPausePoints(source.id, pausePoints);
108+
}
104109

105110
dispatch({
106111
type: "SET_PAUSE_POINTS",

src/actions/utils/middleware/log.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const blacklist = [
1111
"SET_SYMBOLS",
1212
"OUT_OF_SCOPE_LOCATIONS",
1313
"MAP_SCOPES",
14+
"MAP_FRAMES",
1415
"ADD_SCOPES",
1516
"IN_SCOPE_LINES",
1617
"SET_EMPTY_LINES"

src/client/firefox/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function setupCommands(dependencies: Dependencies): { bpClients: BPClients } {
5454
return { bpClients };
5555
}
5656

57-
function sendPacket(packet: Object, callback?: Function) {
58-
debuggerClient.request(packet).then(callback);
57+
function sendPacket(packet: Object, callback?: Function = r => r) {
58+
return debuggerClient.request(packet).then(callback);
5959
}
6060

6161
function resume(): Promise<*> {

src/reducers/ast.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ export function getEmptyLines(state: OuterState, source: Source) {
192192
return state.ast.getIn(["emptyLines", source.id]);
193193
}
194194

195-
export function getPausePoints(state: OuterState, source: Source) {
196-
if (!source) {
197-
return null;
198-
}
195+
export function getPausePoints(state: OuterState, sourceId: string) {
196+
return state.ast.getIn(["pausePoints", sourceId]);
197+
}
199198

200-
return state.ast.getIn(["pausePoints", source.id]);
199+
export function hasPausePoints(state: OuterState, sourceId: string): boolean {
200+
const pausePoints = getPausePoints(state, sourceId);
201+
return !!pausePoints;
201202
}
202203

203204
export function getOutOfScopeLocations(state: OuterState) {

src/test/mochitest/browser.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ support-files =
105105
examples/doc-sourcemaps3.html
106106
examples/doc-sourcemap-bogus.html
107107
examples/doc-sources.html
108+
examples/doc-pause-points.html
108109
examples/doc-return-values.html
109110
examples/doc-wasm-sourcemaps.html
110111
examples/asm.js
@@ -121,6 +122,7 @@ support-files =
121122
examples/simple2.js
122123
examples/simple3.js
123124
examples/frames.js
125+
examples/pause-points.js
124126
examples/script-mutate.js
125127
examples/script-switching-02.js
126128
examples/script-switching-01.js
@@ -175,6 +177,7 @@ skip-if = os == "win"
175177
[browser_dbg-returnvalues.js]
176178
[browser_dbg-reload.js]
177179
[browser_dbg-replay.js]
180+
[browser_dbg-pause-points.js]
178181
[browser_dbg-scopes-mutations.js]
179182
[browser_dbg-search-file.js]
180183
skip-if = os == "win" # Bug 1393121

src/test/mochitest/browser_dbg-breakpoints-reloading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ add_task(async function() {
3535

3636
const syncedBps = waitForDispatch(dbg, "SYNC_BREAKPOINT", 2);
3737
await reload(dbg, "simple1");
38-
await waitForSelectedSource(dbg);
38+
await waitForSelectedSource(dbg, "simple1");
3939
await syncedBps;
4040

4141
assertEditorBreakpoint(dbg, 4);

src/test/mochitest/browser_dbg-call-stack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ add_task(async function() {
4141
// check to make sure that the toggle button isn't there
4242
let button = toggleButton(dbg);
4343
let frames = findAllElements(dbg, "frames");
44-
is(button.innerText, "Expand rows", "toggle button should be expand");
44+
is(button.innerText, "Expand rows", "toggle button should be 'expand'");
4545
is(frames.length, 7, "There should be at most seven frames");
4646

4747
button.click();
@@ -50,4 +50,5 @@ add_task(async function() {
5050
frames = findAllElements(dbg, "frames");
5151
is(button.innerText, "Collapse rows", "toggle button should be collapsed");
5252
is(frames.length, 22, "All of the frames should be shown");
53+
await waitForSelectedSource(dbg, "frames.js");
5354
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
* http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
requestLongerTimeout(2);
5+
6+
async function stepOvers(dbg, count, onStep = () => {}) {
7+
let i = 0;
8+
while (i++ <= count) {
9+
await dbg.actions.stepOver();
10+
await waitForPaused(dbg);
11+
onStep(dbg.getState());
12+
}
13+
}
14+
15+
16+
async function testCase(dbg, { name, count, steps }) {
17+
invokeInTab(name);
18+
let locations = []
19+
20+
await stepOvers(dbg, count, state => {
21+
locations.push(dbg.selectors.getTopFrame(state).location)
22+
});
23+
24+
const formattedSteps = locations.map(
25+
({line, column}) => `(${line},${column})`
26+
).join(", ")
27+
28+
is(formattedSteps, steps, name)
29+
30+
await resume(dbg);
31+
}
32+
33+
add_task(async function test() {
34+
const dbg = await initDebugger("doc-pause-points.html");
35+
36+
await testCase(dbg, {
37+
name: "statements",
38+
count: 7,
39+
steps: "(9,2), (10,4), (10,13), (11,2), (11,21), (12,2), (12,12), (13,0)"
40+
});
41+
42+
await testCase(dbg, {
43+
name: "expressions",
44+
count: 4,
45+
steps: "(40,2), (41,2), (41,8), (42,8), (43,0)"
46+
});
47+
48+
await testCase(dbg, {
49+
name: "sequences",
50+
count: 4,
51+
steps: "(23,2), (25,8), (29,8), (34,2), (37,0)"
52+
});
53+
54+
await testCase(dbg, {
55+
name: "flow",
56+
count: 8,
57+
steps: "(16,2), (17,12), (18,6), (19,8), (19,17), (19,8), (19,17), (19,8), (20,0)"
58+
});
59+
});

src/test/mochitest/browser_dbg-sources.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ add_task(async function() {
5151
ok(fourthNode.classList.contains("focused"), "4th node is focused");
5252
ok(
5353
selectedSource.includes("nested-source.js"),
54-
"The right source is selected"
54+
"nested-source is selected"
5555
);
5656

57+
await waitForSelectedSource(dbg, "nested-source");
58+
5759
// Make sure new sources appear in the list.
5860
ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
5961
const script = content.document.createElement("script");

src/test/mochitest/browser_dbg-stepping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ add_task(async function test() {
3333
await stepIn(dbg);
3434

3535
assertSelectedFile(dbg, "bundle.js");
36-
assertDebugLine(dbg, 42264);
36+
assertDebugLine(dbg, 42309);
3737
assertPausedLocation(dbg);
3838
});

0 commit comments

Comments
 (0)