Bug 1450688. r=bz, a=RyanVM
MozReview-Commit-ID: 4KHNpxiziWd
--- a/dom/xbl/nsXBLBinding.cpp
+++ b/dom/xbl/nsXBLBinding.cpp
@@ -970,17 +970,27 @@ nsXBLBinding::DoInitJSClass(JSContext *c
// prototype are same-compartment with the bound document.
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
// We never store class objects in add-on scopes.
JS::Rooted<JSObject*> xblScope(cx, xpc::GetXBLScopeOrGlobal(cx, global));
NS_ENSURE_TRUE(xblScope, NS_ERROR_UNEXPECTED);
JS::Rooted<JSObject*> parent_proto(cx);
- if (!JS_GetPrototype(cx, obj, &parent_proto)) {
+ {
+ JS::RootedObject wrapped(cx, obj);
+ JSAutoCompartment ac(cx, xblScope);
+ if (!JS_WrapObject(cx, &wrapped)) {
+ return NS_ERROR_FAILURE;
+ }
+ if (!JS_GetPrototype(cx, wrapped, &parent_proto)) {
+ return NS_ERROR_FAILURE;
+ }
+ }
+ if (!JS_WrapObject(cx, &parent_proto)) {
return NS_ERROR_FAILURE;
}
// Get the map entry for the parent prototype. In the one-off case that the
// parent prototype is null, we somewhat hackily just use the WeakMap itself
// as a property holder.
JS::Rooted<JSObject*> holder(cx);
if (parent_proto) {