Debugger-findScripts-08.js (3114B)
1 // Debugger.prototype.findScripts can filter scripts by URL. 2 var g1 = newGlobal({newCompartment: true}); 3 var g2 = newGlobal({newCompartment: true}); 4 var g3 = newGlobal({newCompartment: true}); 5 6 // Define some functions whose url will be this test file. 7 g1.eval('function g1f() {}'); 8 g2.eval('function g2f() {}'); 9 10 // Define some functions whose url will be a different file. 11 url2 = scriptdir + "Debugger-findScripts-08-script2"; 12 load(url2); 13 14 var dbg = new Debugger(); 15 var g1w = dbg.addDebuggee(g1); 16 var g2w = dbg.addDebuggee(g2); 17 var g3w = dbg.addDebuggee(g3); 18 19 var g1fw = g1w.makeDebuggeeValue(g1.g1f); 20 var g1gw = g1w.makeDebuggeeValue(g1.g1g); 21 var g2fw = g2w.makeDebuggeeValue(g2.g2f); 22 var g2gw = g2w.makeDebuggeeValue(g2.g2g); 23 24 // Find the url of this file. 25 url = g1fw.script.url; 26 27 var scripts; 28 29 scripts = dbg.findScripts({}); 30 assertEq(scripts.indexOf(g1fw.script) != -1, true); 31 assertEq(scripts.indexOf(g1gw.script) != -1, true); 32 assertEq(scripts.indexOf(g2fw.script) != -1, true); 33 assertEq(scripts.indexOf(g2gw.script) != -1, true); 34 35 scripts = dbg.findScripts({url:url}); 36 assertEq(scripts.indexOf(g1fw.script) != -1, true); 37 assertEq(scripts.indexOf(g1gw.script) != -1, false); 38 assertEq(scripts.indexOf(g2fw.script) != -1, true); 39 assertEq(scripts.indexOf(g2gw.script) != -1, false); 40 41 scripts = dbg.findScripts({url:url2}); 42 assertEq(scripts.indexOf(g1fw.script) != -1, false); 43 assertEq(scripts.indexOf(g1gw.script) != -1, true); 44 assertEq(scripts.indexOf(g2fw.script) != -1, false); 45 assertEq(scripts.indexOf(g2gw.script) != -1, true); 46 47 scripts = dbg.findScripts({url:url, global:g1}); 48 assertEq(scripts.indexOf(g1fw.script) != -1, true); 49 assertEq(scripts.indexOf(g1gw.script) != -1, false); 50 assertEq(scripts.indexOf(g2fw.script) != -1, false); 51 assertEq(scripts.indexOf(g2gw.script) != -1, false); 52 53 scripts = dbg.findScripts({url:url2, global:g1}); 54 assertEq(scripts.indexOf(g1fw.script) != -1, false); 55 assertEq(scripts.indexOf(g1gw.script) != -1, true); 56 assertEq(scripts.indexOf(g2fw.script) != -1, false); 57 assertEq(scripts.indexOf(g2gw.script) != -1, false); 58 59 scripts = dbg.findScripts({url:url, global:g2}); 60 assertEq(scripts.indexOf(g1fw.script) != -1, false); 61 assertEq(scripts.indexOf(g1gw.script) != -1, false); 62 assertEq(scripts.indexOf(g2fw.script) != -1, true); 63 assertEq(scripts.indexOf(g2gw.script) != -1, false); 64 65 scripts = dbg.findScripts({url:url2, global:g2}); 66 assertEq(scripts.indexOf(g1fw.script) != -1, false); 67 assertEq(scripts.indexOf(g1gw.script) != -1, false); 68 assertEq(scripts.indexOf(g2fw.script) != -1, false); 69 assertEq(scripts.indexOf(g2gw.script) != -1, true); 70 71 scripts = dbg.findScripts({url:"xlerb"}); // "XLERB"??? 72 assertEq(scripts.indexOf(g1fw.script) != -1, false); 73 assertEq(scripts.indexOf(g1gw.script) != -1, false); 74 assertEq(scripts.indexOf(g2fw.script) != -1, false); 75 assertEq(scripts.indexOf(g2gw.script) != -1, false); 76 77 scripts = dbg.findScripts({url:url, global:g3}); 78 assertEq(scripts.indexOf(g1fw.script) != -1, false); 79 assertEq(scripts.indexOf(g1gw.script) != -1, false); 80 assertEq(scripts.indexOf(g2fw.script) != -1, false); 81 assertEq(scripts.indexOf(g2gw.script) != -1, false);