Implement Debug.Frame.prototype.constructing accessor.
authorJim Blandy <jimb@mozilla.com>
Thu, 19 May 2011 11:28:28 -0700
changeset 74429 be12caeb033ae18a50ab90393e80e3eb25d29c96
parent 74428 aaec89b3971836d24f133a4073d9b690958584d5
child 74430 4ab2a31a2b9d4edeb0017413630127744130699f
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Implement Debug.Frame.prototype.constructing accessor.
js/src/jit-test/tests/debug/Frame-01.js
js/src/jsdbg.cpp
--- a/js/src/jit-test/tests/debug/Frame-01.js
+++ b/js/src/jit-test/tests/debug/Frame-01.js
@@ -3,49 +3,68 @@
 
 var g = newGlobal('new-compartment');
 g.debuggeeGlobal = this;
 g.eval("var hits;");
 g.eval("(" + function () {
         var dbg = Debug(debuggeeGlobal);
         dbg.hooks = {
             debuggerHandler: function (f) {
+                // print(uneval(expected));
                 assertEq(Object.getPrototypeOf(f), Debug.Frame.prototype);
-                assertEq(f.type, ftype);
-                assertEq(f.generator, fgen);
+                assertEq(f.type, expected.type);
+                assertEq(f.generator, expected.generator);
+                assertEq(f.constructing, expected.constructing);
                 hits++;
             }
         };
     } + ")()");
 
-g.ftype = "global";
-g.fgen = false;
+g.expected = { type:"global", generator:false, constructing:false };
 g.hits = 0;
 debugger;
 assertEq(g.hits, 1);
 
-g.ftype = "call";
+g.expected = { type:"call", generator:false, constructing:false };
 g.hits = 0;
 (function () { debugger; })();
 assertEq(g.hits, 1);
 
-g.ftype = "eval";
+g.expected = { type:"call", generator:false, constructing:true };
+g.hits = 0;
+new function() { debugger; };
+assertEq(g.hits, 1);
+
+g.expected = { type:"call", generator:false, constructing:false };
+g.hits = 0;
+new function () {
+    (function() { debugger; })();
+    assertEq(g.hits, 1);
+}
+
+g.expected = { type:"eval", generator:false, constructing:false };
 g.hits = 0;
 eval("debugger;");
 assertEq(g.hits, 1);
 
-g.ftype = "eval";
+g.expected = { type:"eval", generator:false, constructing:false };
 g.hits = 0;
 this.eval("debugger;");  // indirect eval
 assertEq(g.hits, 1);
 
-g.ftype = "eval";
+g.expected = { type:"eval", generator:false, constructing:false };
 g.hits = 0;
 (function () { eval("debugger;"); })();
 assertEq(g.hits, 1);
 
-g.ftype = "call";
-g.fgen = true;
+g.expected = { type:"eval", generator:false, constructing:false };
+g.hits = 0;
+new function () {
+    eval("debugger");
+    assertEq(g.hits, 1);
+}
+
+g.expected = { type:"call", generator:true, constructing:false };
 g.hits = 0;
 function gen() { debugger; yield 1; debugger; }
 for (var x in gen()) {
 }
 assertEq(g.hits, 2);
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -846,16 +846,24 @@ static JSBool
 DebugFrame_getGenerator(JSContext *cx, uintN argc, Value *vp)
 {
     THIS_FRAME(cx, vp, "get generator", thisobj, fp);
     vp->setBoolean(fp->isGeneratorFrame());
     return true;
 }
 
 static JSBool
+DebugFrame_getConstructing(JSContext *cx, uintN argc, Value *vp)
+{
+    THIS_FRAME(cx, vp, "get constructing", thisobj, fp);
+    vp->setBoolean(fp->isFunctionFrame() && fp->isConstructing());
+    return true;
+}
+
+static JSBool
 DebugFrame_getThis(JSContext *cx, uintN argc, Value *vp)
 {
     THIS_FRAME(cx, vp, "get this", thisobj, fp);
     {
         AutoCompartment ac(cx, &fp->scopeChain());
         if (!ac.enter())
             return false;
         if (!ComputeThis(cx, fp))
@@ -933,16 +941,17 @@ DebugFrame_construct(JSContext *cx, uint
 
 static JSPropertySpec DebugFrame_properties[] = {
     JS_PSG("type", DebugFrame_getType, 0),
     JS_PSG("this", DebugFrame_getThis, 0),
     JS_PSG("older", DebugFrame_getOlder, 0),
     JS_PSG("live", DebugFrame_getLive, 0),
     JS_PSG("callee", DebugFrame_getCallee, 0),
     JS_PSG("generator", DebugFrame_getGenerator, 0),
+    JS_PSG("constructing", DebugFrame_getConstructing, 0),
     JS_PSG("arguments", DebugFrame_getArguments, 0),
     JS_PS_END
 };
 
 static JSFunctionSpec DebugFrame_methods[] = {
     JS_FN("eval", DebugFrame_eval, 1, 0),
     JS_FS_END
 };