Debian Codegraph @

js/src/jit-test/tests/debug/Frame-onStep-resumption-05.js

raw
1 // Test that invoking the interrupt callback counts as a step.
2
3 function testResumptionVal(resumptionVal, turnOffDebugMode) {
4 var g = newGlobal({newCompartment: true});
5 var dbg = new Debugger;
6 g.log = "";
7 g.resumptionVal = resumptionVal;
8
9 setInterruptCallback(function () {
10 g.log += "i";
11 dbg.addDebuggee(g);
12 var frame = dbg.getNewestFrame();
13 frame.onStep = function () {
14 g.log += "s";
15 frame.onStep = undefined;
16
17 if (turnOffDebugMode)
18 dbg.removeDebuggee(g);
19
20 return resumptionVal;
21 };
22 return true;
23 });
24
25 try {
26 return g.eval("(" + function f() {
27 log += "f";
28 invokeInterruptCallback(function (interruptRv) {
29 log += "r";
30 assertEq(interruptRv, resumptionVal == undefined);
31 });
32 log += "a";
33 return 42;
34 } + ")();");
35 } finally {
36 assertEq(g.log, resumptionVal == undefined ? "fisra" : "fisr");
37 }
38 }
39
40 assertEq(testResumptionVal(undefined), 42);
41 assertEq(testResumptionVal({ return: "not 42" }), "not 42");
42 try {
43 testResumptionVal({ throw: "thrown 42" });
44 } catch (e) {
45 assertEq(e, "thrown 42");
46 }
47
48 assertEq(testResumptionVal(undefined, true), 42);
49 assertEq(testResumptionVal({ return: "not 42" }, true), "not 42");
50
51 try {
52 testResumptionVal({ throw: "thrown 42" }, true);
53 } catch (e) {
54 assertEq(e, "thrown 42");
55 }