/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
static nsIGlobalObject* FindEnclosingNonShadowRealmGlobal(
ShadowRealmGlobalScope* scope) {
nsCOMPtr<nsIGlobalObject> global = scope->GetCreatingGlobal();
do {
nsCOMPtr<ShadowRealmGlobalScope> shadowRealmGlobalScope =
do_QueryInterface(global); if (!shadowRealmGlobalScope) { break;
}
// Our global was a ShadowRealmGlobal; that's a problem, as we can't find a // window or worker global associated with a ShadowRealmGlobal... so we // continue following the chain. // // This will happen if you have nested ShadowRealms.
global = shadowRealmGlobalScope->GetCreatingGlobal();
} while (true);
return global;
}
ModuleLoaderBase* ShadowRealmGlobalScope::GetModuleLoader(JSContext* aCx) { if (mModuleLoader) { return mModuleLoader;
}
// Note: if this fails, we don't need to report an exception, as one will be // reported by ModuleLoaderBase::GetCurrentModuleLoader.
// Don't bother asking the ShadowRealmGlobal itself for a host object to get a // module loader from, instead, delegate to the enclosing global of the shadow // realm
nsCOMPtr<nsIGlobalObject> global = FindEnclosingNonShadowRealmGlobal(this);
MOZ_RELEASE_ASSERT(global);
RefPtr<Document> doc = window->GetExtantDoc(); if (!doc) { return nullptr;
}
ScriptLoader* scriptLoader = doc->ScriptLoader();
mModuleLoader = new ModuleLoader(scriptLoader, this, ModuleLoader::Normal);
// Register the shadow realm module loader for tracing and ownership.
scriptLoader->RegisterShadowRealmModuleLoader( static_cast<ModuleLoader*>(mModuleLoader.get()));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.