Unwrap before applying waiver wrapper (bug 626290, r=mrbkap).

This commit is contained in:
Andreas Gal 2011-01-20 14:41:30 -08:00
Родитель 8b072669f5
Коммит 514649def9
1 изменённых файлов: 7 добавлений и 2 удалений

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

@ -83,6 +83,8 @@ GetCurrentOuter(JSContext *cx, JSObject *obj)
JSObject * JSObject *
WrapperFactory::WaiveXray(JSContext *cx, JSObject *obj) WrapperFactory::WaiveXray(JSContext *cx, JSObject *obj)
{ {
obj = obj->unwrap();
// We have to make sure that if we're wrapping an outer window, that // We have to make sure that if we're wrapping an outer window, that
// the .wrappedJSObject also wraps the outer window. // the .wrappedJSObject also wraps the outer window.
obj = GetCurrentOuter(cx, obj); obj = GetCurrentOuter(cx, obj);
@ -130,7 +132,10 @@ JSObject *
WrapperFactory::DoubleWrap(JSContext *cx, JSObject *obj, uintN flags) WrapperFactory::DoubleWrap(JSContext *cx, JSObject *obj, uintN flags)
{ {
if (flags & WrapperFactory::WAIVE_XRAY_WRAPPER_FLAG) { if (flags & WrapperFactory::WAIVE_XRAY_WRAPPER_FLAG) {
js::SwitchToCompartment sc(cx, obj->compartment()); JSAutoEnterCompartment ac;
if (!ac.enter(cx, obj))
return nsnull;
return WaiveXray(cx, obj); return WaiveXray(cx, obj);
} }
return obj; return obj;
@ -347,7 +352,7 @@ WrapperFactory::WaiveXrayAndWrap(JSContext *cx, jsval *vp)
if (JSVAL_IS_PRIMITIVE(*vp)) if (JSVAL_IS_PRIMITIVE(*vp))
return JS_WrapValue(cx, vp); return JS_WrapValue(cx, vp);
JSObject *obj = JSVAL_TO_OBJECT(*vp)->unwrap(); JSObject *obj = JSVAL_TO_OBJECT(*vp);
obj = WaiveXray(cx, obj); obj = WaiveXray(cx, obj);
if (!obj) if (!obj)