bug 474358 - ASSERTION: Inner window detected in Equality hook, isOuterWindow, p=me, r=timeless, sr=mrbkap
authorRob Campbell <rcampbell@mozilla.com>
Fri, 24 Jul 2009 10:20:34 -0300
changeset 30637 488f1d1a9108d7d71e3581ce778f748109935a7b
parent 30636 410eb23d33c757b2c9d47286e95f8e866508bee0
child 30638 54adfdd9e5a74f0b1cc65067c11a7c117fe2ad05
push idunknown
push userunknown
push dateunknown
reviewerstimeless, mrbkap
bugs474358
milestone1.9.2a1pre
bug 474358 - ASSERTION: Inner window detected in Equality hook, isOuterWindow, p=me, r=timeless, sr=mrbkap
js/jsd/jsd_val.c
js/src/jsobj.h
--- a/js/jsd/jsd_val.c
+++ b/js/jsd/jsd_val.c
@@ -35,16 +35,29 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * JavaScript Debugging support - Value and Property support
  */
 
 #include "jsd.h"
+#include "jsapi.h"
+
+/*
+ * Lifted with slight modification from jsobj.h
+ */
+
+#define OBJ_TO_OUTER_OBJECT(cx, obj)                                \
+    JSClass *clasp_ = JS_GetClass(cx, obj);                         \
+    if (clasp_->flags & JSCLASS_IS_EXTENDED) {                      \
+        JSExtendedClass *xclasp_ = (JSExtendedClass*) clasp_;       \
+        if (xclasp_->outerObject)                                   \
+            obj = xclasp_->outerObject(cx, obj);                    \
+    }
 
 #ifdef DEBUG
 void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
 {
     JS_ASSERT(jsdval);
     JS_ASSERT(jsdval->nref > 0);
     if(!JS_CLIST_IS_EMPTY(&jsdval->props))
     {
@@ -289,17 +302,33 @@ jsd_DropValue(JSDContext* jsdc, JSDValue
         }
         free(jsdval);
     }
 }
 
 jsval
 jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval)
 {
-    return jsdval->val;
+    JSObject* obj;
+    JSContext* cx;
+    jsval val = jsdval->val;
+    if (!JSVAL_IS_PRIMITIVE(val)) {
+        cx = JSD_GetDefaultJSContext(jsdc);
+        obj = JSVAL_TO_OBJECT(val);
+        OBJ_TO_OUTER_OBJECT(cx, obj);
+        if (!obj)
+        {
+            JS_ClearPendingException(cx);
+            val = JSVAL_NULL;
+        }
+        else
+            val = OBJECT_TO_JSVAL(obj);
+    }
+    
+    return val;
 }
 
 static JSDProperty* _newProperty(JSDContext* jsdc, JSPropertyDesc* pd,
                                  uintN additionalFlags)
 {
     JSDProperty* jsdprop;
 
     if(!(jsdprop = (JSDProperty*) calloc(1, sizeof(JSDProperty))))
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -136,16 +136,21 @@ struct JSObjectMap {
         JSClass *clasp_ = OBJ_GET_CLASS(cx, obj);                             \
         if (clasp_->flags & JSCLASS_IS_EXTENDED) {                            \
             JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_;              \
             if (xclasp_->innerObject)                                         \
                 obj = xclasp_->innerObject(cx, obj);                          \
         }                                                                     \
     JS_END_MACRO
 
+/*
+ * The following macro has been copied to jsd/jsd_val.c. If making changes to
+ * OBJ_TO_OUTER_OBJECT, please update jsd/jsd_val.c as well.
+ */
+
 #define OBJ_TO_OUTER_OBJECT(cx,obj)                                           \
     JS_BEGIN_MACRO                                                            \
         JSClass *clasp_ = OBJ_GET_CLASS(cx, obj);                             \
         if (clasp_->flags & JSCLASS_IS_EXTENDED) {                            \
             JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_;              \
             if (xclasp_->outerObject)                                         \
                 obj = xclasp_->outerObject(cx, obj);                          \
         }                                                                     \