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
|
/* 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/>. */
"use strict";
// Tests for stepping through Babel's compile output.
requestLongerTimeout(4);
add_task(async function () {
const dbg = await initDebugger("doc-sourcemapped.html");
await testStepOverForOf(dbg);
await testStepOverForOfArray(dbg);
await testStepOveForOfClosure(dbg);
await testStepOverForOfArrayClosure(dbg);
await testStepOverFunctionParams(dbg);
await testStepOverRegeneratorAwait(dbg);
});
async function breakpointSteps(dbg, target, fixture, { line, column }, steps) {
const filename = `${target}://./${fixture}/input.`;
const fnName = `${target}-${fixture}`.replace(/-([a-z])/g, (s, c) =>
c.toUpperCase()
);
await invokeWithBreakpoint(
dbg,
fnName,
filename,
{ line, column },
async source => {
await runSteps(dbg, source, steps);
}
);
ok(true, `Ran tests for ${fixture} at line ${line} column ${column}`);
}
async function runSteps(dbg, source, steps) {
for (const [i, [type, position]] of steps.entries()) {
info(`Step ${i}`);
switch (type) {
case "stepOver":
await stepOver(dbg);
break;
case "stepIn":
await stepIn(dbg);
break;
default:
throw new Error("Unknown stepping type");
}
assertPausedAtSourceAndLine(dbg, source.id, position.line, position.column);
}
}
function testStepOverForOf(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-for-of",
{ line: 4, column: 2 },
[
["stepOver", { line: 6, column: 20 }],
["stepOver", { line: 6, column: 2 }],
["stepOver", { line: 7, column: 4 }],
["stepOver", { line: 6, column: 2 }],
["stepOver", { line: 7, column: 4 }],
["stepOver", { line: 6, column: 2 }],
["stepOver", { line: 10, column: 2 }],
]
);
}
// This codifies the current behavior, but stepping twice over the for
// header isn't ideal.
function testStepOverForOfArray(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-for-of-array",
{ line: 3, column: 2 },
[
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 5, column: 13 }],
["stepOver", { line: 6, column: 4 }],
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 5, column: 13 }],
["stepOver", { line: 6, column: 4 }],
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 9, column: 2 }],
]
);
}
// The closure means it isn't actually possible to step into the for body,
// and Babel doesn't map the _loop() call, so we step past it automatically.
function testStepOveForOfClosure(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-for-of-closure",
{ line: 6, column: 2 },
[
["stepOver", { line: 8, column: 20 }],
["stepOver", { line: 8, column: 2 }],
["stepOver", { line: 12, column: 2 }],
]
);
}
// Same as the previous, not possible to step into the body. The less
// complicated array logic makes it possible to step into the header at least,
// but this does end up double-visiting the for head.
function testStepOverForOfArrayClosure(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-for-of-array-closure",
{ line: 3, column: 2 },
[
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 5, column: 13 }],
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 5, column: 13 }],
["stepOver", { line: 5, column: 2 }],
["stepOver", { line: 9, column: 2 }],
]
);
}
function testStepOverFunctionParams(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-function-params",
{ line: 6, column: 2 },
[
["stepOver", { line: 7, column: 2 }],
["stepIn", { line: 2, column: 2 }],
]
);
}
function testStepOverRegeneratorAwait(dbg) {
return breakpointSteps(
dbg,
"webpack3-babel6",
"step-over-regenerator-await",
{ line: 2, column: 2 },
[
// Won't work until a fix to regenerator lands and we rebuild.
// https://github.com/facebook/regenerator/issues/342
// ["stepOver", { line: 4, column: 2 }],
]
);
}
|