Граф коммитов

105 Коммитов

Автор SHA1 Сообщение Дата
Yulia 2e8899ceb2 Bug 1822452 - Reject any remaining requests; r=jonco
This patch allows us to reject any outstanding requests when terminating a worker. As this is
controlled by the module loader, the approach I took here was to reject the promises and allow the
moduleloader to
shutdown. I am open to alternatives however.

Differential Revision: https://phabricator.services.mozilla.com/D173290
2023-03-23 09:54:49 +00:00
Yoshi Cheng-Hao Huang 19e0568f4d Bug 1820119 - import() should throw a TypeError in a worklet script. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D171563
2023-03-19 20:39:02 +00:00
Sandor Molnar b1ca540f9f Backed out changeset d341f6827d75 (bug 1820119) for causing xpc failures in js/xpconnect/tests/unit/test_import_es6_modules.js CLOSED TREE 2023-03-16 19:18:45 +02:00
Yoshi Cheng-Hao Huang d73f5a0402 Bug 1820119 - import() should throw a TypeError in a worklet script. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D171563
2023-03-16 14:27:48 +00:00
Yulia 99088fb36f Bug 1540913 - Part 3: Exit early if worker module evaluation is aborted; r=jonco
This change addresses the second issue around worker shutdown with infinitely running dynamic
imports: As the event loop is prevented from running when the worker is dying, we do not want to
delegate to the event loop in this case. This case always has a failing promise. Since this is a
failure case related to the worker dying, we stop running code, rather
than waiting for a tick (that never comes) from the event loop.

Differential Revision: https://phabricator.services.mozilla.com/D171684
2023-03-14 18:16:31 +00:00
Yulia 5231b910c8 Bug 1540913 - Part 2: Clear and shutdown ModuleLoader at worker termination; r=asuth,jonco
When running an infinitely-looping dynamic import, it is possible for the module loader to still be
holding on to that module at shutdown. Shutdown on the worker means that we will no longer run the
event loop, which will execute the dynamic import promises necessary to clear the global. The result
is that the global is kept alive. By calling `Shutdown()` we prevent this partially. We additionally
need to address the failure in the module code (next patch).

Differential Revision: https://phabricator.services.mozilla.com/D171683
2023-03-14 18:16:31 +00:00
Yulia 4e6402f008 Bug 1540913 - Part 1: allow ModuleLoaders to return BaseURI without ScriptLoader;r=jonco
This is a required change for dynamic import on workers, as the ScriptLoader is not guaranteed to
live long enough. Once the initial script loading is finished, and the script has executed, the
scriptloader is cleared and the strong reference to the workerRef is cleared so that shutdown is
possible. The workerRef is required in order to access the worker private safely. In order to
address this, we move the GetBaseURI method to the module loader itself. In the future, we should
remove the script loader interface all together.

Differential Revision: https://phabricator.services.mozilla.com/D171682
2023-03-14 18:16:30 +00:00
Yoshi Cheng-Hao Huang c01828aba9 Bug 1572644 - Part 11-1: Add a virtual method GetResolveFailureMessage in ModuleLoaderBase. r=jonco,yulia
The virtual method will be overrided by WorkletModuleLoader in the next
patch.



Depends on D166548

Differential Revision: https://phabricator.services.mozilla.com/D166549
2023-03-13 22:59:41 +00:00
Yulia 2e680f55e9 Bug 1821066 - Ensure that module error is correctly set when ResolveRequestedModules fails; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D172243
2023-03-10 17:30:04 +00:00
Jon Coppeard e205425545 Bug 1813494 - Part 2: Add IsErrored() predicate for module load request r=smaug
This condition is checked in a few places.

Differential Revision: https://phabricator.services.mozilla.com/D168232
2023-02-07 11:55:51 +00:00
Peter Van der Beken 1f731ae6fe Bug 1811238 - Correct QueryInterface implementation of LoadedScript and ModuleLoaderBase. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D167252
2023-01-24 09:55:27 +00:00
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