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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Source-text-lazy.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +/*
     1.5 + * Debugger.Source.prototype.text should correctly retrieve the source for
     1.6 + * code compiled with CompileOptions::LAZY_SOURCE.
     1.7 + */
     1.8 +
     1.9 +// withSourceHook isn't defined if you pass the shell the --fuzzing-safe
    1.10 +// option. Skip this test silently, to avoid spurious failures.
    1.11 +if (typeof withSourceHook != 'function')
    1.12 +  quit(0);
    1.13 +
    1.14 +let g = newGlobal();
    1.15 +let dbg = new Debugger(g);
    1.16 +
    1.17 +function test(source) {
    1.18 +  // To ensure that we're getting the value the source hook returns, make
    1.19 +  // it differ from the actual source.
    1.20 +  let frobbed = source.replace(/debugger/, 'reggubed');
    1.21 +  let log = '';
    1.22 +
    1.23 +  withSourceHook(function (url) {
    1.24 +    log += 's';
    1.25 +    assertEq(url, "BanalBivalve.jsm");
    1.26 +    return frobbed;
    1.27 +  }, () => {
    1.28 +    dbg.onDebuggerStatement = function (frame) {
    1.29 +      log += 'd';
    1.30 +      assertEq(frame.script.source.text, frobbed);
    1.31 +    }
    1.32 +
    1.33 +    g.evaluate(source, { fileName: "BanalBivalve.jsm",
    1.34 +                         sourceIsLazy: true });
    1.35 +  });
    1.36 +
    1.37 +  assertEq(log, 'ds');
    1.38 +}
    1.39 +
    1.40 +test("debugger; // Ignominious Iguana");
    1.41 +test("(function () { debugger; /* Meretricious Marmoset */})();");
    1.42 +test("(() => { debugger; })(); // Gaunt Gibbon");

mercurial