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