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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check scenarios where we're leaving function a and
* going to the function b's call-site.
*/
async function testFinish({ threadFront, devToolsClient }) {
await close(devToolsClient);
do_test_finished();
}
async function invokeAndPause({ global, threadFront }, expression) {
return executeOnNextTickAndWaitForPause(
() => Cu.evalInSandbox(expression, global),
threadFront
);
}
async function steps(threadFront, sequence) {
const locations = [];
for (const cmd of sequence) {
const packet = await step(threadFront, cmd);
locations.push(getPauseLocation(packet));
}
return locations;
}
async function step(threadFront, cmd) {
return cmd(threadFront);
}
function getPauseLocation(packet) {
const { line, column } = packet.frame.where;
return { line, column };
}
async function stepOutOfA(dbg, func, frameIndex, expectedLocation) {
const { threadFront } = dbg;
info("pause and step into a()");
await invokeAndPause(dbg, `${func}()`);
await steps(threadFront, [stepOver, stepIn, stepIn]);
const { frames } = await threadFront.frames(0, 5);
const frameActorID = frames[frameIndex].actorID;
const packet = await stepOut(threadFront, frameActorID);
deepEqual(
getPauseLocation(packet),
expectedLocation,
`step over location in ${func}`
);
await dbg.threadFront.resume();
}
async function stepOverInA(dbg, func, frameIndex, expectedLocation) {
const { threadFront } = dbg;
info("pause and step into a()");
await invokeAndPause(dbg, `${func}()`);
await steps(threadFront, [stepOver, stepIn]);
const { frames } = await threadFront.frames(0, 5);
const frameActorID = frames[frameIndex].actorID;
const packet = await stepOver(threadFront, frameActorID);
deepEqual(
getPauseLocation(packet),
expectedLocation,
`step over location in ${func}`
);
await dbg.threadFront.resume();
}
function run_test() {
return (async function() {
const dbg = await setupTestFromUrl("stepping.js");
info(`Test step over with the 1st frame`);
await stepOverInA(dbg, "arithmetic", 0, { line: 8, column: 0 });
info(`Test step over with the 2nd frame`);
await stepOverInA(dbg, "arithmetic", 1, { line: 17, column: 0 });
info(`Test step out with the 1st frame`);
await stepOutOfA(dbg, "nested", 0, { line: 31, column: 0 });
info(`Test step out with the 2nd frame`);
await stepOutOfA(dbg, "nested", 1, { line: 36, column: 0 });
await testFinish(dbg);
})();
}
|