Debugger-findScripts-24.js (1420B)
1 // findScripts should reject Debugger.Source objects from other Debuggers. 2 3 load(libdir + 'asserts.js'); 4 5 var g = newGlobal({newCompartment: true}); 6 g.evaluate(`function f() { print("earth/heart/hater"); }`, 7 { lineNumber: 1800 }); 8 9 var dbg1 = new Debugger; 10 var gDO1 = dbg1.addDebuggee(g); 11 var fDO1 = gDO1.getOwnPropertyDescriptor('f').value; 12 assertEq(fDO1.script.source instanceof Debugger.Source, true); 13 14 var dbg2 = new Debugger; 15 var gDO2 = dbg2.addDebuggee(g); 16 var fDO2 = gDO2.getOwnPropertyDescriptor('f').value; 17 assertEq(fDO2.script.source instanceof Debugger.Source, true); 18 19 assertEq(fDO1.script.source !== fDO2.script.source, true); 20 21 // findScripts should reject Debugger.Source objects that don't belong to the 22 // Debugger it's being invoked on. 23 assertThrowsInstanceOf(() => dbg1.findScripts({ source: fDO2.script.source }), 24 TypeError); 25 assertThrowsInstanceOf(() => dbg2.findScripts({ source: fDO1.script.source }), 26 TypeError); 27 28 // findScripts should reject Debugger.Source.prototype. 29 assertThrowsInstanceOf(() => dbg1.findScripts({ source: Debugger.Source.prototype }), 30 TypeError); 31 32 // These should not throw, and should return something, but we're not going to 33 // be picky about exactly what, given findScript's sensitivity to GC. 34 dbg1.findScripts({ source: fDO1.script.source }); 35 dbg2.findScripts({ source: fDO2.script.source });