Commit graph

85 commits

Author SHA1 Message Date
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
Yoshi Cheng-Hao Huang
d9207c7020 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-04 21:02:50 +00:00
Jon Coppeard
5d525af423 Bug 1766274 - Part 4: Change references to module trees to module graphs r=yulia
Module imports can be cyclic so it's more correct to refer to them as graphs.
The spec also uses this term.

Depends on D144599

Differential Revision: https://phabricator.services.mozilla.com/D144600
2022-04-26 12:40:48 +00:00
Jon Coppeard
77609d6143 Bug 1766274 - Part 3: Rename CompileOrFinishModuleScript to CompileFetchedModule r=yulia
I was less sure of this one, but I think 'finish' is confusing here. Better names welcome.

Depends on D144597

Differential Revision: https://phabricator.services.mozilla.com/D144599
2022-04-26 12:40:48 +00:00
Jon Coppeard
7e3e0ea7fd Bug 1766274 - Part 1: Rename ProcessFetchedModuleSource to OnFetchComplete and pass an error code r=yulia
This renames the method to correspond to StartFetch and adds a status argument
so clients can call this rather than
SetModuleFetchFinishedAndResumeWaitingRequests on error.

Depends on D144595

Differential Revision: https://phabricator.services.mozilla.com/D144596
2022-04-26 12:40:47 +00:00
Yulia Startsev
a996a1aca2 Bug 1763372 - Rename GetLoadContext to GetScriptLoadContext; r=jonco
Depends on D143068

Differential Revision: https://phabricator.services.mozilla.com/D143037
2022-04-22 13:24:10 +00:00
Yulia Startsev
604a6aa077 Bug 1763372 - address new issues in the hybrid build; r=jonco
Depends on D143036

Differential Revision: https://phabricator.services.mozilla.com/D143068
2022-04-22 13:24:10 +00:00
Yulia Startsev
7b6ada3766 Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143139
2022-04-21 09:53:34 +00:00
Yulia Startsev
9c4d96a57d Bug 1763586 - Adjust ScriptFetchOptions to be more accurate; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143137
2022-04-21 09:53:33 +00:00
criss
1a5e600ac1 Backed out 4 changesets (bug 1763586) for causing mochitest failures on test_Debugger.Source.prototype.elementAttribute.html. CLOSED TREE
Backed out changeset 8da9574159d3 (bug 1763586)
Backed out changeset 8f964a9e2f31 (bug 1763586)
Backed out changeset 420105516ec3 (bug 1763586)
Backed out changeset 68cd444d018e (bug 1763586)
2022-04-19 16:28:30 +03:00