Commit graph

227 commits

Author SHA1 Message Date
Tom Schuster
115b5bd777 Bug 1843066 - Provide the nonce for speculative <script> preloads. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183390
2023-07-21 17:28:02 +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
0935ddb561 Bug 1843066 - Provide the nonce for speculative <script> preloads. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183390
2023-07-21 12:31:23 +00: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
Tooru Fujisawa
dbc77b97e8 Bug 1837964 - Part 2: Use UniquePtr with explicit free policy in ScriptLoader::{ConvertToUTF16,ConvertToUTF8} and their consumers. r=smaug
Remove raw pointer variant of ScriptLoader::{ConvertToUTF16,ConvertToUTF8} to
make it clearer how the buffer is allocated and how it should be freed.

The consumer in ServiceWorkerScriptCache expects the buffer allocated with
malloc, but given js_malloc and malloc are identical in browser, it also
uses JS::FreePolicy.

Differential Revision: https://phabricator.services.mozilla.com/D181204
2023-07-06 09:37:18 +00:00
Em Zhan
b6b6fe577b Bug 1798319 - Implement modulepreload in early hints r=manuel,smaug,necko-reviewers,kershaw
The aEarlyHintPreloaderId parameter for StartLoad/StartLoadInternal is changed
to be a member variable of ScriptLoadRequest instead so that an initiator type
of early hints can be set for module requests. Before, ModuleLoader would always
pass in a zero value for the id since ModuleLoaderBase has no concept of early
hints when it calls StartFetch.

As a prerequisite for early hints support, this commit also implements
modulepreload in link headers (Bug 1773056).

Differential Revision: https://phabricator.services.mozilla.com/D180020
2023-06-26 10:49:53 +00:00
Adam Vandolder
61ffa36c9d Bug 1827512 - Properly handle type and src attribute changes on script tags. r=smaug
Modifies the preparation of script tags in order to better follow the
specification. Now, scripts are only considered to have already started
if they have a valid type when being prepared, and only changes to the
src attribute trigger script preparation, instead of for all attributes.
This allows script tags to be re-run after their type and src are
modified, if they haven't run already.

Differential Revision: https://phabricator.services.mozilla.com/D175795
2023-06-14 04:00:09 +00:00
Sean Feng
b32e4554a9 Bug 1804086 - Allow classic script hint to be passed from content to parent r=smaug,necko-reviewers,kershaw
This is needed for doing content decoding for ORB.

Differential Revision: https://phabricator.services.mozilla.com/D172490
2023-03-22 14:21:39 +00:00
Noemi Erli
b4fa013c2d Backed out 3 changesets (bug 1804086) for causing failures in JSValidatorChild.cpp CLOSED TREE
Backed out changeset 12a40a80a975 (bug 1804086)
Backed out changeset 1bea9ea5e20d (bug 1804086)
Backed out changeset 00feb14e7824 (bug 1804086)
2023-03-22 03:33:43 +02:00
Sean Feng
078281d4c2 Bug 1804086 - Allow classic script hint to be passed from content to parent r=smaug,necko-reviewers,kershaw
This is needed for doing content decoding for ORB.

Differential Revision: https://phabricator.services.mozilla.com/D172490
2023-03-21 22:55:08 +00:00
Jon Coppeard
08b9729ccf Bug 1813494 - Part 1: Common up code to cancel and remove all load requests r=smaug
Cancellation happend in ParsingComplete() and Destroy() but was inconsistent in
which kinds of requests were cancelled and which were cancelled and removed.
This makes one method that cancels and removes everything and uses it in both
places.

Differential Revision: https://phabricator.services.mozilla.com/D168231
2023-02-07 11:55:50 +00:00
Jon Coppeard
58aee4e76a Bug 1809861 - Part 3: Reorder off-thread compilation methods r=smaug
This just moves the method definitions so that they appear in roughly in the
order they are executed, to make reading and understanding this easier.

Differential Revision: https://phabricator.services.mozilla.com/D166669
2023-01-17 17:06:51 +00:00
Jon Coppeard
2def9365b7 Bug 1809861 - Part 2: Rename off-thread compilation methods to improve consistency r=smaug
This renames the following in an attempt to give consistent names to off-thread
compliation related things:
 - AttemptAsyncScriptCompile -> AttemptOffThreadScriptCompile
 - NotifyOffThreadScriptLoadCompletedRunnable -> OffThreadJobCompleteRunnable
 - OffThreadScriptLoaderCallback -> OffThreadJobCompleteCallback

Differential Revision: https://phabricator.services.mozilla.com/D166668
2023-01-17 17:06:50 +00:00
Jon Coppeard
9041daf265 Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r=smaug
The main change in this patch is to prevent access to main-thread objects
while off-thread. This is done by using nsMainThreadPtrHandle to wrap main
thread pointers in the runnable. This prevents access to their targets when
off thread and ensure they are only released on the main thread.

