Bug 902718 - Add a mechanism to assert that the stack-top cx is an XBL compilation scope. r=bz

This commit is contained in:
Bobby Holley 2013-08-09 09:25:12 -07:00
parent 3f88a39464
commit cde56ff019
2 changed files with 18 additions and 1 deletions

View File

@ -78,6 +78,8 @@ public:
void UnmarkScriptContext();
static JSClass gSharedGlobalClass;
protected:
virtual ~nsXBLDocGlobalObject();
@ -87,7 +89,6 @@ protected:
JSObject *mJSObject;
nsXBLDocumentInfo* mGlobalObjectOwner; // weak reference
static JSClass gSharedGlobalClass;
};
bool
@ -713,3 +714,13 @@ nsXBLDocumentInfo::GetScriptGlobalObject()
return mGlobalObject;
}
#ifdef DEBUG
void
AssertInCompilationScope()
{
AutoJSContext cx;
MOZ_ASSERT(JS_GetClass(JS::CurrentGlobalOrNull(cx)) ==
&nsXBLDocGlobalObject::gSharedGlobalClass);
}
#endif

View File

@ -70,4 +70,10 @@ private:
nsRefPtr<nsXBLDocGlobalObject> mGlobalObject;
};
#ifdef DEBUG
void AssertInCompilationScope();
#else
inline void AssertInCompilationScope() {}
#endif
#endif