michael@0: // Debugger.prototype.findScripts can find the innermost script at a given michael@0: // source location. michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(); michael@0: var gw = dbg.addDebuggee(g); michael@0: michael@0: function script(f) { michael@0: return gw.makeDebuggeeValue(f).script; michael@0: } michael@0: michael@0: function arrayIsOnly(array, element) { michael@0: return array.length == 1 && array[0] === element; michael@0: } michael@0: michael@0: url = scriptdir + 'Debugger-findScripts-14.script1'; michael@0: g.load(url); michael@0: michael@0: var scripts; michael@0: michael@0: // When we're doing 'innermost' queries, we don't have to worry about finding michael@0: // random eval scripts: we should get exactly one script, for the function michael@0: // covering that line. michael@0: scripts = dbg.findScripts({url:url, line:4, innermost:true}); michael@0: assertEq(arrayIsOnly(scripts, script(g.f)), true); michael@0: michael@0: scripts = dbg.findScripts({url:url, line:6, innermost:true}); michael@0: assertEq(arrayIsOnly(scripts, script(g.f())), true); michael@0: michael@0: scripts = dbg.findScripts({url:url, line:8, innermost:true}); michael@0: assertEq(arrayIsOnly(scripts, script(g.f()())), true);