Commit graph

609 commits

Author SHA1 Message Date
Tooru Fujisawa
17c5cde210 Bug 1800641 - Part 10: Add ScriptLoadRequest::mLoadedScript. r=nbp
Depends on D197847

Differential Revision: https://phabricator.services.mozilla.com/D197848
2024-01-08 14:57:39 +00:00
Tooru Fujisawa
bdc574a37f Bug 1800641 - Part 9: Add LoadedScript::mURI and call SetBaseURL separately. r=nbp
Depends on D197846

Differential Revision: https://phabricator.services.mozilla.com/D197847
2024-01-08 14:57:39 +00:00
Tooru Fujisawa
976c794ad0 Bug 1800641 - Part 8: Add LoadContextBase* parameter to ScriptLoadRequest methods which is going to be moved to LoadedScriptDelegate. r=nbp
Depends on D197845

Differential Revision: https://phabricator.services.mozilla.com/D197846
2024-01-08 14:57:38 +00:00
Tooru Fujisawa
f135bad3aa Bug 1800641 - Part 7: Add ScriptLoadRequest::State::{CheckingCache,PendingFetchingError}. r=nbp
Depends on D197844

Differential Revision: https://phabricator.services.mozilla.com/D197845
2024-01-08 14:57:38 +00:00
Noemi Erli
7fd755cbb5 Backed out changeset 4d6294424819 (bug 1800641) for causing Bug 1872347 2023-12-29 16:23:18 +02:00
Nicolas B. Pierron
8a851d2266 Bug 1800641 - Move some ScriptLoadRequest fields into LoadedScript. r=yulia
We are looking into caching loaded script in memory. To do so we need something
to cache.

At the moment, the `ScriptLoadRequest` structure hold all the fields which are
loaded, and used before executing JavaScript code. Then, the `ScriptLoadRequest`
is not guaranteed to out-live the first execution.

Therefore, we have to move fields out of the `ScriptLoadRequest` such that they
can later be used by any caching mechanism. The `LoadedScript` is the closest
existing structure which exists which fit the description.

This patch moves fields out of the ScriptLoadRequest into the `LoadedScript`,
which already has a `LoadedScript` field.

The `LoadedScript` field is initialized sooner, when the `ScriptLoadRequest` is
created, to be subsituted later by a real cache implementation. At the moment
the function `ScriptLoadRequest::NoCacheEntryFound` is used as a placeholder to
change the state of the `ScriptLoadRequest` from `CheckingCache` to `Fetching`.
Existing initializations are replaced by assertions to fail in debug build if
the current patch does not reproduce the expected state properly.

The `LoadedScript` get fields such as the source text, the text length, the
bytecode buffer (which also contains SRI), and the offset at which the bytecode
starts within the bytecode buffer. As these fields are no longer reachable by
name, multiple accessors are added to work-around the issue. Using this as an
opportunity to add extra assertions as part of these accessors.

A new class named `LoadedScriptDelegate` is added to re-add, by inheritance, all
the accessors which used to be part of `ScriptLoadRequest` as methods which are
delegating to the field which is holding the `LoadedScript`. This class is using
templates to avoid virtual inheritance which might hinder inlining, especially
since `ScriptLoadRequest` cannot be made final, as `ModuleLoadRequest` extends
it.

The `ScriptFetchOptions` structure is moved to its own file to solve C++ include
issues.

Differential Revision: https://phabricator.services.mozilla.com/D163615
2023-12-25 09:46:54 +00:00
Cosmin Sabou
a9cb718ef1 Backed out changeset f69f493b2f3c (bug 1800641) for causing non-unified build bustages on LoadedScript.cpp. CLOSED TREE 2023-12-25 08:38:51 +02:00
Nicolas B. Pierron
7b23c511de Bug 1800641 - Move some ScriptLoadRequest fields into LoadedScript. r=yulia
We are looking into caching loaded script in memory. To do so we need something
to cache.

At the moment, the `ScriptLoadRequest` structure hold all the fields which are
loaded, and used before executing JavaScript code. Then, the `ScriptLoadRequest`
is not guaranteed to out-live the first execution.

