Debugger-findScripts-optimized-out.js (762B)
1 // Accessing Debugger.Script's properties which triggers delazification can 2 // fail if the function for the script is optimized out. 3 // It shouldn't crash but just throw an error. 4 5 load(libdir + "asserts.js"); 6 7 var g = newGlobal({newCompartment: true}); 8 var dbg = new Debugger(g); 9 g.eval(` 10 function enclosing() { 11 (function g1() {}); 12 (function* g2() {}); 13 (async function g3() {}); 14 (async function* g4() {}); 15 () => {}; 16 async () => {}; 17 } 18 `); 19 20 for (const s of dbg.findScripts()) { 21 if (!s.displayName) { 22 continue; 23 } 24 25 try { 26 s.lineCount; // don't assert 27 } catch (exc) { 28 // If that didn't throw, it's fine. If it did, check the message. 29 assertEq(exc.message, "function is optimized out"); 30 } 31 }