Bug 1547923 part 4. Add nsIGlobalObject::HasJSGlobal(). r=mccr8

Consumers that just care about this boolean state should use this instead of
getting the JSObject* directly.

Differential Revision: https://phabricator.services.mozilla.com/D29705
This commit is contained in:
Boris Zbarsky
2019-05-02 21:32:17 +00:00
parent bb465af5c0
commit bc3d6e1282
9 changed files with 28 additions and 21 deletions

View File

@@ -131,7 +131,7 @@ ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject* aGlobal,
Type aType)
: mGlobalObject(aGlobal), mType(aType), mOlder(nullptr) {
MOZ_ASSERT_IF(IsIncumbentCandidate() && !NoJSAPI(), mGlobalObject);
MOZ_ASSERT(!mGlobalObject || mGlobalObject->GetGlobalJSObject(),
MOZ_ASSERT(!mGlobalObject || mGlobalObject->HasJSGlobal(),
"Must have an actual JS global for the duration on the stack");
MOZ_ASSERT(
!mGlobalObject || JS_IsGlobalObject(mGlobalObject->GetGlobalJSObject()),
@@ -140,7 +140,7 @@ ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject* aGlobal,
ScriptSettingsStackEntry::~ScriptSettingsStackEntry() {
// We must have an actual JS global for the entire time this is on the stack.
MOZ_ASSERT_IF(mGlobalObject, mGlobalObject->GetGlobalJSObject());
MOZ_ASSERT_IF(mGlobalObject, mGlobalObject->HasJSGlobal());
}
// If the entry or incumbent global ends up being something that the subject
@@ -383,7 +383,7 @@ AutoJSAPI::AutoJSAPI(nsIGlobalObject* aGlobalObject, bool aIsMainThread,
: ScriptSettingsStackEntry(aGlobalObject, aType),
mIsMainThread(aIsMainThread) {
MOZ_ASSERT(aGlobalObject);
MOZ_ASSERT(aGlobalObject->GetGlobalJSObject(), "Must have a JS global");
MOZ_ASSERT(aGlobalObject->HasJSGlobal(), "Must have a JS global");
MOZ_ASSERT(aIsMainThread == NS_IsMainThread());
InitInternal(aGlobalObject, aGlobalObject->GetGlobalJSObject(),