Source-text-lazy.js (1154B)
1 // |jit-test| skip-if: typeof withSourceHook !== 'function' 2 // withSourceHook isn't defined if you pass the shell the --fuzzing-safe 3 // option. Skip this test silently, to avoid spurious failures. 4 5 /* 6 * Debugger.Source.prototype.text should correctly retrieve the source for 7 * code compiled with CompileOptions::LAZY_SOURCE. 8 */ 9 10 let g = newGlobal({newCompartment: true}); 11 let dbg = new Debugger(g); 12 13 function test(source) { 14 // To ensure that we're getting the value the source hook returns, make 15 // it differ from the actual source. 16 let frobbed = source.replace(/debugger/, 'reggubed'); 17 let log = ''; 18 19 withSourceHook(function (url) { 20 log += 's'; 21 assertEq(url, "BanalBivalve.jsm"); 22 return frobbed; 23 }, () => { 24 dbg.onDebuggerStatement = function (frame) { 25 log += 'd'; 26 assertEq(frame.script.source.text, frobbed); 27 } 28 29 g.evaluate(source, { fileName: "BanalBivalve.jsm", 30 sourceIsLazy: true }); 31 }); 32 33 assertEq(log, 'ds'); 34 } 35 36 test("debugger; // Ignominious Iguana"); 37 test("(function () { debugger; /* Meretricious Marmoset */})();"); 38 test("(() => { debugger; })(); // Gaunt Gibbon");