summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-async-02.js
blob: 8e579b588b6b974bd808fdc28bdcd1882e90e976 (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
// |jit-test| error:all-jobs-completed-successfully

load(libdir + 'match.js');
load(libdir + 'match-debugger.js');
const { Pattern } = Match;
const { OBJECT_WITH_EXACTLY: EXACT } = Pattern;

let g = newGlobal({newCompartment: true});
let dbg = Debugger(g);
const log = [];
g.capture = function () {
  dbg.getNewestFrame().onPop = completion => {
    log.push(completion);
  };
};

g.eval(`
    async function f() {
        capture();
        await Promise.resolve(3);
        return "ok";
    }
`);


const promise = g.f();
promise.then(value => {
  assertEq(value, "ok");

  Pattern([
    EXACT({ return: new DebuggerObjectPattern("Promise"), await:true }),
    EXACT({ return: new DebuggerObjectPattern("Promise") }),
  ]).assert(log);

  throw "all-jobs-completed-successfully";
});