1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Debugger-findScripts-08.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +// Debugger.prototype.findScripts can filter scripts by URL. 1.5 +var g1 = newGlobal(); 1.6 +var g2 = newGlobal(); 1.7 +var g3 = newGlobal(); 1.8 + 1.9 +// Define some functions whose url will be this test file. 1.10 +g1.eval('function g1f() {}'); 1.11 +g2.eval('function g2f() {}'); 1.12 + 1.13 +// Define some functions whose url will be a different file. 1.14 +url2 = scriptdir + "Debugger-findScripts-08-script2"; 1.15 +load(url2); 1.16 + 1.17 +var dbg = new Debugger(); 1.18 +var g1w = dbg.addDebuggee(g1); 1.19 +var g2w = dbg.addDebuggee(g2); 1.20 +var g3w = dbg.addDebuggee(g3); 1.21 + 1.22 +var g1fw = g1w.makeDebuggeeValue(g1.g1f); 1.23 +var g1gw = g1w.makeDebuggeeValue(g1.g1g); 1.24 +var g2fw = g2w.makeDebuggeeValue(g2.g2f); 1.25 +var g2gw = g2w.makeDebuggeeValue(g2.g2g); 1.26 + 1.27 +// Find the url of this file. 1.28 +url = g1fw.script.url; 1.29 + 1.30 +var scripts; 1.31 + 1.32 +scripts = dbg.findScripts({}); 1.33 +assertEq(scripts.indexOf(g1fw.script) != -1, true); 1.34 +assertEq(scripts.indexOf(g1gw.script) != -1, true); 1.35 +assertEq(scripts.indexOf(g2fw.script) != -1, true); 1.36 +assertEq(scripts.indexOf(g2gw.script) != -1, true); 1.37 + 1.38 +scripts = dbg.findScripts({url:url}); 1.39 +assertEq(scripts.indexOf(g1fw.script) != -1, true); 1.40 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.41 +assertEq(scripts.indexOf(g2fw.script) != -1, true); 1.42 +assertEq(scripts.indexOf(g2gw.script) != -1, false); 1.43 + 1.44 +scripts = dbg.findScripts({url:url2}); 1.45 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.46 +assertEq(scripts.indexOf(g1gw.script) != -1, true); 1.47 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.48 +assertEq(scripts.indexOf(g2gw.script) != -1, true); 1.49 + 1.50 +scripts = dbg.findScripts({url:url, global:g1}); 1.51 +assertEq(scripts.indexOf(g1fw.script) != -1, true); 1.52 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.53 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.54 +assertEq(scripts.indexOf(g2gw.script) != -1, false); 1.55 + 1.56 +scripts = dbg.findScripts({url:url2, global:g1}); 1.57 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.58 +assertEq(scripts.indexOf(g1gw.script) != -1, true); 1.59 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.60 +assertEq(scripts.indexOf(g2gw.script) != -1, false); 1.61 + 1.62 +scripts = dbg.findScripts({url:url, global:g2}); 1.63 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.64 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.65 +assertEq(scripts.indexOf(g2fw.script) != -1, true); 1.66 +assertEq(scripts.indexOf(g2gw.script) != -1, false); 1.67 + 1.68 +scripts = dbg.findScripts({url:url2, global:g2}); 1.69 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.70 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.71 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.72 +assertEq(scripts.indexOf(g2gw.script) != -1, true); 1.73 + 1.74 +scripts = dbg.findScripts({url:"xlerb"}); // "XLERB"??? 1.75 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.76 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.77 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.78 +assertEq(scripts.indexOf(g2gw.script) != -1, false); 1.79 + 1.80 +scripts = dbg.findScripts({url:url, global:g3}); 1.81 +assertEq(scripts.indexOf(g1fw.script) != -1, false); 1.82 +assertEq(scripts.indexOf(g1gw.script) != -1, false); 1.83 +assertEq(scripts.indexOf(g2fw.script) != -1, false); 1.84 +assertEq(scripts.indexOf(g2gw.script) != -1, false);