bug 474358 - ASSERTION: Inner window detected in Equality hook, isOuterWindow, p=me, r=timeless, sr=mrbkap
bug 474358 - ASSERTION: Inner window detected in Equality hook, isOuterWindow, p=me, r=timeless, sr=mrbkap
--- 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); \
} \