js/src/jit-test/tests/debug/Debugger-findScripts-18.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 // In a debuggee with multiple scripts with varying displayURLs (aka //#
michael@0 2 // sourceURL), findScripts can filter by displayURL.
michael@0 3
michael@0 4 var g = newGlobal();
michael@0 5
michael@0 6 g.eval("function f(){} //# sourceURL=f.js");
michael@0 7 g.eval("function g(){} //# sourceURL=g.js");
michael@0 8 g.eval("function h(){}");
michael@0 9
michael@0 10 var dbg = new Debugger();
michael@0 11 var gw = dbg.addDebuggee(g);
michael@0 12 var fw = gw.makeDebuggeeValue(g.f);
michael@0 13 var ggw = gw.makeDebuggeeValue(g.g);
michael@0 14 var hw = gw.makeDebuggeeValue(g.h);
michael@0 15
michael@0 16 var fScripts = dbg.findScripts({ displayURL: "f.js" });
michael@0 17 assertEq(fScripts.indexOf(fw.script) != -1, true);
michael@0 18 assertEq(fScripts.indexOf(ggw.script), -1);
michael@0 19 assertEq(fScripts.indexOf(hw.script), -1);
michael@0 20
michael@0 21 var gScripts = dbg.findScripts({ displayURL: "g.js" });
michael@0 22 assertEq(gScripts.indexOf(ggw.script) != -1, true);
michael@0 23 assertEq(gScripts.indexOf(fw.script), -1);
michael@0 24 assertEq(gScripts.indexOf(hw.script), -1);
michael@0 25
michael@0 26 var allScripts = dbg.findScripts();
michael@0 27 assertEq(allScripts.indexOf(fw.script) != -1, true);
michael@0 28 assertEq(allScripts.indexOf(ggw.script) != -1, true);
michael@0 29 assertEq(allScripts.indexOf(hw.script) != -1, true);
michael@0 30
michael@0 31 try {
michael@0 32 dbg.findScripts({ displayURL: 3 });
michael@0 33 // Should never get here because the above line should throw
michael@0 34 // JSMSG_UNEXPECTED_TYPE.
michael@0 35 assertEq(true, false);
michael@0 36 } catch(e) {
michael@0 37 assertEq(e.name, "TypeError");
michael@0 38 assertEq(e.message.contains("displayURL"), true);
michael@0 39 }

mercurial