Closed Bug 1820594 Opened 3 years ago Closed 11 months ago

Update module import hooks to reflect changes in spec

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
143 Branch
Tracking Status
firefox143 --- fixed

People

(Reporter: yulia, Assigned: allstars.chh)

References

(Blocks 11 open bugs)

Details

Attachments

(39 files, 16 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Recently a refactor to html and ecma262 landed which refactors and simplifies the host hooks. Presentation is here: https://docs.google.com/presentation/d/1RVUE-MENQT8dj2wxvMLMDxg_VoMOwiwNQQged39QIEU/edit#slide=id.g1489ab97056_2_334

write up: https://github.com/nicolo-ribaudo/modules-import-hooks-refactor
Changes to HTML: https://github.com/whatwg/html/pull/8253
Changes to ecma262: https://nicolo-ribaudo.github.io/modules-import-hooks-refactor/

We will need to do this before the larger components of Modules Harmony lands, this includes in particular import reflection and module blocks, as both are already quite mature.

Severity: -- → N/A
Priority: -- → P3
Duplicate of this bug: 1878077
Assignee: nobody → allstars.chh
Summary: Update Import hooks to reflect changes in spec → Update module import hooks to reflect changes in spec

According to Additional Fields of Cyclic Module Records.
https://tc39.es/ecma262/#cyclic-module-record

Add a ModuleStatus::New to map to the [[Status]]::New

See https://tc39.es/ecma262/#graphloadingstate-record

From the specification, the operation uses the PromiseCapability record
to notify when it is resolved or rejected. However, to accommodate our
synchronous loader, mozJSModuleLoader, I have modified the implementation to
use function callbacks instead. This change ensures compatibility with our
existing synchronous loading mechanism.

Replace resolve hook and dynamic import hook with load hook.

Originally FinishDynamicModuleImport would resolve the module object,
now we resolve the module object in HostLoadImportedModule, and pass the
module object to FinishDynamicModuleImport.

This makes the call to ModuleLoadRequest::InstantiateModuleGraph() from
ModuleLoerBase and ModuleLink() in js shell will call
ModuleLoadRequestedModules() first, and call ModuleLink() in the
resolved callback.

From the specification, ContinueDynamicImport is done inside the engine.
https://tc39.es/ecma262/#sec-ContinueDynamicImport

However, our implementation for EvaluateModuleInContext() has bytecode
encoding related stuff, so for now I implement the ContinueDynamicImport
in the host layer.

Also, the updated spec has a slightly different error handling behavior when
module.Link() fails. I list them below:

Before HTML PR 8253 [https://github.com/whatwg/html/pull/8253]

fetch the descendants of and link a module script
https://web.archive.org/web/20221130023614/https://html.spec.whatwg.org/#fetch-the-descendants-of-and-link-a-module-script

onFetchDescendantsComplete
Step 3.2. Perform record.Link().
If this throws an exception, set result's error to rethrow to that exception.

HostImportModuleDynamically
https://web.archive.org/web/20221130023614/https://html.spec.whatwg.org/#hostimportmoduledynamically(referencingscriptormodule,-modulerequest,-promisecapability)
Step 6.3 Otherwise, set promise to the result of running a module script given result and true.

run a module script
https://web.archive.org/web/20221130023614/https://html.spec.whatwg.org/#run-a-module-script
Step 5. If script's error to rethrow is not null, then set evaluationPromise to a promise rejected with script's error to rethrow.


After ECMA262 PR 2905 [https://github.com/tc39/ecma262/pull/2905]
ContinueDynamicImport
Step 6.a Let link be Completion(module.Link()).
Step 6.b If link is an abrupt completion, then
Step 6.b.i. Perform ! Call(promiseCapability.[[Reject]], undefined, « link.[[Value]] »).
Step 6.b.ii. Return unused.

In short, the old behavior would catch the exception thrown during
module.Link(), and set the module script's error to rethrow to the
exception. Later in Evaluate(), if the module script's error to rethrow
is not null, reject the evaluation promise with the error to rethrow.
And the new behavior is simply reject the evaluation promise with the
exception thrown during module.Link().

To address this change, I add another
InstantiateDynamicImportModuleGraph() for the different error handling,
and slightly update ModuleLoaderBase::FinishDynamicImport to check if
any exception has been thrown already.

The changes in whatwg/html#8253
remove the "Find the first parse error" part. As a result, checking for
parse errors is now done in InstantiateModuleGraph() and
HostLoadImportedModule().

In our implementation, if a ModuleScript has a parse error, it
originally called LoadFinished(), which in turn called
onModuleLoadComplete. However, for WorkerModuleLoader and
WorkletModuleLoader, they called InstantiateModuleGraph(), which then
called HostLoadImportedModule(). This sequence couldn't find the module
script with the parse error, leading to an assertion failure.

To fix this issue, the call to ModuleErrored() has been moved to occur
once the ModuleScript has been inserted into mFetchModules.

Now the modules will be stored in LoadedModules() of the module object,
replace a already instantiated module with a new one won't trigger the
problem.

Attachment #9408916 - Attachment description: Bug 1820594 - Part 6: Add a module argument in FinishDynamicModuleImport. → Bug 1820594 - Part 4: Add a module argument in FinishDynamicModuleImport.
Attachment #9408914 - Attachment description: Bug 1820594 - Part 4: Update Module Hook. → Bug 1820594 - Part 6: Update Module Hook.
Attachment #9408920 - Attachment description: Bug 1820594 - Part 10: Implement ModuleLoadRequestedModules. → Bug 1820594 - Part 10: Implement LoadRequestedModules.
  • UpdateToDependenciesLoaded
  • Check parent->IsTopLevel in ChildLoadComplete
Attachment #9408922 - Attachment description: Bug 1820594 - Part 12: Call ModuleLoadRequestedModule for dynamic import. → Bug 1820594 - Part 23: Update error handling for dynamic import.
Attachment #9408924 - Attachment description: Bug 1820594 - Part 14: Remove FindFirstParseError and check for parse error in InstantiateModuleGraph and HostLoadImportedModule. → Bug 1820594 - Part 24: Remove FindFirstParseError and check for parse error.
Attachment #9408925 - Attachment description: Bug 1820594 - Part 15: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part ?: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9408921 - Attachment is obsolete: true
Attachment #9408923 - Attachment is obsolete: true
Attachment #9437193 - Attachment description: Bug 1820594 - Part 27: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → Bug 1820594 - Part 28: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9437194 - Attachment description: Bug 1820594 - Part 28: Relax the assertion check in AssertAllImportsFinished → Bug 1820594 - Part 29: Relax the assertion check in AssertAllImportsFinished
Attachment #9408925 - Attachment description: Bug 1820594 - Part ?: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 32: Remove js/src/jit-test/tests/modules/bug-1287410.js.

Originally each module graph will get different ParseError due to
FindFirstParseError algorithm,
now once a parse error is found, the error will be set to the error to rethrow
on the root module, hence both module graph should get the same error.

Attachment #9438858 - Attachment description: Bug 1820594 - Part 27: add mInitImports in ModuleLoadRequest → Bug 1820594 - Part 26: add mInitImports in ModuleLoadRequest
Attachment #9437192 - Attachment description: Bug 1820594 - Part 26: Prevent cyclic modules in InitDebuggerDataForModuleGraph → Bug 1820594 - Part 27: Prevent cyclic modules in InitDebuggerDataForModuleGraph
Attachment #9408925 - Attachment description: Bug 1820594 - Part 32: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 33: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9439079 - Attachment description: Bug 1820594 - Part 33: WIP: Update error-type-1.html → Bug 1820594 - Part 34: WIP: Update error-type-1.html
Attachment #9438862 - Attachment description: Bug 1820594 - Part 34: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 35: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9437187 - Attachment description: Bug 1820594 - Part 19: Add GetGraphLoadingStateHostDefined → Bug 1820594 - Part 19: Add GetGraphLoadingStateHostDefined.
Attachment #9437194 - Attachment description: Bug 1820594 - Part 29: Relax the assertion check in AssertAllImportsFinished → Bug 1820594 - Part 29: Check the child request is in the same module graph.
Attachment #9437179 - Attachment description: Bug 1820594 - Part 11: Resume waiting requests after fetching dependencies → Bug 1820594 - Part 11: Resume waiting requests after fetching dependencies.
Attachment #9437180 - Attachment description: Bug 1820594 - Part 12: Remove VisitedURLSet → Bug 1820594 - Part 12: Remove VisitedURLSet.
Attachment #9437183 - Attachment description: Bug 1820594 - Part 15: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies → Bug 1820594 - Part 14: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies.
Attachment #9437182 - Attachment description: Bug 1820594 - Part 14: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest → Bug 1820594 - Part 15: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest
Attachment #9437184 - Attachment description: Bug 1820594 - Part 16: Introduce ModuleScriptRequest struct and store it in mFetchedModules → Bug 1820594 - Part 16: Introduce ModuleScriptRequest struct and store it in mFetchedModules.
Attachment #9437185 - Attachment description: Bug 1820594 - Part 17: update mFetchedModules for inline modules → Bug 1820594 - Part 17: update mFetchedModules for inline modules.
Attachment #9437188 - Attachment description: Bug 1820594 - Part 20: Add State::Loaded → Bug 1820594 - Part 20: Add State::Loaded.
Attachment #9437189 - Attachment description: Bug 1820594 - Part 21: Update module graph's states when loaded → Bug 1820594 - Part 21: Update module graph's states when loaded.
Attachment #9408916 - Attachment description: Bug 1820594 - Part 4: Add a module argument in FinishDynamicModuleImport. → Bug 1820594 - Part 4: Update js::FinishDynamicModuleImport.
Attachment #9408918 - Attachment description: Bug 1820594 - Part 8: Implement FinishLoadingImportedModule, ContinueModuleLoading. → Bug 1820594 - Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading.
Attachment #9408919 - Attachment description: Bug 1820594 - Part 9: Implement ImportAttributes in InnerModuleLoading. → Bug 1820594 - Part 10: Implement ImportAttributes in InnerModuleLoading.
Attachment #9408920 - Attachment description: Bug 1820594 - Part 10: Implement LoadRequestedModules. → Bug 1820594 - Part 11: Implement LoadRequestedModules.
Attachment #9437179 - Attachment description: Bug 1820594 - Part 11: Resume waiting requests after fetching dependencies. → Bug 1820594 - Part 13: Resume waiting requests after fetching dependencies.
Attachment #9437180 - Attachment description: Bug 1820594 - Part 12: Remove VisitedURLSet. → Bug 1820594 - Part 14: Remove VisitedURLSet.
Attachment #9437181 - Attachment description: Bug 1820594 - Part 13: Remove HostResolveImportedModule and HostImportModuleDynamically → Bug 1820594 - Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically
Attachment #9437183 - Attachment description: Bug 1820594 - Part 14: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies. → Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies.
Attachment #9437182 - Attachment description: Bug 1820594 - Part 15: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest → Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest
Attachment #9437184 - Attachment description: Bug 1820594 - Part 16: Introduce ModuleScriptRequest struct and store it in mFetchedModules. → Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules.
Attachment #9437185 - Attachment description: Bug 1820594 - Part 17: update mFetchedModules for inline modules. → Bug 1820594 - Part 19: update mFetchedModules for inline modules.
Attachment #9437186 - Attachment description: Bug 1820594 - Part 18: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase → Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase
Attachment #9437187 - Attachment description: Bug 1820594 - Part 19: Add GetGraphLoadingStateHostDefined. → Bug 1820594 - Part 22: Add GetGraphLoadingStateHostDefined.
Attachment #9437188 - Attachment description: Bug 1820594 - Part 20: Add State::Loaded. → Bug 1820594 - Part 23: Add State::Loaded.
Attachment #9437189 - Attachment description: Bug 1820594 - Part 21: Update module graph's states when loaded. → Bug 1820594 - Part 24: Update module graph's states when loaded.
Attachment #9437190 - Attachment description: Bug 1820594 - Part 22: Error handling when module fetching failed → Bug 1820594 - Part 25: Error handling when module fetching failed
Attachment #9408922 - Attachment description: Bug 1820594 - Part 23: Update error handling for dynamic import. → Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import.
Attachment #9408924 - Attachment description: Bug 1820594 - Part 24: Remove FindFirstParseError and check for parse error. → Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error.
Attachment #9437191 - Attachment description: Bug 1820594 - Part 25: Add JS::GraphLoadingStateContains → Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains
Attachment #9438858 - Attachment description: Bug 1820594 - Part 26: add mInitImports in ModuleLoadRequest → Bug 1820594 - Part 29: add mInitImports in ModuleLoadRequest
Attachment #9437192 - Attachment description: Bug 1820594 - Part 27: Prevent cyclic modules in InitDebuggerDataForModuleGraph → Bug 1820594 - Part 30: Prevent cyclic modules in InitDebuggerDataForModuleGraph
Attachment #9437193 - Attachment description: Bug 1820594 - Part 28: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9437194 - Attachment description: Bug 1820594 - Part 29: Check the child request is in the same module graph. → Bug 1820594 - Part 32: Check the child request is in the same module graph.
Attachment #9438859 - Attachment description: Bug 1820594 - Part 30: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell → Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell
Attachment #9438860 - Attachment description: Bug 1820594 - Part 31: Update JS Shell implementation for HostLoadImportedModule → Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule
Attachment #9441682 - Attachment description: Bug 1820594 - Part 32: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj → Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj
Attachment #9408925 - Attachment description: Bug 1820594 - Part 33: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9438862 - Attachment description: Bug 1820594 - Part 35: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9439079 - Attachment description: Bug 1820594 - Part 34: WIP: Update error-type-1.html → Bug 1820594 - Part 38: WIP: Update error-type-1.html
Attachment #9408911 - Attachment description: Bug 1820594 - Part 1: Add ModuleStatus::New. → Bug 1820594 - Part 1: Add ModuleStatus::New. r?jonco
Attachment #9408912 - Attachment description: Bug 1820594 - Part 2: Implement GraphLoadingStateRecord. → WIP: Bug 1820594 - Part 2: Implement GraphLoadingStateRecord.
Attachment #9408913 - Attachment description: Bug 1820594 - Part 3: Implement LoadedModules in ModuleObject. → WIP: Bug 1820594 - Part 3: Implement LoadedModules in ModuleObject.
Attachment #9408915 - Attachment description: Bug 1820594 - Part 5: Implement GetImportedModule. → Bug 1820594 - Part 4: Implement GetImportedModule. r?jonco
Attachment #9408914 - Attachment description: Bug 1820594 - Part 6: Update Module Hook. → Bug 1820594 - Part 5: Update Module Hook. r?jonco
Attachment #9408917 - Attachment description: Bug 1820594 - Part 7: Implement InnerModuleLoading. → Bug 1820594 - Part 6: Implement InnerModuleLoading. r?jonco
Attachment #9472419 - Attachment description: Bug 1820594 - Part 8: Remove JS::FinishDynamicModuleImport. → Bug 1820594 - Part 7: Remove JS::FinishDynamicModuleImport. r?jonco
Attachment #9408916 - Attachment description: Bug 1820594 - Part 4: Update js::FinishDynamicModuleImport. → Bug 1820594 - Part 8: Update js::FinishDynamicModuleImport. r?jonco
Attachment #9408918 - Attachment description: Bug 1820594 - Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading. → Bug 1820594 - Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading. r?jonco
Attachment #9408919 - Attachment description: Bug 1820594 - Part 10: Implement ImportAttributes in InnerModuleLoading. → Bug 1820594 - Part 10: Implement ImportAttributes in InnerModuleLoading. r?jonco
Attachment #9408920 - Attachment description: Bug 1820594 - Part 11: Implement LoadRequestedModules. → Bug 1820594 - Part 11: Implement LoadRequestedModules. r?jonco
Attachment #9472420 - Attachment description: Bug 1820594 - Part 12: Implement ContinueDynamicImport → WIP: Bug 1820594 - Part 12: Implement ContinueDynamicImport
Attachment #9437179 - Attachment description: Bug 1820594 - Part 13: Resume waiting requests after fetching dependencies. → Bug 1820594 - Part 13: Resume waiting requests after fetching dependencies. r?jonco
Attachment #9437180 - Attachment description: Bug 1820594 - Part 14: Remove VisitedURLSet. → Bug 1820594 - Part 14: Remove VisitedURLSet. r?jonco
Attachment #9437181 - Attachment description: Bug 1820594 - Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically → WIP: Bug 1820594 - Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically
Attachment #9437183 - Attachment description: Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies. → Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies. r?jonco
Attachment #9437182 - Attachment description: Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest → WIP: Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest
Attachment #9437184 - Attachment description: Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules. → Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules. r?jonco
Attachment #9437185 - Attachment description: Bug 1820594 - Part 19: update mFetchedModules for inline modules. → Bug 1820594 - Part 19: update mFetchedModules for inline modules. r?jonco
Attachment #9437186 - Attachment description: Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase → WIP: Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase
Attachment #9472421 - Attachment description: Bug 1820594 - Part 21: Throw TypeError if the module type is unsupported. → WIP: Bug 1820594 - Part 21: Throw TypeError if the module type is unsupported.
Attachment #9437188 - Attachment description: Bug 1820594 - Part 23: Add State::Loaded. → Bug 1820594 - Part 23: Add State::Loaded. r?jonco
Attachment #9437189 - Attachment description: Bug 1820594 - Part 24: Update module graph's states when loaded. → Bug 1820594 - Part 24: Update module graph's states when loaded. r?jonco
Attachment #9437190 - Attachment description: Bug 1820594 - Part 25: Error handling when module fetching failed → WIP: Bug 1820594 - Part 25: Error handling when module fetching failed
Attachment #9408922 - Attachment description: Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import. → Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import. r?jonco
Attachment #9408924 - Attachment description: Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error. → Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error. r?jonco
Attachment #9437191 - Attachment description: Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains → WIP: Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains
Attachment #9438858 - Attachment description: Bug 1820594 - Part 29: add mInitImports in ModuleLoadRequest → WIP: Bug 1820594 - Part 29: add mInitImports in ModuleLoadRequest
Attachment #9437192 - Attachment description: Bug 1820594 - Part 30: Prevent cyclic modules in InitDebuggerDataForModuleGraph → WIP: Bug 1820594 - Part 30: Prevent cyclic modules in InitDebuggerDataForModuleGraph
Attachment #9437193 - Attachment description: Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → WIP: Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9437194 - Attachment description: Bug 1820594 - Part 32: Check the child request is in the same module graph. → WIP: Bug 1820594 - Part 32: Check the child request is in the same module graph.
Attachment #9438859 - Attachment description: Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell → WIP: Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell
Attachment #9438860 - Attachment description: Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule → WIP: Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule
Attachment #9441682 - Attachment description: Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj → WIP: Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj
Attachment #9408925 - Attachment description: Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js. r?jonco
Attachment #9438862 - Attachment description: Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → WIP: Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9439079 - Attachment description: Bug 1820594 - Part 38: WIP: Update error-type-1.html → WIP: Bug 1820594 - Part 38: WIP: Update error-type-1.html
Attachment #9472423 - Attachment description: Bug 1820594 - Part 39: WIP - Add APIs for ModuleEvaluateHook → WIP: Bug 1820594 - Part 39: WIP - Add APIs for ModuleEvaluateHook
Attachment #9472424 - Attachment description: Bug 1820594 - Part 40: WIP: Implement HostEvaluateHook in ModuleLoaderBase → WIP: Bug 1820594 - Part 40: WIP: Implement HostEvaluateHook in ModuleLoaderBase
Attachment #9408911 - Attachment description: Bug 1820594 - Part 1: Add ModuleStatus::New. r?jonco → Bug 1820594 - Part 1: Add ModuleStatus::New.
Attachment #9408912 - Attachment description: WIP: Bug 1820594 - Part 2: Implement GraphLoadingStateRecord. → Bug 1820594 - Part 2: Implement GraphLoadingStateRecord.
Attachment #9408913 - Attachment description: WIP: Bug 1820594 - Part 3: Implement LoadedModules in ModuleObject. → Bug 1820594 - Part 3: Implement LoadedModules in ModuleObject.
Attachment #9408915 - Attachment description: Bug 1820594 - Part 4: Implement GetImportedModule. r?jonco → Bug 1820594 - Part 4: Implement GetImportedModule.
Attachment #9408914 - Attachment description: Bug 1820594 - Part 5: Update Module Hook. r?jonco → Bug 1820594 - Part 5: Update Module Hook.
Attachment #9408917 - Attachment description: Bug 1820594 - Part 6: Implement InnerModuleLoading. r?jonco → Bug 1820594 - Part 6: Implement InnerModuleLoading.
Attachment #9472419 - Attachment description: Bug 1820594 - Part 7: Remove JS::FinishDynamicModuleImport. r?jonco → Bug 1820594 - Part 7: Remove JS::FinishDynamicModuleImport.
Attachment #9408916 - Attachment description: Bug 1820594 - Part 8: Update js::FinishDynamicModuleImport. r?jonco → Bug 1820594 - Part 8: Update js::FinishDynamicModuleImport.
Attachment #9408918 - Attachment description: Bug 1820594 - Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading. r?jonco → Bug 1820594 - Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading.
Attachment #9408919 - Attachment description: Bug 1820594 - Part 10: Implement ImportAttributes in InnerModuleLoading. r?jonco → Bug 1820594 - Part 10: Implement ImportAttributes in InnerModuleLoading.
Attachment #9408920 - Attachment description: Bug 1820594 - Part 11: Implement LoadRequestedModules. r?jonco → Bug 1820594 - Part 11: Implement LoadRequestedModules.
Attachment #9472420 - Attachment description: WIP: Bug 1820594 - Part 12: Implement ContinueDynamicImport → Bug 1820594 - Part 12: Implement ContinueDynamicImport
Attachment #9437179 - Attachment description: Bug 1820594 - Part 13: Resume waiting requests after fetching dependencies. r?jonco → Bug 1820594 - Part 13: Resume waiting requests after fetching dependencies.
Attachment #9437180 - Attachment description: Bug 1820594 - Part 14: Remove VisitedURLSet. r?jonco → Bug 1820594 - Part 14: Remove VisitedURLSet.
Attachment #9437181 - Attachment description: WIP: Bug 1820594 - Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically → Bug 1820594 - Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically
Attachment #9437183 - Attachment description: Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies. r?jonco → Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies.
Attachment #9437182 - Attachment description: WIP: Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest → Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest
Attachment #9437184 - Attachment description: Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules. r?jonco → Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules.
Attachment #9437185 - Attachment description: Bug 1820594 - Part 19: update mFetchedModules for inline modules. r?jonco → Bug 1820594 - Part 19: update mFetchedModules for inline modules.
Attachment #9437186 - Attachment description: WIP: Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase → Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase
Attachment #9472421 - Attachment description: WIP: Bug 1820594 - Part 21: Throw TypeError if the module type is unsupported. → Bug 1820594 - Part 21: Throw TypeError if the module type is unsupported.
Attachment #9437188 - Attachment description: Bug 1820594 - Part 23: Add State::Loaded. r?jonco → Bug 1820594 - Part 23: Add State::Loaded.
Attachment #9437189 - Attachment description: Bug 1820594 - Part 24: Update module graph's states when loaded. r?jonco → Bug 1820594 - Part 24: Update module graph's states when loaded.
Attachment #9437190 - Attachment description: WIP: Bug 1820594 - Part 25: Error handling when module fetching failed → Bug 1820594 - Part 25: Error handling when module fetching failed
Attachment #9408922 - Attachment description: Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import. r?jonco → Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import.
Attachment #9408924 - Attachment description: Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error. r?jonco → Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error.
Attachment #9437191 - Attachment description: WIP: Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains → Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains
Attachment #9438858 - Attachment description: WIP: Bug 1820594 - Part 29: add mInitImports in ModuleLoadRequest → Bug 1820594 - Part 29: add mInitImports in ModuleLoadRequest
Attachment #9437192 - Attachment description: WIP: Bug 1820594 - Part 30: Prevent cyclic modules in InitDebuggerDataForModuleGraph → Bug 1820594 - Part 30: Prevent cyclic modules in InitDebuggerDataForModuleGraph
Attachment #9437193 - Attachment description: WIP: Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9437194 - Attachment description: WIP: Bug 1820594 - Part 32: Check the child request is in the same module graph. → Bug 1820594 - Part 32: Check the child request is in the same module graph.
Attachment #9438859 - Attachment description: WIP: Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell → Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell
Attachment #9438860 - Attachment description: WIP: Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule → Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule
Attachment #9441682 - Attachment description: WIP: Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj → Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj
Attachment #9408925 - Attachment description: Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js. r?jonco → Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9438862 - Attachment description: WIP: Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9439079 - Attachment description: WIP: Bug 1820594 - Part 38: WIP: Update error-type-1.html → Bug 1820594 - Part 38: WIP: Update error-type-1.html
Attachment #9472423 - Attachment description: WIP: Bug 1820594 - Part 39: WIP - Add APIs for ModuleEvaluateHook → Bug 1820594 - Part 39: WIP - Add APIs for ModuleEvaluateHook
Attachment #9472424 - Attachment description: WIP: Bug 1820594 - Part 40: WIP: Implement HostEvaluateHook in ModuleLoaderBase → Bug 1820594 - Part 40: WIP: Implement HostEvaluateHook in ModuleLoaderBase
Attachment #9437187 - Attachment is obsolete: true

I haven't tested this particularly but this should work.

Attachment #9437183 - Attachment description: Bug 1820594 - Part 16: Add ModuleFetched, and call LoadRequestedModules in StartFetchingModuleDependencies. → Bug 1820594 - Part 17: Add OnFetchSucceeded
Attachment #9437182 - Attachment description: Bug 1820594 - Part 17: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest → Bug 1820594 - Part 18: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest
Attachment #9437184 - Attachment description: Bug 1820594 - Part 18: Introduce ModuleScriptRequest struct and store it in mFetchedModules. → Bug 1820594 - Part 19: Introduce ModuleScriptRequest struct and store it in mFetchedModules.
Attachment #9437185 - Attachment description: Bug 1820594 - Part 19: update mFetchedModules for inline modules. → Bug 1820594 - Part 20: update mFetchedModules for inline modules.
Attachment #9437186 - Attachment description: Bug 1820594 - Part 20: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase → Bug 1820594 - Part 21: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase
Attachment #9472421 - Attachment description: Bug 1820594 - Part 21: Throw TypeError if the module type is unsupported. → Bug 1820594 - Part 22: Throw TypeError if the module type is unsupported.
Attachment #9437193 - Attachment description: Bug 1820594 - Part 31: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → Bug 1820594 - Part 29: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9437194 - Attachment description: Bug 1820594 - Part 32: Check the child request is in the same module graph. → Bug 1820594 - Part 30: Check the child request is in the same module graph.
Attachment #9438859 - Attachment description: Bug 1820594 - Part 33: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell → Bug 1820594 - Part 31: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell
Attachment #9438860 - Attachment description: Bug 1820594 - Part 34: Update JS Shell implementation for HostLoadImportedModule → Bug 1820594 - Part 32: Update JS Shell implementation for HostLoadImportedModule
Attachment #9441682 - Attachment description: Bug 1820594 - Part 35: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj → Bug 1820594 - Part 33: Add mCanceledWhileFetching flag to reset mReferreObj and mModuleRequestObj
Attachment #9408925 - Attachment description: Bug 1820594 - Part 36: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 34: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9438862 - Attachment description: Bug 1820594 - Part 37: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 35: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9439079 - Attachment description: Bug 1820594 - Part 38: WIP: Update error-type-1.html → Bug 1820594 - Part 36: WIP: Update error-type-1.html
Attachment #9472420 - Attachment description: Bug 1820594 - Part 12: Implement ContinueDynamicImport → Bug 1820594 - Part 12: Implement ContinueDynamicImport.
Attachment #9472423 - Attachment is obsolete: true
Attachment #9472424 - Attachment is obsolete: true
Attachment #9438858 - Attachment is obsolete: true
Attachment #9437192 - Attachment is obsolete: true
Attachment #9437186 - Attachment description: Bug 1820594 - Part 21: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase → Bug 1820594 - Part 21: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase.
Attachment #9437190 - Attachment description: Bug 1820594 - Part 25: Error handling when module fetching failed → Bug 1820594 - Part 25: Error handling when module fetching failed.
Attachment #9437191 - Attachment description: Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains → Bug 1820594 - Part 28: Add JS::GraphLoadingStateContains.
Attachment #9438860 - Attachment description: Bug 1820594 - Part 32: Update JS Shell implementation for HostLoadImportedModule → Bug 1820594 - Part 32: Update JS Shell implementation for HostLoadImportedModule.

Hi, arai
I'd like to ask for your suggestion.
Currently I have one xpcshell failure in test_import_global_current.js, it fails in testSyncImportWhileAsyncImportTLA

The try failure is here

Originally (in current m-c), the window.import will fetch the TLA script (es6module_top_level_await.js), then it will be moved to loaded list,
And ScriptLoader will process the loaded request

Now with the patches in this bug here. Part 16 will call LoadRequestedModules, and the module will be loaded in Part 24, notice that the module is loaded when the promise from LoadRequestedModules is resolved. At that time ScriptLoader::OnStreamComplete has returned.
When the module is loaded, it will process the loaded requests asynchronously.
But before the module is processed, the ChromeUtils.importESModule is executed, then the module evaluation from ChromeUtils.importESModule will trigger the assertion

So my question is the test testSyncImportWhileAsyncImportTLA still valid after this bug? As window.import now will take longer to do the actual module evaluation, and what and how should the ChromeUtils.importESModule behave while the importing TLA is still executing?

Thanks

Flags: needinfo?(arai.unmht)

At least, hitting an assertion failure sounds like there's an issue in the implementation side, not only in the testcase alone.

Then, I think this was actually a pre-existing issue, where the testcase wasn't hitting the problematic path.

We should expect the evaluation promise to be pending for { global: "current" } option, given that the modules it's seeing can be handled by the regular module loader with supports TLA with pending promises.

Thus, we should have another branch around the following code to handle the case where evaluationPromise is pending, and throw an error about "imported module has TLA and it's still getting executed by other module loader", or something says "modules with TLA can be imported with importESModule only after the module is fully evaluated".
We should also assert that the pending case happens only with { global: "current" } option (otherwise the promise shouldn't be pending at that point).

https://searchfox.org/mozilla-central/rev/a67f2f0854c99bf35cf7e41c0610db7b9bf2c8e2/js/loader/ModuleLoaderBase.cpp#1480-1481

if (!JS::ThrowOnModuleEvaluationFailure(aCx, evaluationPromise,
                                        errorBehaviour)) {

Feel free to disable the testcase for now.
I can look into it later.

Flags: needinfo?(arai.unmht)

Store LoadContextBase and RootedModule information into LoadedScript/ModuleScript.

  • Move UpdateReferrerPolicy from ScriptLoadRequest to ModuleLoadRequest,
    as this can only happend for a module load.

  • Add UpdateReferrerPolicy method to ModuleScript.
    Introduces a new UpdateReferrerPolicy method for ModuleScript,
    allowing the referrer policy to be updated based on the associated
    ModuleLoadRequest.

Attachment #9437190 - Attachment description: Bug 1820594 - Part 25: Error handling when module fetching failed. → Bug 1820594 - Part 23: Error handling when module fetching failed.

When there's a ParseError, the error should be dispatched asynchronously.
However, workers can't handle the micro task, therefore we still call
ModuleErrored synchronously.

WPT test: /html/semantics/scripting-1/the-script-element/module/inline-async-inserted-execorder.html

Attachment #9408922 - Attachment description: Bug 1820594 - Part 26: Call FinishLoadingImportedModule for dynamic import. → Bug 1820594 - Part 25: Call FinishLoadingImportedModule for dynamic import.
Attachment #9408924 - Attachment description: Bug 1820594 - Part 27: Remove FindFirstParseError and check for parse error. → Bug 1820594 - Part 26: Remove FindFirstParseError and check for parse error.

Since the module graph is now traversed within the JS engine itself, the
related data structures in the host layer are no longer necessary.

Attachment #9437193 - Attachment description: Bug 1820594 - Part 29: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update → Bug 1820594 - Part 28: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update
Attachment #9438859 - Attachment description: Bug 1820594 - Part 31: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell → Bug 1820594 - Part 29: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell
Attachment #9438860 - Attachment description: Bug 1820594 - Part 32: Update JS Shell implementation for HostLoadImportedModule. → Bug 1820594 - Part 30: Update JS Shell implementation for HostLoadImportedModule.
Attachment #9437194 - Attachment description: Bug 1820594 - Part 30: Check the child request is in the same module graph. → Bug 1820594 - Part 31: Test the child requests accross multiple module graphs.
Attachment #9408925 - Attachment description: Bug 1820594 - Part 34: Remove js/src/jit-test/tests/modules/bug-1287410.js. → Bug 1820594 - Part 32: Remove js/src/jit-test/tests/modules/bug-1287410.js.
Attachment #9438862 - Attachment description: Bug 1820594 - Part 35: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 33: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html
Attachment #9439079 - Attachment description: Bug 1820594 - Part 36: WIP: Update error-type-1.html → Bug 1820594 - Part 34: WIP: Update error-type-1.html
Attachment #9490650 - Attachment description: Bug 1820594 - Part 37: Update wpt ini for dynamic import. → Bug 1820594 - Part 35: Update wpt ini for dynamic import.
Attachment #9437184 - Attachment is obsolete: true
Attachment #9437185 - Attachment is obsolete: true
Attachment #9437188 - Attachment is obsolete: true
Attachment #9437189 - Attachment is obsolete: true
Attachment #9437191 - Attachment is obsolete: true
Attachment #9441682 - Attachment is obsolete: true
Attachment #9490651 - Attachment is obsolete: true
Attachment #9496998 - Attachment description: Bug 1820594 - Part 19 : Refactor CreateStaticImport. → Bug 1820594 - Part 19: Refactor CreateStaticImport.
Attachment #9497001 - Attachment description: Bug 1820594 - Part 27 : Remove redundant module graph data structures from host layer. → Bug 1820594 - Part 27: Remove redundant module graph data structures from host layer.
Attachment #9497002 - Attachment description: Bug 1820594 - Part 36 - Disable testSyncImportWhileAsyncImportTLA. → Bug 1820594 - Part 36: Disable testSyncImportWhileAsyncImportTLA.
Attachment #9438862 - Attachment description: Bug 1820594 - Part 33: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html → Bug 1820594 - Part 33: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html.
Attachment #9439079 - Attachment description: Bug 1820594 - Part 34: WIP: Update error-type-1.html → Bug 1820594 - Part 34: Update error-type-1.html

Comment on attachment 9438862 [details]
Bug 1820594 - Part 33: Update testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html.

Revision D229652 was moved to bug 1974658. Setting attachment 9438862 [details] to obsolete.

Attachment #9438862 - Attachment is obsolete: true

Comment on attachment 9439079 [details]
Bug 1820594 - Part 34: Update error-type-1.html

Revision D229651 was moved to bug 1974658. Setting attachment 9439079 [details] to obsolete.

Attachment #9439079 - Attachment is obsolete: true
Attachment #9490650 - Attachment description: Bug 1820594 - Part 35: Update wpt ini for dynamic import. → Bug 1820594 - Part 34: Update wpt ini for dynamic import.
Attachment #9497002 - Attachment description: Bug 1820594 - Part 36: Disable testSyncImportWhileAsyncImportTLA. → Bug 1820594 - Part 35: Disable testSyncImportWhileAsyncImportTLA.

In mochitest-browser tests, it's possible for the about:neterror page to
load. This triggers aboutNetError.html, which in turn loads aboutNetError.mjs.

Occasionally, the load promise from
LoadRequestedModules(aboutNetError.mjs) is never resolved because the
PromiseJobRunnable is not executed if the global is in the process of
shutting down.

To avoid this issue, we now use the synchronous version of
LoadRequestedModules when loading chrome resources.

In mochitest-browser tests, it's possible for the about:neterror page to
load. This triggers aboutNetError.html, which in turn loads
aboutNetError.mjs, eventually importing pkijs.js. The pkijs.js module is
compiled off-thread.

However, when the test framework proceeds to the next test, the
associated document may be detached before the off-thread compilation of
pkijs.js completes. If this happens while TaskController is shutting
down, the compilation task may never finish.

Currently, ScriptLoader only tracks top-level off-thread compilation
requests, not submodules involved in those tasks. To address this, we
now call CancelFetchingModules when ScriptLoader cancels ongoing
requests, ensuring submodule fetches are also properly aborted.

Pushed by allstars.chh@gmail.com: https://github.com/mozilla-firefox/firefox/commit/bfd2615ef195 https://hg.mozilla.org/integration/autoland/rev/c4deab997a08 Part 1: Add ModuleStatus::New. r=jonco https://github.com/mozilla-firefox/firefox/commit/05a2b76d9c08 https://hg.mozilla.org/integration/autoland/rev/5db2670b50c6 Part 2: Implement GraphLoadingStateRecord. r=jonco https://github.com/mozilla-firefox/firefox/commit/f639c7eb9620 https://hg.mozilla.org/integration/autoland/rev/b9e0a5069871 Part 3: Implement LoadedModules in ModuleObject. r=jonco https://github.com/mozilla-firefox/firefox/commit/19507524a2e6 https://hg.mozilla.org/integration/autoland/rev/045516a59e28 Part 4: Implement GetImportedModule. r=jonco https://github.com/mozilla-firefox/firefox/commit/4f00fb82af4a https://hg.mozilla.org/integration/autoland/rev/4b587d61e767 Part 5: Update Module Hook. r=jonco https://github.com/mozilla-firefox/firefox/commit/ef4d03deaf29 https://hg.mozilla.org/integration/autoland/rev/bc7618ad2c34 Part 6: Implement InnerModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/1e6d8581b93b https://hg.mozilla.org/integration/autoland/rev/0292b31b5fbd Part 7: Remove JS::FinishDynamicModuleImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/f5546f06d267 https://hg.mozilla.org/integration/autoland/rev/b000b34a212f Part 8: Update js::FinishDynamicModuleImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/85bcdccef34b https://hg.mozilla.org/integration/autoland/rev/deb9edd6a57f Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/3115d8a191c5 https://hg.mozilla.org/integration/autoland/rev/1a13659c86e8 Part 10: Implement ImportAttributes in InnerModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/0049bf82d126 https://hg.mozilla.org/integration/autoland/rev/e9e1b6fc8bf2 Part 11: Implement LoadRequestedModules. r=jonco https://github.com/mozilla-firefox/firefox/commit/b487d8ffec7f https://hg.mozilla.org/integration/autoland/rev/46f44a3082c5 Part 12: Implement ContinueDynamicImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/a5edee9705c6 https://hg.mozilla.org/integration/autoland/rev/87e34685a86f Part 13: Resume waiting requests after fetching dependencies. r=jonco https://github.com/mozilla-firefox/firefox/commit/09f1ea1a1a88 https://hg.mozilla.org/integration/autoland/rev/6ff927b808a4 Part 14: Remove VisitedURLSet. r=jonco https://github.com/mozilla-firefox/firefox/commit/8c45c3380e4b https://hg.mozilla.org/integration/autoland/rev/a225c8cf8cd5 Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically r=jonco https://github.com/mozilla-firefox/firefox/commit/cf9a4a886df3 https://hg.mozilla.org/integration/autoland/rev/f02c6f496cad Part 16: Call LoadRequestedModules in StartFetchingModuleDependencies. r=jonco https://github.com/mozilla-firefox/firefox/commit/a75c3d1989f8 https://hg.mozilla.org/integration/autoland/rev/cd1f242dade1 Part 16-1 : Use sync version of LoadRequestedModules for chrome pages. r=jonco https://github.com/mozilla-firefox/firefox/commit/4b60b4037a55 https://hg.mozilla.org/integration/autoland/rev/30410e042280 Part 17: Add OnFetchSucceeded r=jonco https://github.com/mozilla-firefox/firefox/commit/96b553c522fc https://hg.mozilla.org/integration/autoland/rev/c479c528c2fd Part 18: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest r=jonco https://github.com/mozilla-firefox/firefox/commit/e7cc5dcf27f1 https://hg.mozilla.org/integration/autoland/rev/425e6e784b4e Part 19: Refactor CreateStaticImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/e92cdaa12999 https://hg.mozilla.org/integration/autoland/rev/f82327c72c57 Part 20: Update module script's referrer policy. r=jonco https://github.com/mozilla-firefox/firefox/commit/2c2abeb8a3e7 https://hg.mozilla.org/integration/autoland/rev/37aa0de87918 Part 21: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase. r=jonco https://github.com/mozilla-firefox/firefox/commit/f793f2b08688 https://hg.mozilla.org/integration/autoland/rev/54251d5b6cd5 Part 22: Throw TypeError if the module type is unsupported. r=jonco https://github.com/mozilla-firefox/firefox/commit/8054f6d6b318 https://hg.mozilla.org/integration/autoland/rev/adb7e8ccd69a Part 23: Error handling when module fetching failed. r=jonco https://github.com/mozilla-firefox/firefox/commit/aa0e96e6c157 https://hg.mozilla.org/integration/autoland/rev/7d143e3db297 Part 24: Add ModuleErroredRunnable to dispatch ModuleErrored. r=jonco https://github.com/mozilla-firefox/firefox/commit/9037595d2781 https://hg.mozilla.org/integration/autoland/rev/e52ac6aa02c1 Part 25: Call FinishLoadingImportedModule for dynamic import. r=jonco https://github.com/mozilla-firefox/firefox/commit/665970f84791 https://hg.mozilla.org/integration/autoland/rev/bc27f738ab53 Part 26: Remove FindFirstParseError and check for parse error. r=jonco https://github.com/mozilla-firefox/firefox/commit/81673cfb4e6c https://hg.mozilla.org/integration/autoland/rev/6406483d53a7 Part 27: Remove redundant module graph data structures from host layer. r=jonco https://github.com/mozilla-firefox/firefox/commit/86aea74da6d8 https://hg.mozilla.org/integration/autoland/rev/f34df5d6d250 Part 28: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update r=jonco https://github.com/mozilla-firefox/firefox/commit/aa686310fc36 https://hg.mozilla.org/integration/autoland/rev/078a3cdf5cd7 Part 29: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell r=jonco https://github.com/mozilla-firefox/firefox/commit/5a2f281ba707 https://hg.mozilla.org/integration/autoland/rev/f48c98c10cef Part 30: Update JS Shell implementation for HostLoadImportedModule. r=jonco https://github.com/mozilla-firefox/firefox/commit/fc403c5ea97b https://hg.mozilla.org/integration/autoland/rev/ec26cd0ac7bd Part 31: Test the child requests accross multiple module graphs. r=jonco https://github.com/mozilla-firefox/firefox/commit/6a47bd9a7c2a https://hg.mozilla.org/integration/autoland/rev/bcb51f401536 Part 32: Remove js/src/jit-test/tests/modules/bug-1287410.js. r=jonco https://github.com/mozilla-firefox/firefox/commit/696d4051b251 https://hg.mozilla.org/integration/autoland/rev/2bac600a9e4a Part 33: Update choice-of-error-1.html.ini and error-type-1.html.ini failed as expected. r=jonco https://github.com/mozilla-firefox/firefox/commit/6dc30859a292 https://hg.mozilla.org/integration/autoland/rev/3f9cda7af2bc Part 34: Update wpt ini for dynamic import. r=jonco https://github.com/mozilla-firefox/firefox/commit/bd7ac6c6dac3 https://hg.mozilla.org/integration/autoland/rev/23c1514d4c46 Part 35: Disable testSyncImportWhileAsyncImportTLA. r=arai https://github.com/mozilla-firefox/firefox/commit/bb9106dfec70 https://hg.mozilla.org/integration/autoland/rev/2320382eddda Part 36: Add CancelFetchingModules. r=jonco
Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f46ece6f70e1 https://hg.mozilla.org/integration/autoland/rev/48134d64e64b Revert "Bug 1820594 - Part 36: Add CancelFetchingModules. r=jonco" for causing failures at mochitest.toml.

I'll check the leak, thanks.

Flags: needinfo?(allstars.chh)
Pushed by allstars.chh@gmail.com: https://github.com/mozilla-firefox/firefox/commit/b7653ddc0605 https://hg.mozilla.org/integration/autoland/rev/0edfd9c6884d Part 1: Add ModuleStatus::New. r=jonco https://github.com/mozilla-firefox/firefox/commit/5794f2e2ec7d https://hg.mozilla.org/integration/autoland/rev/b6d75f4f4756 Part 2: Implement GraphLoadingStateRecord. r=jonco https://github.com/mozilla-firefox/firefox/commit/e18a469866a3 https://hg.mozilla.org/integration/autoland/rev/0ae144aca175 Part 3: Implement LoadedModules in ModuleObject. r=jonco https://github.com/mozilla-firefox/firefox/commit/97f18986dbe3 https://hg.mozilla.org/integration/autoland/rev/96ab5aa70275 Part 4: Implement GetImportedModule. r=jonco https://github.com/mozilla-firefox/firefox/commit/a9c5e5494278 https://hg.mozilla.org/integration/autoland/rev/a8a18d8f7237 Part 5: Update Module Hook. r=jonco https://github.com/mozilla-firefox/firefox/commit/f75396a2687a https://hg.mozilla.org/integration/autoland/rev/d07c809e1fd7 Part 6: Implement InnerModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/ddf8de3cc166 https://hg.mozilla.org/integration/autoland/rev/528371e474bb Part 7: Remove JS::FinishDynamicModuleImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/4c3086d007ac https://hg.mozilla.org/integration/autoland/rev/1d7c093083ea Part 8: Update js::FinishDynamicModuleImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/76fbf186c099 https://hg.mozilla.org/integration/autoland/rev/a35abbf73367 Part 9: Implement FinishLoadingImportedModule, ContinueModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/13fb577be23d https://hg.mozilla.org/integration/autoland/rev/69f593198e24 Part 10: Implement ImportAttributes in InnerModuleLoading. r=jonco https://github.com/mozilla-firefox/firefox/commit/29eea71f201c https://hg.mozilla.org/integration/autoland/rev/bd54f46cdae0 Part 11: Implement LoadRequestedModules. r=jonco https://github.com/mozilla-firefox/firefox/commit/2662812a51fd https://hg.mozilla.org/integration/autoland/rev/440c2a2605b3 Part 12: Implement ContinueDynamicImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/e10ced86e911 https://hg.mozilla.org/integration/autoland/rev/03007620a79e Part 13: Resume waiting requests after fetching dependencies. r=jonco https://github.com/mozilla-firefox/firefox/commit/00a8ab1fcee1 https://hg.mozilla.org/integration/autoland/rev/c5eabc03ec00 Part 14: Remove VisitedURLSet. r=jonco https://github.com/mozilla-firefox/firefox/commit/a2b683969197 https://hg.mozilla.org/integration/autoland/rev/46fc20c776f5 Part 15: Remove HostResolveImportedModule and HostImportModuleDynamically r=jonco https://github.com/mozilla-firefox/firefox/commit/5c786aae1ffc https://hg.mozilla.org/integration/autoland/rev/04606db11850 Part 16: Call LoadRequestedModules in StartFetchingModuleDependencies. r=jonco https://github.com/mozilla-firefox/firefox/commit/a48f69ed7934 https://hg.mozilla.org/integration/autoland/rev/8d8d07e5b63c Part 16-1 : Use sync version of LoadRequestedModules for chrome pages. r=jonco https://github.com/mozilla-firefox/firefox/commit/2a6b58d511b4 https://hg.mozilla.org/integration/autoland/rev/e4cb2d8bc88f Part 17: Add OnFetchSucceeded r=jonco https://github.com/mozilla-firefox/firefox/commit/2f395ffaf723 https://hg.mozilla.org/integration/autoland/rev/cfff4af812f1 Part 18: Add mReferrerObj, mModuleRequestObj, mReferencingPrivate, mStatePrivate in ModuleLoadRequest r=jonco https://github.com/mozilla-firefox/firefox/commit/745139e2c815 https://hg.mozilla.org/integration/autoland/rev/2b33077bbe0b Part 19: Refactor CreateStaticImport. r=jonco https://github.com/mozilla-firefox/firefox/commit/cfaa6e7c060a https://hg.mozilla.org/integration/autoland/rev/99cfceaf276b Part 20: Update module script's referrer policy. r=jonco https://github.com/mozilla-firefox/firefox/commit/14ef8f5fdbd2 https://hg.mozilla.org/integration/autoland/rev/6d0c7a363043 Part 21: Implement HostLoadImportedModule and FinishLoadingImportedModule in ModuleLoaderBase. r=jonco https://github.com/mozilla-firefox/firefox/commit/b4418fa96d3a https://hg.mozilla.org/integration/autoland/rev/6ef880c3361e Part 22: Throw TypeError if the module type is unsupported. r=jonco https://github.com/mozilla-firefox/firefox/commit/33d4e771ca4f https://hg.mozilla.org/integration/autoland/rev/8ce9c39a01cc Part 23: Error handling when module fetching failed. r=jonco https://github.com/mozilla-firefox/firefox/commit/2d3841c2a04f https://hg.mozilla.org/integration/autoland/rev/46f3fb297eee Part 24: Add ModuleErroredRunnable to dispatch ModuleErrored. r=jonco https://github.com/mozilla-firefox/firefox/commit/2464b45fe0e7 https://hg.mozilla.org/integration/autoland/rev/70e571a4d115 Part 25: Call FinishLoadingImportedModule for dynamic import. r=jonco https://github.com/mozilla-firefox/firefox/commit/4f92fa4f2d6f https://hg.mozilla.org/integration/autoland/rev/b21b6ee4cd76 Part 26: Remove FindFirstParseError and check for parse error. r=jonco https://github.com/mozilla-firefox/firefox/commit/264c8307be5e https://hg.mozilla.org/integration/autoland/rev/e505acd05133 Part 27: Remove redundant module graph data structures from host layer. r=jonco https://github.com/mozilla-firefox/firefox/commit/a45a4b166239 https://hg.mozilla.org/integration/autoland/rev/609d8edb3283 Part 28: DOM, Worker, Worklet ScriptLoader, mozJSModuleLoader update r=jonco https://github.com/mozilla-firefox/firefox/commit/101f455ecf07 https://hg.mozilla.org/integration/autoland/rev/028810114451 Part 29: Remove ModuleLoader::ResolveImportedModule and ModuleLoader::ImportModuleDynamically in JS Shell r=jonco https://github.com/mozilla-firefox/firefox/commit/9b69569913ab https://hg.mozilla.org/integration/autoland/rev/3119dda70eb8 Part 30: Update JS Shell implementation for HostLoadImportedModule. r=jonco https://github.com/mozilla-firefox/firefox/commit/16dd3441e9b9 https://hg.mozilla.org/integration/autoland/rev/3f0c9544000e Part 31: Test the child requests accross multiple module graphs. r=jonco https://github.com/mozilla-firefox/firefox/commit/27682875fd7c https://hg.mozilla.org/integration/autoland/rev/f2b1698faa37 Part 32: Remove js/src/jit-test/tests/modules/bug-1287410.js. r=jonco https://github.com/mozilla-firefox/firefox/commit/6232bc1f6b39 https://hg.mozilla.org/integration/autoland/rev/277e23f39103 Part 33: Update choice-of-error-1.html.ini and error-type-1.html.ini failed as expected. r=jonco https://github.com/mozilla-firefox/firefox/commit/e4784b66b5ab https://hg.mozilla.org/integration/autoland/rev/bbd0092e97a3 Part 34: Update wpt ini for dynamic import. r=jonco https://github.com/mozilla-firefox/firefox/commit/3a92e676705b https://hg.mozilla.org/integration/autoland/rev/e2972b033db7 Part 35: Disable testSyncImportWhileAsyncImportTLA. r=arai https://github.com/mozilla-firefox/firefox/commit/a61af56c37dd https://hg.mozilla.org/integration/autoland/rev/90cbfb6edeef Part 36: Add CancelFetchingModules. r=jonco

https://hg.mozilla.org/mozilla-central/rev/0edfd9c6884d
https://hg.mozilla.org/mozilla-central/rev/b6d75f4f4756
https://hg.mozilla.org/mozilla-central/rev/0ae144aca175
https://hg.mozilla.org/mozilla-central/rev/96ab5aa70275
https://hg.mozilla.org/mozilla-central/rev/a8a18d8f7237
https://hg.mozilla.org/mozilla-central/rev/d07c809e1fd7
https://hg.mozilla.org/mozilla-central/rev/528371e474bb
https://hg.mozilla.org/mozilla-central/rev/1d7c093083ea
https://hg.mozilla.org/mozilla-central/rev/a35abbf73367
https://hg.mozilla.org/mozilla-central/rev/69f593198e24
https://hg.mozilla.org/mozilla-central/rev/bd54f46cdae0
https://hg.mozilla.org/mozilla-central/rev/440c2a2605b3
https://hg.mozilla.org/mozilla-central/rev/03007620a79e
https://hg.mozilla.org/mozilla-central/rev/c5eabc03ec00
https://hg.mozilla.org/mozilla-central/rev/46fc20c776f5
https://hg.mozilla.org/mozilla-central/rev/04606db11850
https://hg.mozilla.org/mozilla-central/rev/8d8d07e5b63c
https://hg.mozilla.org/mozilla-central/rev/e4cb2d8bc88f
https://hg.mozilla.org/mozilla-central/rev/cfff4af812f1
https://hg.mozilla.org/mozilla-central/rev/2b33077bbe0b
https://hg.mozilla.org/mozilla-central/rev/99cfceaf276b
https://hg.mozilla.org/mozilla-central/rev/6d0c7a363043
https://hg.mozilla.org/mozilla-central/rev/6ef880c3361e
https://hg.mozilla.org/mozilla-central/rev/8ce9c39a01cc
https://hg.mozilla.org/mozilla-central/rev/46f3fb297eee
https://hg.mozilla.org/mozilla-central/rev/70e571a4d115
https://hg.mozilla.org/mozilla-central/rev/b21b6ee4cd76
https://hg.mozilla.org/mozilla-central/rev/e505acd05133
https://hg.mozilla.org/mozilla-central/rev/609d8edb3283
https://hg.mozilla.org/mozilla-central/rev/028810114451
https://hg.mozilla.org/mozilla-central/rev/3119dda70eb8
https://hg.mozilla.org/mozilla-central/rev/3f0c9544000e
https://hg.mozilla.org/mozilla-central/rev/f2b1698faa37
https://hg.mozilla.org/mozilla-central/rev/277e23f39103
https://hg.mozilla.org/mozilla-central/rev/bbd0092e97a3
https://hg.mozilla.org/mozilla-central/rev/e2972b033db7
https://hg.mozilla.org/mozilla-central/rev/90cbfb6edeef

Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 143 Branch
Regressions: 1978873
Blocks: 1980126
Duplicate of this bug: 1894729
QA Whiteboard: [qa-triage-done-c144/b143]
Regressions: 2013907
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: