Commit graph

569 commits

Author SHA1 Message Date
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
Yulia Startsev
e6d68fc585 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-14 09:04:59 +00:00
Marian-Vasile Laza
2b10b4cf84 Backed out 4 changesets (bug 1805676) for wpt failures on shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 95d1e02df42c (bug 1805676)
Backed out changeset 79f32abb379d (bug 1805676)
Backed out changeset 2d35363f5937 (bug 1805676)
Backed out changeset b173c8e2beba (bug 1805676)
2023-02-13 21:14:00 +02:00
Yulia Startsev
a3e98a92c7 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 16:09:46 +00:00
Stanca Serban
35c5dff6e9 Backed out 4 changesets (bug 1805676) for causing wpt failures in /workers/modules/shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 3d943ee00682 (bug 1805676)
Backed out changeset 34da8cbd7db2 (bug 1805676)
Backed out changeset 1573d31341db (bug 1805676)
Backed out changeset 212f36c3a9e0 (bug 1805676)
2023-02-13 10:41:28 +02:00
Yulia Startsev
fad5626a3b Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 07:35:59 +00:00
Yulia Startsev
b151bd5373 Bug 1812628 - put worker modules behind a flag; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D168129
2023-02-01 15:30:15 +00:00
Norisz Fay
b9628b7cd5 Backed out 2 changesets (bug 1812628) for causing wpt failures on pointerevent_pointerrawupdate_in_pointerlock.html CLOSED TREE
Backed out changeset da2c075d4524 (bug 1812628)
Backed out changeset cc6317f62e54 (bug 1812628)
2023-02-01 00:09:29 +02:00
Yulia Startsev
570e58e395 Bug 1812628 - put worker modules behind a flag; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D168129
2023-01-31 15:24:03 +00:00
Yulia Startsev
1c5ad3e91d Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2023-01-18 13:46:33 +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
84728b24c9 Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2023-01-18 13:46:32 +00:00
Yulia Startsev
99b0e5f9bb Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2023-01-18 13:46:31 +00:00
Yulia Startsev
221fd06fcd Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2023-01-18 13:46:31 +00:00
Yulia Startsev
51e7e0e857 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2023-01-18 13:46:30 +00:00
Yulia Startsev
24d2db5bf6 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2023-01-18 13:46:30 +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
Jan Varga
72d9bf2d41 Bug 1808685 - Don't use SerialEventTargetGuard in workers code for now; r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D166048
2023-01-06 03:11:16 +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
dcbacd54c8 Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2022-12-20 20:56:15 +00: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
e35e35d3c0 Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2022-12-20 20:56:14 +00:00
Yulia Startsev
d625cafe6f Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2022-12-20 20:56:13 +00:00
Yulia Startsev
a0b8b2351c Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2022-12-20 20:56:13 +00:00
Yulia Startsev
83dd3f6844 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2022-12-20 20:56:13 +00:00
Yulia Startsev
85669b74b0 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2022-12-20 20:56:12 +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
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
Jan Varga
650c726cb3 Bug 1803062 - GetCurrentSerialEventTarget should return the nested event target when a sync loop is running; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163841
2022-12-15 05:15:31 +00:00
Yulia Startsev
4916e53611 Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2022-12-14 14:55:38 +00: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
904f7c679e Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2022-12-14 14:55:37 +00:00
Yulia Startsev
5ac66699bc Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2022-12-14 14:55:36 +00:00
Yulia Startsev
d3ca0aecd0 Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2022-12-14 14:55:36 +00:00
Yulia Startsev
3d4f58ac76 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2022-12-14 14:55:35 +00:00
Yulia Startsev
33b96ee278 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2022-12-14 14:55:35 +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
Yulia
4763aa8e30 Bug 1247687 - Call EnsureAndLoadStringBundle from Worker ScriptLoaderRunnable; r=allstarschh
Depends on D163238

Differential Revision: https://phabricator.services.mozilla.com/D163239
2022-12-14 14:55:33 +00:00
Stanca Serban
591b091f05 Backed out changeset 6499b9cc1cfc (bug 1803062) for causing worker related failures. CLOSED TREE 2022-12-13 10:21:29 +02:00
Jan Varga
1b5145d00f Bug 1803062 - GetSerialEventTarget should return the nested event target when a sync loop is running; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163841
2022-12-13 04:56:35 +00:00
Nika Layzell
8351f7cc2d Bug 1804093 - Part 5: Eliminate WorkerPrincipal and WorkletPrincipals, r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163856
2022-12-12 22:08:36 +00:00