bug 580128 - Outerize in JS instead of in the rewrap hook so the identity in the wrapper map stays constant. r=gal

This commit is contained in:
Blake Kaplan 2010-09-28 17:02:43 -07:00
Родитель d4dbc19ff6
Коммит 20e65225e2
2 изменённых файлов: 13 добавлений и 18 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;