Bug 1806136 - Part 0: Change the API so that the supported assertions are set once on initialization r=arai
Not related to the rest of the bug. This is a simplification so that we set the supported import assertions once rather than querying the host every time they are needed. Differential Revision: https://phabricator.services.mozilla.com/D164914
This commit is contained in:
@@ -49,6 +49,8 @@ mozilla::LazyLogModule ModuleLoaderBase::gModuleLoaderBaseLog(
|
||||
|
||||
#define LOG_ENABLED() \
|
||||
MOZ_LOG_TEST(ModuleLoaderBase::gModuleLoaderBaseLog, mozilla::LogLevel::Debug)
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// ModuleLoaderBase
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -75,8 +77,14 @@ void ModuleLoaderBase::EnsureModuleHooksInitialized() {
|
||||
JS::SetModuleMetadataHook(rt, HostPopulateImportMeta);
|
||||
JS::SetScriptPrivateReferenceHooks(rt, HostAddRefTopLevelScript,
|
||||
HostReleaseTopLevelScript);
|
||||
JS::SetSupportedAssertionsHook(rt, HostGetSupportedImportAssertions);
|
||||
JS::SetModuleDynamicImportHook(rt, HostImportModuleDynamically);
|
||||
|
||||
JS::ImportAssertionVector assertions;
|
||||
// ImportAssertionVector has inline storage for one element so this cannot
|
||||
// fail.
|
||||
MOZ_ALWAYS_TRUE(assertions.reserve(1));
|
||||
assertions.infallibleAppend(JS::ImportAssertion::Type);
|
||||
JS::SetSupportedImportAssertions(rt, assertions);
|
||||
}
|
||||
|
||||
// 8.1.3.8.1 HostResolveImportedModule(referencingModule, moduleRequest)
|
||||
@@ -317,20 +325,6 @@ bool ModuleLoaderBase::HostImportModuleDynamically(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModuleLoaderBase::HostGetSupportedImportAssertions(
|
||||
JSContext* aCx, JS::ImportAssertionVector& aValues) {
|
||||
MOZ_ASSERT(aValues.empty());
|
||||
|
||||
if (!aValues.reserve(1)) {
|
||||
JS_ReportOutOfMemory(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
aValues.infallibleAppend(JS::ImportAssertion::Type);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
ModuleLoaderBase* ModuleLoaderBase::GetCurrentModuleLoader(JSContext* aCx) {
|
||||
auto reportError = mozilla::MakeScopeExit([aCx]() {
|
||||
|
||||
Reference in New Issue
Block a user