From ffb3a9b8811ec9bb5e442a07ac3918cbf06feb22 Mon Sep 17 00:00:00 2001 From: Rob Campbell Date: Fri, 24 Jul 2009 10:20:34 -0300 Subject: [PATCH] bug 474358 - ASSERTION: Inner window detected in Equality hook, isOuterWindow, p=me, r=timeless, sr=mrbkap --- js/jsd/jsd_val.c | 31 ++++++++++++++++++++++++++++++- js/src/jsobj.h | 5 +++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/js/jsd/jsd_val.c b/js/jsd/jsd_val.c index 1619de63c15b..65ceeae6adb0 100644 --- a/js/jsd/jsd_val.c +++ b/js/jsd/jsd_val.c @@ -40,6 +40,19 @@ */ #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) @@ -294,7 +307,23 @@ jsd_DropValue(JSDContext* jsdc, JSDValue* 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, diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 35044eab37c7..f713da3a651f 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -141,6 +141,11 @@ struct JSObjectMap { } \ 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); \