Handle module import error in customElements.js
Categories
(Toolkit :: General, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox150 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
Details
Attachments
(1 file)
derived from bug 2019262 and bug 2018794.
In the customElements.js, we're using ChromeUtils.importESModule to sync-import modules.
customElements.setElementCreationCallback(
tag,
function customElementCreationCallback() {
ChromeUtils.importESModule(script, { global: "current" });
}
);
There are four problems here:
- (A) those modules are imported both with the regular module loader and sync module loader, which is actually prohibited in the design
- (B) bug 2018794 happens likely because the page performs navigation while initializing custom elements and importing modules, which results in the import failure
- (C)
ChromeUtils.importESModule's sync module loader conflicts with the regular module loader's failure - (D) CustomElementRegistry doesn't expect errors in the callback, and thus just propagating the import error still causes crash
NS_IMETHODIMP
CustomElementRegistry::RunCustomElementCreationCallback::Run() {
...
MOZ_ASSERT(NS_SUCCEEDED(er.StealNSResult()),
"chrome JavaScript error in the callback.");
(C) is going to be addressed in bug 2019262, and (B) is going to be addressed in bug 2018794.
(D) need to be addressed here, and the option I'm thinking is to wrap the ChromeUtils.importESModule call with try-catch and define an empty element on failure.
(A) is something that should ultimately be solved, but that requires huge amount of rewrite I think.
| Assignee | ||
Comment 1•4 months ago
|
||
Comment 3•4 months ago
|
||
| bugherder | ||
Comment 4•4 months ago
|
||
Authored by https://github.com/arai-a
https://github.com/mozilla/enterprise-firefox/commit/ee0e1a6c52c9d357ef04a892b57363e28203124c
[enterprise-main] Bug 2020008 - Fallback to an empty element if the custom element's module import fails. r=hjones
Updated•3 months ago
|
Description
•