Commit graph

94 commits

Author SHA1 Message Date
Yulia Startsev
87c8288cb8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2023-01-18 13:46:32 +00:00
Yulia Startsev
56c6f79308 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2023-01-18 13:46:29 +00:00
Jonatan Klemets
402679a7ad Bug 1810366 - Remove unused requestedModule variable in ModuleLoaderBase::ResolveRequestedModules r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D166879
2023-01-16 20:17:30 +00:00
Norisz Fay
8cf029b070 Backed out 15 changesets (bug 1247687) as requested by dev CLOSED TREE
Backed out changeset 81d052cabf84 (bug 1247687)
Backed out changeset d698041e5174 (bug 1247687)
Backed out changeset 2adf67f910e8 (bug 1247687)
Backed out changeset 0bc871906e97 (bug 1247687)
Backed out changeset 1700d5b79273 (bug 1247687)
Backed out changeset 31888ffde37a (bug 1247687)
Backed out changeset 9153182c650d (bug 1247687)
Backed out changeset 45de9ffeec19 (bug 1247687)
Backed out changeset 59207e959b7c (bug 1247687)
Backed out changeset 49f18430c465 (bug 1247687)
Backed out changeset 0ae1fd421d4f (bug 1247687)
Backed out changeset 7770ec4717fd (bug 1247687)
Backed out changeset 68b476066248 (bug 1247687)
Backed out changeset c94a9dc60dff (bug 1247687)
Backed out changeset 0ab366c6eaaf (bug 1247687)
2022-12-21 10:48:15 +02:00
Yulia Startsev
ef3c7012f8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-20 20:56:14 +00:00
Yulia Startsev
e859be10b8 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-20 20:56:12 +00:00
Jon Coppeard
50c149f6dc 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
2022-12-19 11:56:34 +00:00
Csoregi Natalia
c382c6a7ca Backed out 16 changesets (bug 1247687) for frequent string bundle related crashes with PDF viewer (bug 1806064). a=backout
Backed out changeset 721f612fd09f (bug 1247687)
Backed out changeset c6c5750cf713 (bug 1247687)
Backed out changeset 5d05ab0c7cde (bug 1247687)
Backed out changeset 2429599729cb (bug 1247687)
Backed out changeset 55f13fb4ee3f (bug 1247687)
Backed out changeset 354711cf113a (bug 1247687)
Backed out changeset 40b8abaf1c0b (bug 1247687)
Backed out changeset 0c9650a1ac48 (bug 1247687)
Backed out changeset e7b103c79b1a (bug 1247687)
Backed out changeset 4dbd510fb042 (bug 1247687)
Backed out changeset 9276c7e1ddd9 (bug 1247687)
Backed out changeset 6ee318df6641 (bug 1247687)
Backed out changeset 6c129bd72b61 (bug 1247687)
Backed out changeset 4b0a4fcc6894 (bug 1247687)
Backed out changeset 34680059b9f0 (bug 1247687)
Backed out changeset 85b827971a48 (bug 1247687)
2022-12-17 11:27:32 +02:00
Yulia Startsev
51d7d18a24 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-14 14:55:37 +00:00
Yulia Startsev
a40b702d6e Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-14 14:55:35 +00:00
Jon Coppeard
7856ea877c Bug 1804254 - Part 3: Replace RequestedModuleObject with native RequestedModule r=arai
This is more complicated because it needed a change to the public API now we're
not longer returning an array object. The new API is less error prone since
it's no longer possible for the caller to mutate the object returned.

Depends on D163948

Differential Revision: https://phabricator.services.mozilla.com/D163949
2022-12-07 11:28:28 +00:00
Jon Coppeard
f3248398d8 Bug 1774111 - Check for already-completed request in ModuleLoaderBase::FinishDynamicImport r=yulia
I've looked at this for a while and still don't know how this can happen but it
does seem reasonable to add a check here that we haven't already completed the
request.

Depends on D162386

Differential Revision: https://phabricator.services.mozilla.com/D162387
2022-11-18 13:25:47 +00:00
Jon Coppeard
71d7de8c4d Bug 1774111 - Initialize AutoJAPI from the native global in the module loader r=yulia
We're getting a bunch of crashes related to initializing AutoJSAPI from a
JSObject pointer that turns out to be null. That overload of Init() gets the
native global from the JSObject and since we already have a native global in
the module loader we can use the overload that takes that instead. This
overload does a null check so we will catch the case where the global is null
(although that should also not happen).

This might just move crashes elsewhere but it's a reasonable tidyup.

