diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 45eb0ffa95c9..42a4a4ddc3d8 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -2410,35 +2410,16 @@ XrayWrapper::getPrototype(JSContext* cx, JS::HandleObject wrapper, // only if there's been a set. If there's not an expando, or the expando // slot is |undefined|, hand back the default proto, appropriately wrapped. + RootedValue v(cx); if (expando) { - RootedValue v(cx); - { // Scope for JSAutoCompartment - JSAutoCompartment ac(cx, expando); - v = JS_GetReservedSlot(expando, JSSLOT_EXPANDO_PROTOTYPE); - } - if (!v.isUndefined()) { - protop.set(v.toObjectOrNull()); - return JS_WrapObject(cx, protop); - } + JSAutoCompartment ac(cx, expando); + v = JS_GetReservedSlot(expando, JSSLOT_EXPANDO_PROTOTYPE); } + if (v.isUndefined()) + return getPrototypeHelper(cx, wrapper, target, protop); - // Check our holder, and cache there if we don't have it cached already. - RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper)); - if (!holder) - return false; - - Value cached = js::GetReservedSlot(holder, - Traits::HOLDER_SLOT_CACHED_PROTO); - if (cached.isUndefined()) { - if (!getPrototypeHelper(cx, wrapper, target, protop)) - return false; - - js::SetReservedSlot(holder, Traits::HOLDER_SLOT_CACHED_PROTO, - ObjectOrNullValue(protop)); - } else { - protop.set(cached.toObjectOrNull()); - } - return true; + protop.set(v.toObjectOrNull()); + return JS_WrapObject(cx, protop); } template