Debian Codegraph @

js/src/jit-test/tests/debug/onExceptionUnwind-resumption-generator.js

raw
1 load(libdir + "asserts.js");
2
3 var g = newGlobal({newCompartment: true});
4 var dbg = Debugger(g);
5
6 g.eval(`
7 function* f() {
8 e;
9 }
10 `);
11
12 // To continue testing after uncaught exception, remember the exception and
13 // return normal completion.
14 var currentFrame;
15 var uncaughtException;
16 dbg.uncaughtExceptionHook = function(e) {
17 uncaughtException = e;
18 return {
19 return: "uncaught"
20 };
21 };
22 function testUncaughtException() {
23 uncaughtException = undefined;
24 var obj = g.eval(`f().next()`);
25 assertEq(obj.done, true);
26 assertEq(obj.value, 'uncaught');
27 assertEq(uncaughtException instanceof TypeError, true);
28 }
29
30 // Just continue
31 dbg.onExceptionUnwind = function(frame) {
32 return undefined;
33 };
34 assertThrowsInstanceOf(() => g.eval(`f().next();`), g.ReferenceError);
35
36 // Forced early return
37 dbg.onExceptionUnwind = function(frame) {
38 currentFrame = frame;
39 return {
40 return: "foo"
41 };
42 };
43 var obj = g.eval(`f().next()`);
44 assertEq(obj.done, true);
45 assertEq(obj.value, "foo");
46
47 // Bad resumption value
48 dbg.onExceptionUnwind = function(frame) {
49 currentFrame = frame;
50 return {declaim: "gadzooks"};
51 };
52 testUncaughtException();