summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-source-location.js
blob: fef9df7770c77faefb81d82834780d3971c1c902 (plain)
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
// Ensure onPop hook for the final return/yield uses the correct source location
// (closing '}' of the function body).

var g = newGlobal({newCompartment: true});
var dbg = new Debugger(g);
dbg.onEnterFrame = frame => {
    if (frame.type === "global") {
        return;
    }
    frame.onPop = c => {
        if (c.yield !== true) {
            const data = frame.script.getOffsetMetadata(frame.offset);
            g.log.push(`pop(${data.lineNumber}:${data.columnNumber})`);
        }
    };
};
g.evaluate(`                 // line 1
this.log = [];               // 2
function A() {               // 3
    log.push("A");           // 4
    if (log === null) {      // 5
        throw "fail";        // 6
    }                        // 7
}                            // 8
function* B() {              // 9
    log.push("B");           // 10
    if (log === null) {      // 11
        throw "fail";        // 12
    }                        // 13
}                            // 14
async function C() {         // 15
    log.push("C");           // 16
    if (log === null) {      // 17
        throw "fail";        // 18
    }                        // 19
}                            // 20
let D = async () => {        // 21
    log.push("D");           // 22
    if (log === null) {      // 23
        throw "fail";        // 24
    }                        // 25
};                           // 26
class E extends class {} {   // 27
    constructor() {          // 28
        log.push("E");       // 29
        super();             // 30
        if (log === null) {  // 31
            throw "fail";    // 32
        }                    // 33
    }                        // 34
}                            // 35
A();
for (let x of B()) {}
C();
D();
new E();
`);
assertEq(g.log.join(","), "A,pop(8:1),B,pop(14:1),C,pop(20:1),D,pop(26:1),E,pop(27:17),pop(34:5)");