summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Debugger-onPromiseSettled-06.js
blob: 97108bef4437f5b240fdfc0420d34e0b9dd5d56f (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
// Resumption values from onPromiseSettled handlers are disallowed.
if (!('Promise' in this))
    quit(0);

load(libdir + 'asserts.js');

var g = newGlobal();
var dbg = new Debugger(g);
var log;

dbg.onPromiseSettled = function (g) { log += 's'; return undefined; };
log = '';
g.settlePromiseNow(new g.Promise(function (){}));
assertEq(log, 's');

dbg.uncaughtExceptionHook = function (ex) { assertEq(/disallowed/.test(ex), true); log += 'u'; }
dbg.onPromiseSettled = function (g) { log += 's'; return { return: "snoo" }; };
log = '';
g.settlePromiseNow(new g.Promise(function (){}));
assertEq(log, 'su');

dbg.onPromiseSettled = function (g) { log += 's'; return { throw: "snoo" }; };
log = '';
g.settlePromiseNow(new g.Promise(function (){}));
assertEq(log, 'su');

dbg.onPromiseSettled = function (g) { log += 's'; return null; };
log = '';
g.settlePromiseNow(new g.Promise(function (){}));
assertEq(log, 'su');

dbg.uncaughtExceptionHook = function (ex) { assertEq(/foopy/.test(ex), true); log += 'u'; }
dbg.onPromiseSettled = function (g) { log += 's'; throw "foopy"; };
log = '';
g.settlePromiseNow(new g.Promise(function (){}));
assertEq(log, 'su');