Bug 1166351 - Add an assertion to make sure that we use the correct cached XBL binding prototypes. r=bobbyholley+313730

MozReview-Commit-ID: 7MfslXmortQ

--HG--
extra : rebase_source : 478d19031d5820acf2eeb077d689159769318b2a
This commit is contained in:
Mike Conley 2016-04-29 14:54:12 -04:00
parent 0abb0a4c79
commit 4e5e8f7b73

View File

@ -957,6 +957,15 @@ GetOrCreateMapEntryForPrototype(JSContext *cx, JS::Handle<JSObject*> proto)
return entry;
}
static
nsXBLPrototypeBinding*
GetProtoBindingFromClassObject(JSObject* obj)
{
MOZ_ASSERT(JS_GetClass(obj) == &gPrototypeJSClass);
return static_cast<nsXBLPrototypeBinding*>(::JS_GetReservedSlot(obj, 0).toPrivate());
}
// static
nsresult
nsXBLBinding::DoInitJSClass(JSContext *cx,
@ -1012,7 +1021,9 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
*aNew = !desc.object();
if (desc.object()) {
proto = &desc.value().toObject();
MOZ_ASSERT(JS_GetClass(js::UncheckedUnwrap(proto)) == &gPrototypeJSClass);
DebugOnly<nsXBLPrototypeBinding*> cachedBinding =
GetProtoBindingFromClassObject(js::UncheckedUnwrap(proto));
MOZ_ASSERT(cachedBinding == aProtoBinding);
} else {
// We need to create the prototype. First, enter the compartment where it's