js/src/jit-test/tests/debug/Source-text-lazy.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  * Debugger.Source.prototype.text should correctly retrieve the source for
     3  * code compiled with CompileOptions::LAZY_SOURCE.
     4  */
     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);
    11 let g = newGlobal();
    12 let dbg = new Debugger(g);
    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 = '';
    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     }
    30     g.evaluate(source, { fileName: "BanalBivalve.jsm",
    31                          sourceIsLazy: true });
    32   });
    34   assertEq(log, 'ds');
    35 }
    37 test("debugger; // Ignominious Iguana");
    38 test("(function () { debugger; /* Meretricious Marmoset */})();");
    39 test("(() => { debugger; })(); // Gaunt Gibbon");

mercurial