This means that mRunnable is now only accessed on the main thread and so it
doesn't need to be atomic and can be a normal RefPtr. We also don't need to
leak a reference to it in AttemptOffThreadScriptCompile.

This also requires that timing data is moved to the runnable.

Cancellation should always have happened by unlink or destruction of
ScriptLoadContext so handling for that is removed.

Differential Revision: https://phabricator.services.mozilla.com/D166667
2023-01-17 17:06:50 +00:00
Stanca Serban
6a0d860e76 Backed out 3 changesets (bug 1809861) for causing bustages in ScriptLoader.cpp. CLOSED TREE
Backed out changeset d8b7cb85d87f (bug 1809861)
Backed out changeset fa4190d9f97e (bug 1809861)
Backed out changeset 15b4b4f318a7 (bug 1809861)
2023-01-17 17:56:26 +02:00
Jon Coppeard
9de78f79c8 Bug 1809861 - Part 3: Reorder off-thread compilation methods r=smaug
This just moves the method definitions so that they appear in roughly in the
order they are executed, to make reading and understanding this easier.

Differential Revision: https://phabricator.services.mozilla.com/D166669
2023-01-17 14:37:07 +00:00
Jon Coppeard
8faf8ae204 Bug 1809861 - Part 2: Rename off-thread compilation methods to improve consistency r=smaug
This renames the following in an attempt to give consistent names to off-thread
compliation related things:
 - AttemptAsyncScriptCompile -> AttemptOffThreadScriptCompile
 - NotifyOffThreadScriptLoadCompletedRunnable -> OffThreadJobCompleteRunnable
 - OffThreadScriptLoaderCallback -> OffThreadJobCompleteCallback

Differential Revision: https://phabricator.services.mozilla.com/D166668
2023-01-17 14:37:07 +00:00
Jon Coppeard
62c190d44c Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r=smaug
The main change in this patch is to prevent access to main-thread objects
while off-thread. This is done by using nsMainThreadPtrHandle to wrap main
thread pointers in the runnable. This prevents access to their targets when
off thread and ensure they are only released on the main thread.

This means that mRunnable is now only accessed on the main thread and so it
doesn't need to be atomic and can be a normal RefPtr. We also don't need to
leak a reference to it in AttemptOffThreadScriptCompile.

This also requires that timing data is moved to the runnable.

Cancellation should always have happened by unlink or destruction of
ScriptLoadContext so handling for that is removed.

Differential Revision: https://phabricator.services.mozilla.com/D166667
2023-01-17 14:37:06 +00:00
Ted Campbell
a188b7fd3e Bug 1806169 - Add ScriptLoader::ConvertToUTF8 overload r=jonco
Similar to the ConvertToUTF16 overload for JS owned strings, add an overload for
the UTF8 case. This simplifies later work to switch parsing to UTF8.

Differential Revision: https://phabricator.services.mozilla.com/D164930
2022-12-23 21:26:25 +00:00
Manuel Bucher
7681efff11 Bug 1771867 - Early Hints Phase 2 - Part 5: Pass early hint preload to script preloader r=necko-reviewers,valentin
Note that modules can't be specified in Link preloads with `rel=preload`,
only in `rel=modulepreload`.  We currently only support `rel=preload` in
early hints. See Bug 1798319 for updates on module preloads.

Differential Revision: https://phabricator.services.mozilla.com/D161175
2022-12-02 16:15:54 +00:00
Csoregi Natalia
5a260d61a4 Backed out 13 changesets (bug 1771867) for causing CanonicalBrowsingContext crashes. CLOSED TREE
Backed out changeset 120838b58449 (bug 1771867)
Backed out changeset aea7ca0bbd17 (bug 1771867)
Backed out changeset 2fe2afdee09d (bug 1771867)
Backed out changeset 8bdb1f682d22 (bug 1771867)
Backed out changeset a9f3158ed688 (bug 1771867)
Backed out changeset 1177913e1edf (bug 1771867)
Backed out changeset d33ccbbf407d (bug 1771867)
Backed out changeset 110ac12e16f5 (bug 1771867)
Backed out changeset 7f20525f5e94 (bug 1771867)
Backed out changeset b3d65b1aa872 (bug 1771867)
Backed out changeset 7cdf3cef2773 (bug 1771867)
Backed out changeset 5090eae24a5c (bug 1771867)
Backed out changeset f8a03d226c73 (bug 1771867)
2022-12-02 13:44:55 +02:00
Manuel Bucher
4ec279d231 Bug 1771867 - Early Hints Phase 2 - Part 5: Pass early hint preload to script preloader r=necko-reviewers,valentin
Note that modules can't be specified in Link preloads with `rel=preload`,
only in `rel=modulepreload`.  We currently only support `rel=preload` in
early hints. See Bug 1798319 for updates on module preloads.

