Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // findScripts can filter scripts by global. |
michael@0 | 2 | var g1 = newGlobal(); |
michael@0 | 3 | var g2 = newGlobal(); |
michael@0 | 4 | var g3 = newGlobal(); |
michael@0 | 5 | |
michael@0 | 6 | var dbg = new Debugger(); |
michael@0 | 7 | var g1w = dbg.addDebuggee(g1); |
michael@0 | 8 | var g2w = dbg.addDebuggee(g2); |
michael@0 | 9 | |
michael@0 | 10 | g1.eval('function f() {}'); |
michael@0 | 11 | g2.eval('function g() {}'); |
michael@0 | 12 | g2.eval('function h() {}'); |
michael@0 | 13 | var g1fw = g1w.makeDebuggeeValue(g1.f); |
michael@0 | 14 | var g2gw = g2w.makeDebuggeeValue(g2.g); |
michael@0 | 15 | |
michael@0 | 16 | var scripts; |
michael@0 | 17 | |
michael@0 | 18 | scripts = dbg.findScripts({}); |
michael@0 | 19 | assertEq(scripts.indexOf(g1fw.script) != -1, true); |
michael@0 | 20 | assertEq(scripts.indexOf(g2gw.script) != -1, true); |
michael@0 | 21 | |
michael@0 | 22 | scripts = dbg.findScripts({global: g1}); |
michael@0 | 23 | assertEq(scripts.indexOf(g1fw.script) != -1, true); |
michael@0 | 24 | assertEq(scripts.indexOf(g2gw.script) != -1, false); |
michael@0 | 25 | |
michael@0 | 26 | scripts = dbg.findScripts({global: g2}); |
michael@0 | 27 | assertEq(scripts.indexOf(g1fw.script) != -1, false); |
michael@0 | 28 | assertEq(scripts.indexOf(g2gw.script) != -1, true); |
michael@0 | 29 | |
michael@0 | 30 | scripts = dbg.findScripts({global: g3}); |
michael@0 | 31 | // findScripts should only return debuggee scripts, and g3 isn't a |
michael@0 | 32 | // debuggee, so this should be completely empty. |
michael@0 | 33 | assertEq(scripts.length, 0); |