Differential Revision: https://phabricator.services.mozilla.com/D162386
2022-11-18 13:25:46 +00:00
Jon Coppeard
f64d585ec0 Bug 1797166 - Don't assume an exception is always set if module compilation fails r=yulia
It would be nice to assume this but CompileFetchedModule can potentially fail for reasons that
are not JS-related.

Also check for the exception being |undefined| which would cause
ModuleScript::HasParseError to return false. Such an exception should never be
thrown by parsing but check for it just in case.

Add a diagnostic assert to check module script state is as we expect to
hopefully catch related problems sooner.

Differential Revision: https://phabricator.services.mozilla.com/D160788
2022-10-31 14:26:48 +00:00
Jon Coppeard
a8344b1f34 Bug 1712762 - Check if module load requests have already been cancelled in ModuleLoaderBase::CancelDynamicImport r=yulia
I don't know whether this is the problem, but if we try and cancel a request
that has already been cancelled it would produce this crash.

Differential Revision: https://phabricator.services.mozilla.com/D159167
2022-10-12 16:26:20 +00:00
Yoshi Cheng-Hao Huang
ee07ecaeec Bug 1778289 - Part 12: Update spec links as the PR is merged. r=jonco,yulia
The PR has been merged.
See https://html.spec.whatwg.org/multipage/webappapis.html#import-maps

Differential Revision: https://phabricator.services.mozilla.com/D158828
2022-10-07 13:56:27 +00:00
Yoshi Cheng-Hao Huang
4c950d8322 Bug 1778289 - Part 5: Update spec in RegisterImportMap. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D152872
2022-10-07 13:56:24 +00:00
Yoshi Cheng-Hao Huang
c12c714e61 Bug 1778289 - Part 3: Update spec links in ModuleLoaderBase::ParseImportMap. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D152870
2022-10-07 13:56:23 +00:00
Yoshi Cheng-Hao Huang
aa441ff9e0 Bug 1775424 - Part 3: Fix GC hazards in ImportMetaResolveImpl. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D155973
2022-08-30 18:42:54 +00:00
Yoshi Cheng-Hao Huang
d17eb87e4d Bug 1775424 - Part 1: Impl import.meta.resolve() on browser. r=jonco,yulia
Define 'resolve()' function on import.meta object on browser.

Add mochitests for import.meta.resolve, as some of the wpt tests for
import.meta.resolve cannot be run due to some bugs in wpt testing framework.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1785806

Differential Revision: https://phabricator.services.mozilla.com/D154105
2022-08-30 18:42:53 +00:00
Sandor Molnar
d3f5c8300e Backed out 2 changesets (bug 1775424) for causing linux hazard build bustage in js/loader/ModuleLoaderBase.cpp CLOSED TREE
Backed out changeset a043a84a771c (bug 1775424)
Backed out changeset 19bc4fafd300 (bug 1775424)
2022-08-30 02:51:29 +03:00
Yoshi Cheng-Hao Huang
a9970aa2ff Bug 1775424 - Part 1: Impl import.meta.resolve() on browser. r=jonco,yulia
Define 'resolve()' function on import.meta object on browser.

Add mochitests for import.meta.resolve, as some of the wpt tests for
import.meta.resolve cannot be run due to some bugs in wpt testing framework.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1785806

Differential Revision: https://phabricator.services.mozilla.com/D154105
2022-08-29 18:12:09 +00:00
Yulia Startsev
dee4b84e71 Bug 1784477 - Make ModuleLoaderBase thread-insensitive; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D147323
2022-08-12 16:18:44 +00:00
Yulia Startsev
ddbc6378de Bug 1784477 - Remove Dynamic Import option; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D154529
2022-08-12 16:18:44 +00:00
Tooru Fujisawa
0bb31403fd Bug 1781124 - Use static pref for dom.importMaps.enabled in module loader. r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D152712
2022-07-26 06:30:46 +00:00
Jon Coppeard
3e69adc940 Bug 1777450 - Separate error messages for module resulution failure when the specifier might be bare r=allstarschh,flod
This fixes the original case by adding an extra error reason which is used when
the specifier could be bare and and only warning about relative URLs in this
case.

The same problem happens with import maps enable where "./foo.js" produces an
error about it being a bare specifier, which it's not. For that case make
ParseURLLikeImportSpecifier return a ResolveResult and use the same approach.