Differential Revision: https://phabricator.services.mozilla.com/D161175
2022-12-02 09:45:25 +00:00
Jon Coppeard
bccb7ef6f3 Bug 1788532 - Block dynamic module load processing during sync XHR r=smaug
The problem is that synchronous XMLHttpRequest requests can spin the event loop
and cause us to process dynamic module loads (by calling
JS::FinishDynamicModuleImport) when we are already inside JS::ModuleEvaluate.
The module algorithms assume that they are not reentrant.

The patch changes dyammic module load processing to happen in the same way as
async script loads (of both classic scripts and modules), which are blocked
during sync XHR by Document::SuppressEventHandling calling
ScriptLoader::AddExecuteBlocker.

Differential Revision: https://phabricator.services.mozilla.com/D157218
2022-09-15 09:14:11 +00:00
Dianna Smith
54494382c7 Backed out 1 changesets (bug 1776205) for causing bug 1780426, a=backout
Backed out changeset 84c72c2fbfd6 (bug 1776205)
2022-07-26 14:34:59 -04:00
Dianna Smith
27fbc1c20a Backed out 1 changesets (bug 1776668) for causing bug 1780426, a=backout
Backed out changeset f3cd67fc1a50 (bug 1776668)
2022-07-26 14:30:18 -04:00
Nicolas B. Pierron
03fbdc6ade Bug 1776668 - ApplyDelazifyStrategy: Skip inline script sooner. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D152091
2022-07-19 10:41:16 +00:00
Nicolas B. Pierron
49f29dc411 Bug 1776205 - Set the delazify option in all ScriptLoader code paths. r=arai
This patch move the ShouldApplyDelazificationStartegy as well as the
ApplyDelazificationStrategy under FillCompileOptionsForRequest.

As not all delazification strategies are capable of handling modules yet (Bug
1760334), and do not apply to cached-stencil, we have to add extra filters to
prevent ShouldApplyDelazificationStrategy to access custom delazification mode.

Differential Revision: https://phabricator.services.mozilla.com/D150118
2022-07-08 13:19:30 +00:00
Matthew Gaudet
cc218be0b6 Bug 1747059 - Add ShadowRealm module loader support to ScriptLoader r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D147465
2022-06-28 22:04:18 +00:00
Csoregi Natalia
a6c7516d80 Backed out 9 changesets (bug 1747059, bug 1767525)for causing hazard failures on ShadowRealmGlobalScope.cpp. CLOSED TREE
Backed out changeset ed7aad37f2cf (bug 1747059)
Backed out changeset 40a257fb4788 (bug 1747059)
Backed out changeset f7b049ef3b8c (bug 1747059)
Backed out changeset aad38abc7139 (bug 1747059)
Backed out changeset 8115813e77a5 (bug 1747059)
Backed out changeset e06192e664fd (bug 1747059)
Backed out changeset a198b0893220 (bug 1767525)
Backed out changeset c083f0824619 (bug 1767525)
Backed out changeset 9a3bf794ec6d (bug 1767525)
2022-06-28 02:39:08 +03:00
Matthew Gaudet
c940e88de9 Bug 1747059 - Add ShadowRealm module loader support to ScriptLoader r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D147465
2022-06-27 21:17:35 +00:00
Jon Coppeard
1e506ccabd Bug 1767829 - Part 2: Give ScriptLoaderInterface a virtual destructor r=yulia
Classes with virtual methods should have a virtual destructor so deleting an
object through a base class pointer works correctly. I think I got lint
warnings about this when I added a new derived loader.

Differential Revision: https://phabricator.services.mozilla.com/D145489
2022-05-09 11:06:25 +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
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
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
Yulia Startsev
f1dd84285f Bug 1763372 - Add LoadContextBase; r=jonco,smaug
Differential Revision: https://phabricator.services.mozilla.com/D143036
2022-04-22 13:24:09 +00:00
Jon Coppeard
8907766025 Bug 1761938 - Part 6: Remove global from script load context r=smaug,yulia
This removes the global object field from the script load context and gets the
global from the script loader / module loader where necessary.

Differential Revision: https://phabricator.services.mozilla.com/D142833
2022-04-11 15:35:30 +00:00
Jon Coppeard
3b308851b4 Bug 1761938 - Part 5: Use module loader's global where possible and remove GetGlobalForRequest from script loader interface r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D142832
2022-04-11 15:35:30 +00:00
Jon Coppeard
d4aae71cf3 Bug 1761938 - Part 4: Give module loaders a global object field r=smaug,yulia
This gives the module loader a field for the current global, since a module map
is only associated with a single global.

