Bug 796073: Use Debugger.Object.prototype.makeDebuggeeValue where appropriate, not Debugger.prototype.addDebuggee. r=luke

Many tests use Debugger.prototype.addDebuggee to produce Debugger.Object
instances referring to random objects. Now we have
Debugger.Object.prototype.makeDebuggeeValue to do that, which is more
careful about wrappers. This patch changes all the existing tests that
abuse addDebuggee in this way (well, they didn't have any choice when they
were written) to use makeDebuggeeValue instead, in preparation for
tightening up addDebuggee to only accept global objects.
This commit is contained in:
Jim Blandy 2012-10-13 16:04:41 -07:00
parent 9e7714919a
commit b755c3b751
11 changed files with 48 additions and 33 deletions

View File

@ -5,10 +5,11 @@ g.eval('function f(){}');
g.eval('function g(){}');
g.eval('function h(){}');
var dbg = new Debugger(g);
var fw = dbg.addDebuggee(g.f);
var gw = dbg.addDebuggee(g.g);
var hw = dbg.addDebuggee(g.h);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var fw = gw.makeDebuggeeValue(g.f);
var gw = gw.makeDebuggeeValue(g.g);
var hw = gw.makeDebuggeeValue(g.h);
assertEq(dbg.findScripts().indexOf(fw.script) != -1, true);
assertEq(dbg.findScripts().indexOf(gw.script) != -1, true);

View File

@ -1,12 +1,13 @@
// findScripts' result includes scripts for nested functions.
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var log;
g.eval('function f() { return function g() { return function h() { return "Squee!"; } } }');
var fw = dbg.addDebuggee(g.f);
var gw = dbg.addDebuggee(g.f());
var hw = dbg.addDebuggee(g.f()());
var fw = gw.makeDebuggeeValue(g.f);
var gw = gw.makeDebuggeeValue(g.f());
var hw = gw.makeDebuggeeValue(g.f()());
assertEq(fw.script != gw.script, true);
assertEq(fw.script != hw.script, true);

View File

@ -1,11 +1,13 @@
// In a debugger with multiple debuggees, findScripts finds scripts across all debuggees.
var g1 = newGlobal('new-compartment');
var g2 = newGlobal('new-compartment');
var dbg = new Debugger(g1, g2);
var dbg = new Debugger();
var g1w = dbg.addDebuggee(g1);
var g2w = dbg.addDebuggee(g2);
g1.eval('function f() {}');
g2.eval('function g() {}');
var scripts = dbg.findScripts();
assertEq(scripts.indexOf(dbg.addDebuggee(g1.f).script) != -1, true);
assertEq(scripts.indexOf(dbg.addDebuggee(g2.g).script) != -1, true);
assertEq(scripts.indexOf(g1w.makeDebuggeeValue(g1.f).script) != -1, true);
assertEq(scripts.indexOf(g2w.makeDebuggeeValue(g2.g).script) != -1, true);

View File

@ -3,13 +3,15 @@ var g1 = newGlobal('new-compartment');
var g2 = newGlobal('new-compartment');
var g3 = newGlobal('new-compartment');
var dbg = new Debugger(g1, g2);
var dbg = new Debugger();
var g1w = dbg.addDebuggee(g1);
var g2w = dbg.addDebuggee(g2);
g1.eval('function f() {}');
g2.eval('function g() {}');
g2.eval('function h() {}');
var g1fw = dbg.addDebuggee(g1.f);
var g2gw = dbg.addDebuggee(g2.g);
var g1fw = g1w.makeDebuggeeValue(g1.f);
var g2gw = g2w.makeDebuggeeValue(g2.g);
var scripts;

View File

@ -11,12 +11,15 @@ g2.eval('function g2f() {}');
url2 = scriptdir + "Debugger-findScripts-08-script2";
load(url2);
var dbg = new Debugger(g1, g2, g3);
var dbg = new Debugger();
var g1w = dbg.addDebuggee(g1);
var g2w = dbg.addDebuggee(g2);
var g3w = dbg.addDebuggee(g3);
var g1fw = dbg.addDebuggee(g1.g1f);
var g1gw = dbg.addDebuggee(g1.g1g);
var g2fw = dbg.addDebuggee(g2.g2f);
var g2gw = dbg.addDebuggee(g2.g2g);
var g1fw = g1w.makeDebuggeeValue(g1.g1f);
var g1gw = g1w.makeDebuggeeValue(g1.g1g);
var g2fw = g2w.makeDebuggeeValue(g2.g2f);
var g2gw = g2w.makeDebuggeeValue(g2.g2g);
// Find the url of this file.
url = g1fw.script.url;

View File

@ -1,13 +1,14 @@
// Debugger.prototype.findScripts can filter scripts by line number.
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var g = newGlobal();
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var scriptname = scriptdir + 'Debugger-findScripts-11-script2';
g.load(scriptname);
var gfw = dbg.addDebuggee(g.f);
var ggw = dbg.addDebuggee(g.f());
var ghw = dbg.addDebuggee(g.h);
var gfw = gw.makeDebuggeeValue(g.f);
var ggw = gw.makeDebuggeeValue(g.f());
var ghw = gw.makeDebuggeeValue(g.h);
// Specifying a line outside of all functions screens out all function scripts.
assertEq(dbg.findScripts({url:scriptname, line:3}).indexOf(gfw.script) != -1, false);

View File

@ -18,7 +18,8 @@ var g3 = newGlobal('new-compartment');
var dbg = new Debugger(g1, g2, g3);
function script(func) {
var script = dbg.addDebuggee(func).script;
var gw = dbg.addDebuggee(func.global);
var script = gw.makeDebuggeeValue(func).script;
script.toString = function ()
"[Debugger.Script for " + func.name + " in " + uneval(func.global) + "]";
return script;

View File

@ -1,10 +1,11 @@
// Debugger.prototype.findScripts can find the innermost script at a given
// source location.
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
function script(f) {
return dbg.addDebuggee(f).script;
return gw.makeDebuggeeValue(f).script;
}
function arrayIsOnly(array, element) {

View File

@ -1,11 +1,12 @@
// Setting onPop handlers from breakpoint handlers works.
var g = newGlobal('new-compartment');
g.eval("function f(){ return 'to normalcy'; }");
var dbg = new Debugger(g);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var log;
// Set a breakpoint at the start of g.f
var gf = dbg.addDebuggee(g.f); // addDebuggee used as Debugger.Object factory
var gf = gw.makeDebuggeeValue(g.f);
var fStartOffset = gf.script.getLineOffsets(gf.script.startLine)[0];
gf.script.setBreakpoint(fStartOffset, {
hit: function handleHit(frame) {

View File

@ -5,7 +5,8 @@ var obj = g.eval("({x: 1})");
assertEq(g.Object.isExtensible(obj), true);
var dbg = new Debugger;
var objw = dbg.addDebuggee(obj);
var gw = dbg.addDebuggee(g);
var objw = gw.makeDebuggeeValue(obj);
assertEq(objw.isExtensible(), true);
assertEq(objw.preventExtensions(), undefined);

View File

@ -13,7 +13,8 @@ var g = newGlobal('new-compartment');
g.eval("function f(frame) { n++; return 42; }");
g.n = 0;
var dbg = Debugger(g);
var dbg = Debugger();
var gw = dbg.addDebuggee(g);
// Register the debuggee function as the onEnterFrame handler. When we first
// call or eval in the debuggee:
@ -36,7 +37,7 @@ var dbg = Debugger(g);
dbg.onEnterFrame = g.f;
// Get a Debugger.Object instance referring to f.
var debuggeeF = dbg.addDebuggee(g.f);
var debuggeeF = gw.makeDebuggeeValue(g.f);
// Using f.call allows us to catch the termination.
assertEq(debuggeeF.call(), null);