Differential Revision: https://phabricator.services.mozilla.com/D151153
2022-07-08 09:58:33 +00:00
Jon Coppeard
3ca0fba399 Bug 1778076 - Part 4: Rename ModuleInstantiate with ModuleLink to follow the spec r=arai
The ModuleObject methods will be dealt with in the next patch.

Depends on D151013

Differential Revision: https://phabricator.services.mozilla.com/D151014
2022-07-05 13:04:55 +00:00
Tooru Fujisawa
4a7453191a Bug 1776832 - Clear chrome module environments in shutdown r=arai
Differential Revision: https://phabricator.services.mozilla.com/D150966
2022-07-04 14:18:54 +00:00
Matthew Gaudet
430dfe1d67 Bug 1769322 - Allow for the possibility of non-xpc globals in nsIGlobal::IsScriptForbidden r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D146347
2022-05-24 17:23:32 +00:00
Tooru Fujisawa
bb1d312b22 Bug 1769029 - Support ESM loaded by shim in Cu.loadedModules. r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D146169
2022-05-13 22:02:41 +00:00
Tooru Fujisawa
980d04aebc Bug 1768922 - Support ESM loaded by shim in Cu.isModuleLoaded. r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D146166
2022-05-13 22:02:40 +00:00
Cristian Tuns
2bea2f32be Backed out 8 changesets (bug 1766976, bug 1768922, bug 1769029, bug 1766761, bug 1768060) for causing spidermonkey failures on Modules.cpp CLOSED TREE
Backed out changeset da102935dfd2 (bug 1769029)
Backed out changeset e080258f38a7 (bug 1768922)
Backed out changeset 36e9e0301a24 (bug 1766976)
Backed out changeset dd28b0eb27ef (bug 1768060)
Backed out changeset 682c4afbcfe9 (bug 1766761)
Backed out changeset a7a37e912b90 (bug 1766761)
Backed out changeset d8099b6d970b (bug 1766761)
Backed out changeset 435acc6d6abd (bug 1766761)
2022-05-13 12:49:49 -04:00
Tooru Fujisawa
229b059954 Bug 1769029 - Support ESM loaded by shim in Cu.loadedModules. r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D146169
2022-05-13 15:23:17 +00:00
Tooru Fujisawa
11c8544fb4 Bug 1768922 - Support ESM loaded by shim in Cu.isModuleLoaded. r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D146166
2022-05-13 15:23:17 +00:00
Jon Coppeard
10fc79714b Bug 1432901 - Part 12: Break cycles manually during shutdown r=yulia
Since mozJSComponentLoader is destroyed after the cycle collector, we need to
break cycles manually before the final cycle collection otherwise we get a
memory leak. Unload() is called at an appropriate earlier point in shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D145567
2022-05-10 12:58:10 +00:00
Jon Coppeard
fc72352fb5 Bug 1432901 - Part 7: Add a load context for use by the new module loader r=yulia
This will be used to hold compilation results before they are passed to the base class.

Differential Revision: https://phabricator.services.mozilla.com/D145561
2022-05-10 12:58:08 +00:00
Jon Coppeard
e14763ccd7 Bug 1432901 - Part 3: Add option for synchronous module evaluation in the module loader r=yulia
This adds the parameter to the module loaders evaluation method. I also
rewrote the comments a bit to make this section clearer based on my
understanding of how this works.

Differential Revision: https://phabricator.services.mozilla.com/D145556
2022-05-10 12:58:06 +00:00
Jon Coppeard
9143d0485b Bug 1767829 - Part 5: Add EvaluateModuleInContext method to allow callers to set up and supply their own JSContext r=yulia
The main version of EvaluateModule will continue to use AutoEntryScript, but we
don't always want it's error reporting behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D145492
2022-05-09 11:06:26 +00:00
Jon Coppeard
260fa6927f Bug 1767829 - Part 4: Throw an error if CreateDynamicImport returns null r=yulia
This allows derived loaders not to support dynamic import if they don't want to.

Module loading for in mozJSComponentLoader will not initially support this.

Differential Revision: https://phabricator.services.mozilla.com/D145491
2022-05-09 11:06:26 +00:00
Jon Coppeard
ce9567cdac Bug 1767829 - Part 3: Add the option for derived module loaders to specifiy their own event target r=yulia
Module loaders require an event target to use with mozPromise. The default uses
the event loop so doesn't permit implementing a synchronous module loader.

Differential Revision: https://phabricator.services.mozilla.com/D145490
2022-05-09 11:06:25 +00:00
Yoshi Cheng-Hao Huang
8a939e5954 Bug 1688879 - Part 5: ResolveModuleSpecifier for import maps. r=jonco,yulia,flod
Implement https://wicg.github.io/import-maps/#resolve-a-module-specifier

