diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 6b9eeece2ee..17a563018bb 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -145,16 +145,23 @@ JSCompartment::wrap(JSContext *cx, Value *vp) /* Don't unwrap an outer window proxy. */ if (!obj->getClass()->ext.innerObject) { obj = vp->toObject().unwrap(&flags); - OBJ_TO_OUTER_OBJECT(cx, obj); - if (!obj) - return false; vp->setObject(*obj); + + /* If the wrapped object is already in this compartment, we are done. */ + if (obj->getCompartment() == this) + return true; + } else { + JS_ASSERT(!obj->isWrapper() || obj->getClass()->ext.innerObject); + vp->setObject(*obj); } - /* If the wrapped object is already in this compartment, we are done. */ - if (obj->compartment() == this) - return true; + OBJ_TO_OUTER_OBJECT(cx, obj); + if (!obj) + return false; + + JS_ASSERT(obj->getCompartment() == vp->toObject().getCompartment()); + vp->setObject(*obj); } /* If we already have a wrapper for this value, use it. */ @@ -217,14 +224,6 @@ JSCompartment::wrap(JSContext *cx, Value *vp) vp->setObject(*wrapper); - /* - * If the returned "wrapper" is not a proxy, then we were attempting to - * wrap an XPConnect "holder" object and the actual wrapped object was - * in our compartment. - */ - if (!wrapper->isProxy()) - return true; - wrapper->setProto(proto); if (!crossCompartmentWrappers.put(wrapper->getProxyPrivate(), *vp)) return false; diff --git a/js/src/xpconnect/wrappers/WrapperFactory.cpp b/js/src/xpconnect/wrappers/WrapperFactory.cpp index 7eac89ddfa8..5005ce4f8c6 100644 --- a/js/src/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/src/xpconnect/wrappers/WrapperFactory.cpp @@ -76,10 +76,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj)) return nsnull; - OBJ_TO_OUTER_OBJECT(cx, obj); - if (!obj) - return nsnull; - JSCompartment *origin = obj->getCompartment(); JSCompartment *target = cx->compartment; JSObject *xrayHolder = nsnull;