Skip to content

Commit ac6a7c2

Browse files
committed
Bug 1916277 - Part 8: Set mIsPreload to true for non-top-level modules. r=jonco
Currently Gecko only set mIsPreload to true for the top-level preloading load. To identify a non-top-level preload, update mIsPreload accordingly to match the mIsPreload flag from the root module. Differential Revision: https://phabricator.services.mozilla.com/D281154
1 parent 2e020fb commit ac6a7c2

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

dom/script/ModuleLoader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateRequest(
498498
MOZ_ASSERT(root);
499499
LoadContextBase* loadContext = root->mLoadContext;
500500
context->mScriptMode = loadContext->AsWindowContext()->mScriptMode;
501+
if (loadContext->AsWindowContext()->mIsPreload) {
502+
context->mIsPreload = true;
503+
}
501504
kind = ModuleLoadRequest::Kind::StaticImport;
502505
}
503506

dom/script/ScriptLoadContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class ScriptLoadContext : public JS::loader::LoadContextBase,
286286
bool mInCompilingList; // True if we are in mOffThreadCompilingRequests.
287287
bool mWasCompiledOMT; // True if the script has been compiled off main
288288
// thread.
289-
// Set on scripts and top level modules.
289+
// Set on preloading scripts or modules.
290290
bool mIsPreload;
291291

292292
// For preload requests, we defer reporting errors to the console until the

js/loader/ModuleLoadRequest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ void ModuleLoadRequest::ModuleLoaded() {
9797
MOZ_ASSERT(IsFetching());
9898

9999
mModuleScript = mLoader->GetFetchedModule(ModuleMapKey(URI(), mModuleType));
100+
101+
if (mModuleScript->ForPreload() != mLoadContext->IsPreload()) {
102+
mModuleScript->SetForPreload(mLoadContext->IsPreload());
103+
}
100104
}
101105

102106
void ModuleLoadRequest::LoadFailed() {

0 commit comments

Comments
 (0)