Bug 1757846 - Treat BackstagePass as Window when checking for unexposed globals r=nika

Differential Revision: https://phabricator.services.mozilla.com/D140124
This commit is contained in:
Barret Rennie
2022-03-09 20:55:36 +00:00
parent 5e1ff2c5f0
commit eef359867c
3 changed files with 19 additions and 25 deletions

View File

@@ -2825,25 +2825,20 @@ bool EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj,
bool IsNonExposedGlobal(JSContext* aCx, JSObject* aGlobal,
uint32_t aNonExposedGlobals) {
MOZ_ASSERT(aNonExposedGlobals, "Why did we get called?");
MOZ_ASSERT(
(aNonExposedGlobals & ~(GlobalNames::Window | GlobalNames::BackstagePass |
GlobalNames::DedicatedWorkerGlobalScope |
GlobalNames::SharedWorkerGlobalScope |
GlobalNames::ServiceWorkerGlobalScope |
GlobalNames::WorkerDebuggerGlobalScope |
GlobalNames::WorkletGlobalScope |
GlobalNames::AudioWorkletGlobalScope |
GlobalNames::PaintWorkletGlobalScope)) == 0,
"Unknown non-exposed global type");
MOZ_ASSERT((aNonExposedGlobals &
~(GlobalNames::Window | GlobalNames::DedicatedWorkerGlobalScope |
GlobalNames::SharedWorkerGlobalScope |
GlobalNames::ServiceWorkerGlobalScope |
GlobalNames::WorkerDebuggerGlobalScope |
GlobalNames::WorkletGlobalScope |
GlobalNames::AudioWorkletGlobalScope |
GlobalNames::PaintWorkletGlobalScope)) == 0,
"Unknown non-exposed global type");
const char* name = JS::GetClass(aGlobal)->name;
if ((aNonExposedGlobals & GlobalNames::Window) && !strcmp(name, "Window")) {
return true;
}
if ((aNonExposedGlobals & GlobalNames::BackstagePass) &&
!strcmp(name, "BackstagePass")) {
if ((aNonExposedGlobals & GlobalNames::Window) &&
(!strcmp(name, "Window") || !strcmp(name, "BackstagePass"))) {
return true;
}

View File

@@ -106,14 +106,13 @@ namespace GlobalNames {
// interfaces, not of the global names used to refer to them in IDL [Exposed]
// annotations.
static const uint32_t Window = 1u << 0;
static const uint32_t BackstagePass = 1u << 1;
static const uint32_t DedicatedWorkerGlobalScope = 1u << 2;
static const uint32_t SharedWorkerGlobalScope = 1u << 3;
static const uint32_t ServiceWorkerGlobalScope = 1u << 4;
static const uint32_t WorkerDebuggerGlobalScope = 1u << 5;
static const uint32_t WorkletGlobalScope = 1u << 6;
static const uint32_t AudioWorkletGlobalScope = 1u << 7;
static const uint32_t PaintWorkletGlobalScope = 1u << 8;
static const uint32_t DedicatedWorkerGlobalScope = 1u << 1;
static const uint32_t SharedWorkerGlobalScope = 1u << 2;
static const uint32_t ServiceWorkerGlobalScope = 1u << 3;
static const uint32_t WorkerDebuggerGlobalScope = 1u << 4;
static const uint32_t WorkletGlobalScope = 1u << 5;
static const uint32_t AudioWorkletGlobalScope = 1u << 6;
static const uint32_t PaintWorkletGlobalScope = 1u << 7;
} // namespace GlobalNames
struct PrefableDisablers {

View File

@@ -612,7 +612,7 @@ bool IndexedDatabaseManager::ExperimentalFeaturesEnabled(JSContext* aCx,
// actually going through IndexedDatabaseManager.
// See Bug 1198093 comment 14 for detailed explanation.
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
if (IsNonExposedGlobal(aCx, aGlobal, GlobalNames::BackstagePass)) {
if (!strcmp(JS::GetClass(aGlobal)->name, "BackstagePass")) {
MOZ_ASSERT(NS_IsMainThread());
static bool featureRetrieved = false;
if (!featureRetrieved) {