prologueFailure-02.js (1200B)
1 g = newGlobal({newCompartment: true}); 2 g.parent = this; 3 4 function installHook() { 5 let calledTimes = 0; 6 function hook(frame) { 7 calledTimes++; 8 switch (calledTimes) { 9 case 1: 10 // Proxy get trap 11 assertEq(frame.type, "call"); 12 assertEq(frame.script.displayName.includes("get"), true); 13 break; 14 case 2: 15 // wrapper function. There is no entry for notRun 16 assertEq(frame.type, "call"); 17 assertEq(frame.script.displayName.includes("wrapper"), true); 18 break; 19 case 3: 20 assertEq(frame.type, "global"); 21 // Force the top-level to return cleanly, so that we can tell 22 // assertion failures from the intended throwing. 23 return { return: undefined }; 24 25 default: 26 // that's the whole chain. 27 assertEq(false, true); 28 } 29 } 30 31 Debugger(parent).onExceptionUnwind = hook; 32 } 33 34 35 g.eval("(" + installHook + ")()"); 36 37 var handler = { 38 get(t, p) { 39 throw new TypeError; 40 } 41 }; 42 43 function notRun() {} 44 45 function wrapper() { 46 var f = new Proxy(notRun, handler); 47 new f(); 48 } 49 wrapper();