Bug 831076 - Add assertSameCompartment to JS_ObjectToOuterObject, and clean up classinfo hook. r=mrbkap

This commit is contained in:
Bobby Holley 2013-02-04 15:13:14 +00:00
parent e03bc92cec
commit 7f9ead0fc2
2 changed files with 6 additions and 5 deletions

View File

@ -6742,12 +6742,12 @@ nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
}
JSObject *winObj = win->FastGetGlobalJSObject();
if (!winObj) {
NS_ASSERTION(origWin->IsOuterWindow(), "What window is this?");
*_retval = obj;
return NS_OK;
}
MOZ_ASSERT(winObj);
// Note that while |wrapper| is same-compartment with cx, the outer window
// might not be. If we're running script in an inactive scope and evalute
// |this|, the outer window is actually a cross-compartment wrapper. So we
// need to wrap here.
if (!JS_WrapObject(cx, &winObj)) {
*_retval = nullptr;
return NS_ERROR_UNEXPECTED;

View File

@ -105,6 +105,7 @@ JS_FRIEND_API(JSObject *)
JS_ObjectToOuterObject(JSContext *cx, JSObject *obj_)
{
Rooted<JSObject*> obj(cx, obj_);
assertSameCompartment(cx, obj);
return GetOuterObject(cx, obj);
}