diff --git a/js/xpconnect/wrappers/AddonWrapper.cpp b/js/xpconnect/wrappers/AddonWrapper.cpp index 6d125905c1d5..d18753516e1a 100644 --- a/js/xpconnect/wrappers/AddonWrapper.cpp +++ b/js/xpconnect/wrappers/AddonWrapper.cpp @@ -38,20 +38,36 @@ ReportASCIIErrorWithId(JSContext* cx, const char* msg, HandleId id) JS_ReportErrorUTF8(cx, msg, bytes.ptr()); } +bool +RequiresInterpositions(JSContext* cx, HandleObject unwrapped) +{ + Rooted desc(cx); + JSAutoCompartment ac(cx, unwrapped); + + if (!JS_GetOwnPropertyDescriptor(cx, unwrapped, "requiresAddonInterpositions", &desc)) { + JS_ClearPendingException(cx); + return false; + } + + return desc.hasValue() && desc.value().isTrue(); +} + bool InterposeProperty(JSContext* cx, HandleObject target, const nsIID* iid, HandleId id, MutableHandle descriptor) { - // We only want to do interpostion on DOM instances and - // wrapped natives. + // We only want to do interpostion on DOM instances, + // wrapped natives, or if the object explicitly requests it. RootedObject unwrapped(cx, UncheckedUnwrap(target)); const js::Class* clasp = js::GetObjectClass(unwrapped); bool isCPOW = jsipc::IsWrappedCPOW(unwrapped); + if (!mozilla::dom::IsDOMClass(clasp) && !IS_WN_CLASS(clasp) && !IS_PROTO_CLASS(clasp) && clasp != &OuterWindowProxyClass && - !isCPOW) { + !isCPOW && + !RequiresInterpositions(cx, unwrapped)) { return true; }