Fix non-debug-mode assertion in addDebuggee.
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 23 May 2011 16:47:27 -0500
changeset 74441 b46785b17311b579f7f7acd9a97835b4bff3b2f3
parent 74440 0c0dfc86796d2ea947f1caa8905fe0462deb0cd0
child 74442 f99cf5ced5aa950e22b26de5a5452c8366a1c4ec
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Fix non-debug-mode assertion in addDebuggee.
js/src/jsdbg.cpp
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -867,34 +867,27 @@ Debug::getYoungestFrame(JSContext *cx, u
         return true;
     }
     return dbg->getScriptFrame(cx, fp, vp);
 }
 
 JSBool
 Debug::construct(JSContext *cx, uintN argc, Value *vp)
 {
-    // Check arguments.
+    // Check that the arguments, if any, are cross-compartment wrappers.
     Value *argv = vp + 2, *argvEnd = argv + argc;
     for (Value *p = argv; p != argvEnd; p++) {
-        // Check that the argument is a cross-compartment wrapper.
         const Value &arg = *p;
         if (!arg.isObject())
             return ReportObjectRequired(cx);
         JSObject *argobj = &arg.toObject();
         if (!argobj->isCrossCompartmentWrapper()) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CCW_REQUIRED, "Debug");
             return false;
         }
-
-        // Check that the target compartment is in debug mode.
-        if (!argobj->getProxyPrivate().toObject().compartment()->debugMode) {
-            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NEED_DEBUG_MODE);
-            return false;
-        }
     }
 
     // Get Debug.prototype.
     Value v;
     jsid prototypeId = ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom);
     if (!vp[0].toObject().getProperty(cx, prototypeId, &v))
         return false;
     JSObject *proto = &v.toObject();
@@ -930,16 +923,21 @@ Debug::construct(JSContext *cx, uintN ar
 
     vp->setObject(*obj);
     return true;
 }
 
 bool
 Debug::addDebuggeeGlobal(JSContext *cx, GlobalObject *obj)
 {
+    if (!obj->compartment()->debugMode) {
+        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NEED_DEBUG_MODE);
+        return false;
+    }
+
     // Check for cycles. If obj's compartment is reachable from this Debug
     // object's compartment by following debuggee-to-debugger links, then
     // adding obj would create a cycle. (Typically nobody is debugging the
     // debugger, in which case we zip through this code without looping.)
     Vector<JSCompartment *> visited(cx);
     if (!visited.append(object->compartment()))
         return false;
     JSCompartment *dest = obj->compartment();