This adds a method to Document to tell the script loader when its global
changes. I'm not sure of when we do this exactly.

Differential Revision: https://phabricator.services.mozilla.com/D142831
2022-04-11 15:35:29 +00:00
Jon Coppeard
88d0d67d61 Bug 1761938 - Part 2: Give each web extension content script global its own module loader r=smaug,yulia
This gives the DOM module loader a kind and records content script module
loaders in an array on the script loader.

Differential Revision: https://phabricator.services.mozilla.com/D142829
2022-04-11 15:35:28 +00:00
Jon Coppeard
3570cedee9 Bug 1759881 - Part 3: Don't pass a global to FillCompileOptionsForRequest r=yulia
This can work it out if it needs it by calling GetGlobalForRequest.

Depends on D141249

Differential Revision: https://phabricator.services.mozilla.com/D141250
2022-03-17 15:22:17 +00:00
Tooru Fujisawa
c963262d5c Bug 1436400 - Part 8: Add code path for bytecode encoding module scripts. r=nbp
The module scripts are scanned immediately before executing, and if the
module script is not yet executed, and it matches the requirement for encoding
(size, fetch count, etc), it's marked as encode,
and they're scanned again immediately after executing, and marked scripts are
queued for bytecode encoding.

This patch doesn't actually enable the encoding, given ShouldCacheBytecode
returns false because the caching is not enabled for the channel and
GetCacheTokenFetchCount fails.

Differential Revision: https://phabricator.services.mozilla.com/D140296
2022-03-15 19:05:56 +00:00
Tooru Fujisawa
1f7d1985f5 Bug 1436400 - Part 7: Split ScriptLoader::MaybePrepareForBytecodeEncoding into 2 parts. r=nbp
As a preparation to use the bytecode encoding in the module evaluation code,
ScriptLoader::MaybePrepareForBytecodeEncoding is split into 2 parts:
  * one for performing preparation before executing script
  * one for queuing the request for bytecode encoding after executing script

In module's case, the bytecode encoding handling must be done on the entire
import tree, and also the module object's ScriptSlot is cleared on execution.
So, the script reference must be copied to the corresponding script load request
field before execution, and the script source must be queued for bytecode
encoding after executing the top-level script, so that incremental encoding
reflects functions called there.

Differential Revision: https://phabricator.services.mozilla.com/D140295
2022-03-15 19:05:56 +00:00
Tooru Fujisawa
0aaa5686d0 Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp
Module bytecode should use different MIME type, to avoid mixing up script/module
bytecodes for single JS file.

This patch adds a static method that simply returns the current bytecode MIME
type.
The later patch adds a new MIME type for module bytecode and modify the
ScriptLoader::BytecodeMimeTypeFor method to return corresponding MIME type.

Differential Revision: https://phabricator.services.mozilla.com/D140292
2022-03-15 19:05:55 +00:00
Csoregi Natalia
6ae31a2e64 Backed out 15 changesets (bug 1757597, bug 1436400) for causing mochitest failures on test_bug1656248.html. CLOSED TREE
Backed out changeset 4be29c1eb5bc (bug 1436400)
Backed out changeset ffd9ddcef6b0 (bug 1436400)
Backed out changeset 5ac844508d8b (bug 1436400)
Backed out changeset 561aeb550892 (bug 1436400)
Backed out changeset 6f473bcf809a (bug 1436400)
Backed out changeset c33620854115 (bug 1436400)
Backed out changeset 8f894ea40eb2 (bug 1436400)
Backed out changeset cce080064d82 (bug 1436400)
Backed out changeset 001d8528ff96 (bug 1436400)
Backed out changeset dd2bb1b46f75 (bug 1436400)
Backed out changeset b1c2084042fa (bug 1436400)
Backed out changeset dd0fea93bcd7 (bug 1436400)
Backed out changeset e38a959648e1 (bug 1436400)
Backed out changeset 40b474d430e9 (bug 1436400)
Backed out changeset 5bef21ef1ba2 (bug 1757597)
2022-03-15 07:23:29 +02:00
Tooru Fujisawa
bd3852013b Bug 1436400 - Part 8: Add code path for bytecode encoding module scripts. r=nbp
The module scripts are scanned immediately before executing, and if the
module script is not yet executed, and it matches the requirement for encoding
(size, fetch count, etc), it's marked as encode,
and they're scanned again immediately after executing, and marked scripts are
queued for bytecode encoding.

This patch doesn't actually enable the encoding, given ShouldCacheBytecode
returns false because the caching is not enabled for the channel and
GetCacheTokenFetchCount fails.

Differential Revision: https://phabricator.services.mozilla.com/D140296
2022-03-15 04:24:51 +00:00