Therefore, we have to move fields out of the `ScriptLoadRequest` such that they
can later be used by any caching mechanism. The `LoadedScript` is the closest
existing structure which exists which fit the description.

This patch moves fields out of the ScriptLoadRequest into the `LoadedScript`,
which already has a `LoadedScript` field.

The `LoadedScript` field is initialized sooner, when the `ScriptLoadRequest` is
created, to be subsituted later by a real cache implementation. At the moment
the function `ScriptLoadRequest::NoCacheEntryFound` is used as a placeholder to
change the state of the `ScriptLoadRequest` from `CheckingCache` to `Fetching`.
Existing initializations are replaced by assertions to fail in debug build if
the current patch does not reproduce the expected state properly.

The `LoadedScript` get fields such as the source text, the text length, the
bytecode buffer (which also contains SRI), and the offset at which the bytecode
starts within the bytecode buffer. As these fields are no longer reachable by
name, multiple accessors are added to work-around the issue. Using this as an
opportunity to add extra assertions as part of these accessors.

A new class named `LoadedScriptDelegate` is added to re-add, by inheritance, all
the accessors which used to be part of `ScriptLoadRequest` as methods which are
delegating to the field which is holding the `LoadedScript`. This class is using
templates to avoid virtual inheritance which might hinder inlining, especially
since `ScriptLoadRequest` cannot be made final, as `ModuleLoadRequest` extends
it.

The `ScriptFetchOptions` structure is moved to its own file to solve C++ include
issues.

Differential Revision: https://phabricator.services.mozilla.com/D163615
2023-12-25 05:50:53 +00:00
Jens Stutte
21001eee69 Bug 1823391 - Have a static WorkerScriptLoader::Create and try to shutdown when the workerRef is notified. r=yulia,edenchuang,asuth
This patch does:
- use our common `Create` pattern also here to move some complexity out of the constructor and improve the error handling.
- give each strong worker ref a unique name for better diagnostics.
- add a `TryShutdown` to the life-cycle worker ref, presumably this may help if the worker dies before any DispatchLoadScript(s) has been called.

Differential Revision: https://phabricator.services.mozilla.com/D192936
2023-11-15 07:00:02 +00:00
Andrew Sutherland
49058aa9d5 Bug 1856090 - Improve ServiceWorker state propagation. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D190245
2023-10-24 20:34:25 +00:00
Artur Iunusov
3beddab32f Bug 1831583: Fix secFlags when fetching a module script, r=dom-worker-reviewers,smaug
https://html.spec.whatwg.org/#fetch-a-single-module-script
Step 8. Let request be a new request whose URL is url,
destination is destination, mode is "cors",
referrer is referrer, and client is fetchClient.

Differential Revision: https://phabricator.services.mozilla.com/D181065
2023-09-25 14:37:00 +00:00
Yoshi Cheng-Hao Huang
cd69bc3c65 Bug 1841859 - Part 1: Move ReferrerPolicy to ScriptLoadRequest and LoadedScript. r=jonco,smaug
Suggested by jonco during review,
https://phabricator.services.mozilla.com/D186944#inline-1036982

Differential Revision: https://phabricator.services.mozilla.com/D187385
2023-09-20 17:32:15 +00:00
Mirko Brodesser
2966a909e7 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-28 11:56:34 +00:00
Yoshi Cheng-Hao Huang
af590ba000 Bug 1831324 - Part 2: Check if classic worker script can be compiled. r=dom-worker-reviewers,smaug
According to the spec,
https://html.spec.whatwg.org/#run-a-worker

14. In both cases, let onComplete given script be the following steps:
  1. If script is null or if script's error to rethrow is non-null, then:
    1. Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
    2. Run the environment discarding steps for inside settings.
    3. Abort these steps.

Split EvaluateSourceBuffer into JS::Compile and JS_ExecuteScript.
So if we found the script cannot be compiled and it is a top-level script,
we assign a non-JS-Exception error code to it.

If the script cannot be compiled and it's not a top-level script, this
means it's a script which is loaded by importScripts(), according to the
spec, https://html.spec.whatwg.org/#import-scripts-into-worker-global-scope
the exception will be rethrown.

