Bug 738480 - Debugger.prototype.findScripts does not find non-compileAndGo scripts. r=jimb.

--HG--
extra : rebase_source : e66841593e3a8d05fda50e1cdbbb7068713eff81
This commit is contained in:
Jason Orendorff 2012-05-23 12:06:02 -05:00
parent ad369aa65c
commit c7dbc89b0c
2 changed files with 17 additions and 26 deletions

View File

@ -0,0 +1,9 @@
// findScripts finds non-compile-and-go scripts.
var g = newGlobal("new-compartment");
g.evaluate("function f(x) { return x + 1; }", {compileAndGo: false});
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var s = dbg.findScripts();
var fw = gw.getOwnPropertyDescriptor("f").value;
assertEq(s.indexOf(fw.script) !== -1, true);

View File

@ -2066,30 +2066,7 @@ class Debugger::ScriptQuery {
/* Search each compartment for debuggee scripts. */
for (CompartmentSet::Range r = compartments.all(); !r.empty(); r.popFront()) {
for (gc::CellIter i(r.front(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
JSScript *script = i.get<JSScript>();
GlobalObject *global = script->getGlobalObjectOrNull();
if (global && !consider(script, global, vector))
return false;
}
}
/*
* Since eval scripts have no global, we need to find them via the call
* stack, where frame's scope tells us the global in use.
*/
for (ScriptFrameIter fri(cx); !fri.done(); ++fri) {
if (fri.isEvalFrame()) {
JSScript *script = fri.script();
/*
* If eval scripts never have global objects set, then we don't need
* to check the existing script vector for duplicates, since we only
* include scripts with globals above.
*/
JS_ASSERT(!script->getGlobalObjectOrNull());
GlobalObject *global = &fri.fp()->global();
if (!consider(script, global, vector))
if (!consider(i.get<JSScript>(), vector))
return false;
}
}
@ -2209,9 +2186,14 @@ class Debugger::ScriptQuery {
* |vector| or place it in |innermostForGlobal|, as appropriate. Return true
* if no error occurs, false if an error occurs.
*/
bool consider(JSScript *script, GlobalObject *global, AutoScriptVector *vector) {
if (!globals.has(global))
bool consider(JSScript *script, AutoScriptVector *vector) {
// Non-compile-and-go scripts aren't associated with any global. In
// Gecko, this includes scripts loaded using C.u.import. Rather than
// ignore them, we include them all.
GlobalObject *global = script->getGlobalObjectOrNull();
if (global && !globals.has(global))
return true;
if (urlCString.ptr()) {
if (!script->filename || strcmp(script->filename, urlCString.ptr()) != 0)
return true;