Differential Revision: https://phabricator.services.mozilla.com/D142072
2022-05-05 21:19:02 +00:00
Yoshi Cheng-Hao Huang
7ba3206f1c Bug 1688879 - Part 4: Refactor ResolveModuleSpecifier. r=jonco,yulia
Add ResolveResult to return nsIURI on success or return ResolveError on
failure.

Differential Revision: https://phabricator.services.mozilla.com/D142073
2022-05-05 21:19:02 +00:00
Yoshi Cheng-Hao Huang
464384bf31 Bug 1688879 - Part 3: Parse and register an import map. r=jonco,yulia
Implement
https://wicg.github.io/import-maps/#parse-an-import-map-string,
and
https://wicg.github.io/import-maps/#register-an-import-map

Differential Revision: https://phabricator.services.mozilla.com/D142071
2022-05-05 21:19:01 +00:00
Butkovits Atila
fb9f362af3 Backed out 11 changesets (bug 1688879) for causing build bustages. CLOSED TREE
Backed out changeset 350ddd17c7f5 (bug 1688879)
Backed out changeset 27984b95ed20 (bug 1688879)
Backed out changeset 6a5bb063965f (bug 1688879)
Backed out changeset d8edcfdb504b (bug 1688879)
Backed out changeset 77ab231310ec (bug 1688879)
Backed out changeset c2bce95a1aca (bug 1688879)
Backed out changeset f5862572ced8 (bug 1688879)
Backed out changeset 05e0a1bf32fc (bug 1688879)
Backed out changeset adeab05b7419 (bug 1688879)
Backed out changeset 0e60834e17e5 (bug 1688879)
Backed out changeset 877bb4c2ce66 (bug 1688879)
2022-05-05 19:52:05 +03:00
Yoshi Cheng-Hao Huang
098e1668c8 Bug 1688879 - Part 5: ResolveModuleSpecifier for import maps. r=jonco,yulia,flod
Implement https://wicg.github.io/import-maps/#resolve-a-module-specifier

Differential Revision: https://phabricator.services.mozilla.com/D142072
2022-05-05 16:03:17 +00:00
Yoshi Cheng-Hao Huang
1b35f68535 Bug 1688879 - Part 4: Refactor ResolveModuleSpecifier. r=jonco,yulia
Add ResolveResult to return nsIURI on success or return ResolveError on
failure.

Differential Revision: https://phabricator.services.mozilla.com/D142073
2022-05-05 16:03:17 +00:00
Yoshi Cheng-Hao Huang
48be9bcaa2 Bug 1688879 - Part 3: Parse and register an import map. r=jonco,yulia
Implement
https://wicg.github.io/import-maps/#parse-an-import-map-string,
and
https://wicg.github.io/import-maps/#register-an-import-map

Differential Revision: https://phabricator.services.mozilla.com/D142071
2022-05-05 16:03:16 +00:00
Narcis Beleuzu
a92a200e76 Backed out 9 changesets (bug 1688879) for bustages on ImportMap.cpp
Backed out changeset 44e9abe72a5e (bug 1688879)
Backed out changeset 0503d2d2ae01 (bug 1688879)
Backed out changeset 2cf08a51b184 (bug 1688879)
Backed out changeset 6f0276c3ab0e (bug 1688879)
Backed out changeset f16b14d8f677 (bug 1688879)
Backed out changeset 03b772e02d07 (bug 1688879)
Backed out changeset 39ed48a5ecc2 (bug 1688879)
Backed out changeset d7b42d8312bb (bug 1688879)
Backed out changeset 5e695bf5dd0d (bug 1688879)
2022-05-05 03:41:31 +03:00
Yoshi Cheng-Hao Huang
45ae7f8cf1 Bug 1688879 - Part 5: ResolveModuleSpecifier for import maps. r=jonco,yulia,flod
Implement https://wicg.github.io/import-maps/#resolve-a-module-specifier

Differential Revision: https://phabricator.services.mozilla.com/D142072
2022-05-04 21:02:51 +00:00
Yoshi Cheng-Hao Huang
b5def10f13 Bug 1688879 - Part 4: Refactor ResolveModuleSpecifier. r=jonco,yulia
Add ResolveResult to return nsIURI on success or return ResolveError on
failure.

Differential Revision: https://phabricator.services.mozilla.com/D142073
2022-05-04 21:02:51 +00:00