Differential Revision: https://phabricator.services.mozilla.com/D185532
2023-08-15 16:26:51 +00:00
Yoshi Cheng-Hao Huang
8570bf9c5d Bug 1831324 - Part 1: Check if the module worker script has a parse error or an error to rethrow. r=jonco,dom-worker-reviewers,smaug
According to the spec,
https://html.spec.whatwg.org/#run-a-worker

14. In both cases, let onComplete given script be the following steps:
  1. If script is null or if script's error to rethrow is non-null, then:
    1. Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
    2. Run the environment discarding steps for inside settings.
    3. Abort these steps.

Check if the module worker script has a parse error or an error to
rethrow. If it has, assign an error code to mRv and return false.

The error will be reported in CompileScriptRunnable
https://searchfox.org/mozilla-central/rev/892475f3ba2b959aeaef19d1d8602494e3f2ae32/dom/workers/WorkerPrivate.cpp#417

Differential Revision: https://phabricator.services.mozilla.com/D185531
2023-08-15 16:26:51 +00:00
Yoshi Cheng-Hao Huang
e2668be1a6 Bug 1847548 - Part 1: Use nsIContentPolicy::TYPE_INTERNAL_MODULE for worker's dynamic import scripts. r=dom-worker-reviewers,smaug,evilpie
Differential Revision: https://phabricator.services.mozilla.com/D185563
2023-08-15 07:54:55 +00:00
Cosmin Sabou
c406bcf318 Backed out 5 changesets (bug 1839316) for causing bustages on ScriptLoader.cpp. CLOSED TREE
Backed out changeset 85f107e082ee (bug 1839316)
Backed out changeset 8c1e22518c3a (bug 1839316)
Backed out changeset a4c3dec0f34c (bug 1839316)
Backed out changeset 313ff15742dd (bug 1839316)
Backed out changeset fa200e26bbb1 (bug 1839316)
2023-08-09 20:16:06 +03:00
Mirko Brodesser
5cade38f47 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-09 13:50:28 +00:00
Cosmin Sabou
0058dbdd1c Backed out 5 changesets (bug 1839316) for causing leaks. CLOSED TREE
Backed out changeset 75edff380fee (bug 1839316)
Backed out changeset 6a622fd5cd91 (bug 1839316)
Backed out changeset 60908cc7c586 (bug 1839316)
Backed out changeset 7b9dd8875a9e (bug 1839316)
Backed out changeset b586915187c2 (bug 1839316)
2023-08-07 16:43:03 +03:00
Mirko Brodesser
5d091f10d0 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-07 11:46:19 +00:00
Jon Coppeard
80cac6bbb5 Bug 1843838 - Rename ScriptLoadRequest::IsReadyToRun to IsFinished since this returns true for cancelled requests r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183740
2023-08-04 09:40:40 +00:00
Jon Coppeard
85b88021df Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-03 08:15:29 +00:00
Narcis Beleuzu
cf92578c03 Backed out 4 changesets (bug 1842798) for wpt failures on module-tla-import.html . CLOSED TREE
Backed out changeset 879154594bb1 (bug 1842798)
Backed out changeset 2a6b3ff79a01 (bug 1842798)
Backed out changeset 507da9d36f91 (bug 1842798)
Backed out changeset 3528d70acb5f (bug 1842798)
2023-08-02 20:48:53 +03:00
Jon Coppeard
afcabcef11 Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-02 14:39:33 +00:00
Sandor Molnar
9de1620f3b Backed out 4 changesets (bug 1842798) for causing wpt failures in /html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html CLOSED TREE
Backed out changeset b153ebf104ef (bug 1842798)
Backed out changeset 05bcaff61b68 (bug 1842798)
Backed out changeset 0864a23409e6 (bug 1842798)
Backed out changeset 98a1aa86513d (bug 1842798)
2023-08-02 14:58:13 +03:00
Jon Coppeard
7378829120 Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-02 09:34:39 +00:00
Tom Schuster
ecff00a7ba Bug 1843002 - Add parser-metadata to ScriptFetchOptions. r=allstarschh,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183366
2023-07-21 17:28:02 +00:00
Tom Schuster
936032fed3 Bug 1843002 - Add nonce to ScriptFetchOptions. r=allstarschh,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183365
2023-07-21 17:28:02 +00:00
Stanca Serban
70ab9b117e Backed out 6 changesets (bug 1313937, bug 1843066, bug 1843002) for causing build bustages in ScriptLoadRequest.h. CLOSED TREE
Backed out changeset 84c2d1c04aa2 (bug 1313937)
Backed out changeset 7cab9a1ea25f (bug 1313937)
Backed out changeset affc7d1f130d (bug 1313937)
Backed out changeset e13aacfe7944 (bug 1843066)
Backed out changeset 21a9bee8f772 (bug 1843002)
Backed out changeset d381b6365111 (bug 1843002)
2023-07-21 17:41:04 +03:00
Tom Schuster
593c5e731b Bug 1843002 - Add parser-metadata to ScriptFetchOptions. r=allstarschh,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183366
2023-07-21 12:31:23 +00:00
Tom Schuster
9df91ffb4d Bug 1843002 - Add nonce to ScriptFetchOptions. r=allstarschh,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183365
2023-07-21 12:31:22 +00:00
Natalia Csoregi
87dee095ca Backed out 6 changesets (bug 1842798) for causing failures on js/src/tests/test262/language/*. CLOSED TREE
Backed out changeset 38669a2ddad9 (bug 1842798)
Backed out changeset 5dad4aeacd53 (bug 1842798)
Backed out changeset 23d10eb8f853 (bug 1842798)
Backed out changeset 946e4dfe5452 (bug 1842798)
Backed out changeset 1b89736a463f (bug 1842798)
Backed out changeset b2e6bdd781ac (bug 1842798)
2023-07-17 20:52:18 +03:00
Jon Coppeard
3aab0ac6ba Bug 1842798 - Part 3: Remove unused event target from ModuleLoaderBase r=smaug
This was previously used by MozPromise but is no longer required.

Differential Revision: https://phabricator.services.mozilla.com/D183586
2023-07-17 12:44:19 +00:00
Jon Coppeard
3d87996a4b Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-07-17 12:44:18 +00:00
Yoshi Cheng-Hao Huang
77132d9570 Bug 1833503 - Add ref to ScriptLoaderRunnable. r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D181214
2023-06-19 20:26:52 +00:00
Yoshi Cheng-Hao Huang
28412ca66f Bug 1822699 - Use credentials="same origin" for dynamic import scripts in a classic worker script. r=jonco
HostLoadImportedModule,
https://html.spec.whatwg.org/multipage/webappapis.html#hostloadimportedmodule

<spec>
6. If referrer is a Script Record or a Module Record, then:
   3. Set fetchOptions to the descendant script fetch options for
      referencingScript's fetch options.
</spec>

And the referencingScript can be either:
  - a classic worker script.
  - a module worker script.

For the classic worker script, its fetch options are defined in
'fetch a classic worker script'
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script
See the algorithm processResponseConsumeBody

  <spec>
  5. Let script be the result of creating a classic script using
     source text, script settings object, response's URL, and the
     default classic script fetch options.
  </spec>

  Default classic script fetch options
  https://html.spec.whatwg.org/multipage/webappapis.html#default-classic-script-fetch-options

  <spec>
  The default classic script fetch options are a script fetch options
  whose ... credentials mode is "same-origin", ....
  </spec>

For the module worker script, its fetch options are defined in
'fetch a worklet/module worker script graph'

https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph

<spec>
1. Let options be a script fetch options whose ... credentials mode is
   _credentials mode_ ...
</spec>

where _credentials mode_ is provided when a worklet or a module worker
is created.

Differential Revision: https://phabricator.services.mozilla.com/D180088
2023-06-07 07:54:56 +00:00
Eden Chuang
f4a08bbee6 Bug 1800659 - P2 remove nsICancelableRunnable inheriting form WorkerRunnable. r=asuth
This patch is only remove the inheriting, but keeping Cancel() implmentation.
The Cancel() is needed in some special cases, such as Worker enters Canceling when WorkerScope is not created.

Depends on D176915

Differential Revision: https://phabricator.services.mozilla.com/D173850
2023-06-06 06:36:50 +00:00
Yoshi Cheng-Hao Huang
58e5abe947 Bug 1831585 - Update request's referrerPolicy if it's empty. r=jonco
For the top-level worker module script,
its referrer policy is empty by default,
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph

<spec>
Step 1. Let options be a script fetch options whose ...<ommitted> referrer policy is the empty string <omitted>....
</spec>

After the top-level worker module script is fetched, worker will update
the referrer policy according to the HTTP response header.

https://html.spec.whatwg.org/multipage/workers.html#run-a-worker
<spec>
Step 14.3.2. Initialize worker global scope's policy container given worker global scope, response, and inside settings.
</spec>

https://html.spec.whatwg.org/multipage/browsers.html#initialize-worker-policy-container
<spec>
Step 2. Otherwise, set workerGlobalScope's policy container to the result of creating a policy container from a fetch response given response and environment.
</spec>

https://html.spec.whatwg.org/multipage/browsers.html#creating-a-policy-container-from-a-fetch-response
<spec>
Step 5. Set result's referrer policy to the result of parsing the `Referrer-Policy` header given response. [REFERRERPOLICY]
</spec>

At this moment, the referrer policy of the WorkerGlobalScope's policy container has been updated.

Now when the worker script is doing a dynamic import.

https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-import-calls
<spec>
Step 1. Let referrer be GetActiveScriptOrModule().
..
Step 8. Perform HostLoadImportedModule(referrer, specifierString, empty, promiseCapability).
</spec>

https://html.spec.whatwg.org/multipage/webappapis.html#hostloadimportedmodule
<spec>
Step 6. If referrer is a Script Record or a Module Record, then:
  Step 1. Set referencingScript to referrer.[[HostDefined]].
  ...
  Step 3. Set fetchOptions to the descendant script fetch options for referencingScript's fetch options.
</spec>

So the dynamic imported script will inherit the referrer policy from the
worker module script's fetch options, which is the empty script by default.

Then to the fetch part.
According to the fetch spec:
https://fetch.spec.whatwg.org/#concept-main-fetch
<spec>
Step 8. If request’s referrer policy is the empty string, then set request’s referrer policy to request’s policy container’s referrer policy.
</spec>

Our fetch implementation does implement this,
https://searchfox.org/mozilla-central/rev/2d678a843ceab81e43f7ffb83212197dc10e944a/dom/fetch/FetchDriver.cpp#732

However, our worker doesn't use Fetch API so we have to update referrer
policy in worker's ScriptLoader.

Differential Revision: https://phabricator.services.mozilla.com/D178784
2023-05-24 15:10:01 +00:00
Artur Iunusov
57309ebbbf Bug 1646034 - Service workers can reveal script base URL due to dynamic import(), r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D175773
2023-04-22 20:34:49 +00:00
Yoshi Cheng-Hao Huang
3a75d9ad12 Bug 1829001 - Update comments in WorkerScriptLoader. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D175950
2023-04-21 21:05:54 +00:00
Yoshi Cheng-Hao Huang
1a3fee6081 Bug 1828130: r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D175912
2023-04-21 08:05:44 +00:00
Yoshi Cheng-Hao Huang
ae3bdd69fe Bug 1824498 - Call shutdown when there isn't any ongoing fetching modules. r=jonco
In the test file, worker_bug1824498.mjs, it imports two module scripts,
"foo" and "bar", both are invalid specifiers.

The ModuleLoadRequest of "foo" will be canceled, which in turn will:
1. Cancel all imports of the parent ModuleLoadRequest (worker_bug1824498.mjs)
2. Cancel the ModuleLoadRequest of "bar".

After the step 1, WorkerModuleLoader::OnModuleLoadComplete will be
called, and will shutdown the script loader.

The shutdown causes two problems:
1. When step 2 is executed, it will reject the mReady promise in
ModuleLoadRequest, however when the MozPromise is dispatched, its event
target has been shutdown so an assertion failure is triggered.

2. Also when the ScriptLoaderRunnable of "bar" is received, it also
triggers the assertion failure of the valid SyncLoopEventTarget.

To fix the problem, we delay the shutdown until there's no ongoing module
requests.

Differential Revision: https://phabricator.services.mozilla.com/D175476
2023-04-20 17:41:47 +00:00
Yulia
9bcfe3edd9 Bug 1824803; r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D174100
2023-04-14 16:26:01 +00:00
Alexandre Poirot
625273f385 Bug 1816933 - [devtools] Force loading the debugger worker script as "classic". r=yulia,devtools-reviewers,bomsy,nchevobbe
This prevents loading the debugger script the same way the worker is loaded.
So prevent loading it as ES Module when the worker is using ES Module.

Differential Revision: https://phabricator.services.mozilla.com/D173257
2023-03-28 12:32:58 +00:00
Artur Iunusov
7d615f3055 Bug 1819626: Enforce strict MIME type checks for worker-imported scripts, r=smaug
This patch introduces a new pref:
dom.workers.importScripts.enforceStrictMimeType

which is enabled by default on Nightly

see: https://github.com/whatwg/html/issues/8869,
https://github.com/whatwg/html/pull/4001

Differential Revision: https://phabricator.services.mozilla.com/D173149
2023-03-24 17:19:31 +00:00
Emilio Cobos Álvarez
91e6e4c5d4 Bug 1823686 - Share URLExtraData between SVG attribute mapping and style attribute. r=smaug
I don't think there's ever a way these should differ.

Got some include hell from removing ReferrerInfo.h from Document.h but
hopefully should be straight-forward to review.

Depends on D173154

Differential Revision: https://phabricator.services.mozilla.com/D173155
2023-03-22 14:54:43 +00:00
Yulia
702c6fab1b Bug 1540913 - Part 6-a: Fix BaseURL for importScripts; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D171875
2023-03-14 18:16:32 +00:00
Yulia Startsev
b8d4d67ca2 Bug 1540913 - Part 6: Implement Dynamic import for workers; r=jonco
This is the final change for dynamic imports, and makes the necessary modifications to properly load
them.

Differential Revision: https://phabricator.services.mozilla.com/D169629
2023-03-14 18:16:32 +00:00
Yulia
f7fd7ba054 Bug 1540913 - Part 5: Track ScriptLoaders on WorkerLoadContext; r=jonco
As mentioned in the previous patch, this patch introduces tracking and shutdown of scriptloaders in
the case that we have multiple scriptloaders involved in module loading.

Differential Revision: https://phabricator.services.mozilla.com/D171686
2023-03-14 18:16:32 +00:00
Yulia
0350774d47 Bug 1540913 - Part 4: Introduce WorkerScriptLoader configuration for dynamic import; r=jonco
Earlier, we introduced GetBaseURI to the module loader. This allows us to get the BaseURI for a
dynamic import even after the importing script/module's ScriptLoader has been cleaned up. However,
we now need to be able to handle the case where we need to run the dynamic import and load it. In
order to do this, we need to create a scriptloader configured for dynamic import. The most important
difference between this scriptloader and the one that is normally used for script loading in workers
is that we *do not have a syncLoopTarget* to which we return. There are a couple of reasons for
this:

* Dynamic import (and modules in general) relies on the event loop to resolve. If we create a
syncLoop here, we will end up pausing execution, and this breaks the StartModuleLoad algorithm. We
will never complete and the result will be that we are in the wrong state when we return here.
* We do not have perfect knowledge of the future, so we cannot keep the existing script loader alive
in the case that it might be used for loading in the future.
* We cannot migrate the ModuleLoader to not use sync loading without significantly changing other
aspects of how loading scripts on workers works. This becomes particularily evident with error
handling
(https://searchfox.org/mozilla-central/rev/00ea1649b59d5f427979e2d6ba42be96f62d6e82/dom/workers/WorkerPrivate.cpp#383-444),
and in addition, for reasons I wasn't able to discern, using the CurrentEventTarget results in hard
to identify errors. When there is time to investigate this fully, the ModuleLoader may move away
from using a syncLoop itself.

For now, all main-script loads (whether they are modules or classic scripts) will use the sync loop,
and all dynamic imports will create a new script loader for their needs that is not using the sync
loop. The book keeping for this is in the next patch.

Differential Revision: https://phabricator.services.mozilla.com/D171685
2023-03-14 18:16:31 +00:00