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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial