Bug 796073: Use Debugger.Object.prototype.makeDebuggeeValue where appropriate, not Debugger.prototype.addDebuggee. r=luke
authorJim Blandy <jimb@mozilla.com>
Sat, 13 Oct 2012 16:04:41 -0700
changeset 110335 567352805e77069675ac063ae2ff38ad2e3a9499
parent 110334 f67e5b827cdf0817f8721cbdc05c14210f6d2e21
child 110336 19abbe2af7cfe9cab121785c975c8996750c107d
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersluke
bugs796073
milestone19.0a1
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.
js/src/jit-test/tests/debug/Debugger-findScripts-02.js
js/src/jit-test/tests/debug/Debugger-findScripts-05.js
js/src/jit-test/tests/debug/Debugger-findScripts-06.js
js/src/jit-test/tests/debug/Debugger-findScripts-07.js
js/src/jit-test/tests/debug/Debugger-findScripts-08.js
js/src/jit-test/tests/debug/Debugger-findScripts-11.js
js/src/jit-test/tests/debug/Debugger-findScripts-12.js
js/src/jit-test/tests/debug/Debugger-findScripts-14.js
js/src/jit-test/tests/debug/Frame-onPop-11.js
js/src/jit-test/tests/debug/Object-preventExtensions-01.js
js/src/jit-test/tests/debug/onEnterFrame-04.js
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-02.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-02.js
@@ -1,15 +1,16 @@
 // In a debuggee with functions, findScripts finds those functions' scripts.
 
 var g = newGlobal('new-compartment');
 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);
 assertEq(dbg.findScripts().indexOf(hw.script) != -1, true);
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-05.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-05.js
@@ -1,17 +1,18 @@
 // 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);
 
 var scripts = dbg.findScripts();
 assertEq(scripts.indexOf(fw.script) != -1, true);
 assertEq(scripts.indexOf(gw.script) != -1, true);
 assertEq(scripts.indexOf(hw.script) != -1, true);
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-06.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-06.js
@@ -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);
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-07.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-07.js
@@ -1,20 +1,22 @@
 // findScripts can filter scripts by global.
 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;
 
 scripts = dbg.findScripts({});
 assertEq(scripts.indexOf(g1fw.script) != -1, true);
 assertEq(scripts.indexOf(g2gw.script) != -1, true);
 
 scripts = dbg.findScripts({global: g1});
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-08.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-08.js
@@ -6,22 +6,25 @@ var g3 = newGlobal('new-compartment');
 // Define some functions whose url will be this test file.
 g1.eval('function g1f() {}');
 g2.eval('function g2f() {}');
 
 // Define some functions whose url will be a different file.
 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;
 
 var scripts;
 
 scripts = dbg.findScripts({});
 assertEq(scripts.indexOf(g1fw.script) != -1, true);
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-11.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-11.js
@@ -1,18 +1,19 @@
 // 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);
 assertEq(dbg.findScripts({url:scriptname, line:3}).indexOf(ggw.script) != -1, false);
 assertEq(dbg.findScripts({url:scriptname, line:3}).indexOf(ghw.script) != -1, false);
 
 // Specifying a different url screens out scripts, even when global and line match.
 assertEq(dbg.findScripts({url:"xlerb", line:8}).indexOf(gfw.script) != -1, false);
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-12.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-12.js
@@ -13,17 +13,18 @@ var g2 = newGlobal('new-compartment');
 g2.toSource = function () "[global g2]";
 g2.load(url1);
 g2.load(url2);
 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;
 }
 
 // The function scripts we know of. There may be random eval scripts involved, but
 // we don't care about those.
 var allScripts = ([g1.f, g1.f(), g1.g, g1.h, g1.h(), g1.i,
--- a/js/src/jit-test/tests/debug/Debugger-findScripts-14.js
+++ b/js/src/jit-test/tests/debug/Debugger-findScripts-14.js
@@ -1,15 +1,16 @@
 // 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) {
     return array.length == 1 && array[0] === element;
 }
 
 url = scriptdir + 'Debugger-findScripts-14.script1';
 g.load(url);
--- a/js/src/jit-test/tests/debug/Frame-onPop-11.js
+++ b/js/src/jit-test/tests/debug/Frame-onPop-11.js
@@ -1,16 +1,17 @@
 // 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) {
         log += 'b';
         frame.onPop = function handlePop(c) {
             log += ')';
             assertEq(c.return, "to normalcy");
         };
--- a/js/src/jit-test/tests/debug/Object-preventExtensions-01.js
+++ b/js/src/jit-test/tests/debug/Object-preventExtensions-01.js
@@ -1,16 +1,17 @@
 // Basic preventExtensions test.
 
 var g = newGlobal('new-compartment');
 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);
 assertEq(g.Object.isExtensible(obj), false);
 assertEq(objw.isExtensible(), false);
 
 // Calling preventExtensions again has no effect.
 assertEq(objw.preventExtensions(), undefined);
--- a/js/src/jit-test/tests/debug/onEnterFrame-04.js
+++ b/js/src/jit-test/tests/debug/onEnterFrame-04.js
@@ -8,40 +8,41 @@
 // for at least detecting the recursion.
 
 load(libdir + 'asserts.js');
 
 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:
 //
 // - The onEnterFrame call reporting that frame's creation is itself an event
 //   that must be reported, so we call onEnterFrame again.
-// 
+//
 // - SpiderMonkey detects the out-of-control recursion, and generates a "too
 //   much recursion" InternalError in the youngest onEnterFrame call.
 //
 // - We don't catch it, so the onEnterFrame handler call itself throws.
 //
 // - Since the Debugger doesn't have an uncaughtExceptionHook (it can't; such a
 //   hook would itself raise a "too much recursion" exception), Spidermonkey
 //   reports the exception immediately and terminates the debuggee --- which is
 //   the next-older onEnterFrame call.
 //
 // - This termination propagates all the way out to the initial attempt to
 //   create a frame in the debuggee.
 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);
 
 // We should never actually begin execution of the function.
 assertEq(g.n, 0);
 
 // When an error is reported, the shell usually exits with a nonzero exit code.