Commit Graph

96 Commits

Author SHA1 Message Date
Tooru Fujisawa
84727f2cc6 Bug 1916635 - Part 1: Create PerformanceResourceTiming entry for SharedScriptCache. r=bthrall
Differential Revision: https://phabricator.services.mozilla.com/D223357
2024-10-01 12:17:26 +00:00
Tooru Fujisawa
adec9d4fda Bug 1907009 - Part 1: Add CacheExpirationTime type. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D217957
2024-08-06 05:38:23 +00:00
Tooru Fujisawa
3f46be92f0 Bug 1896709 - Part 13: Use SharedSubResourceCache in ScriptLoader. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215882
2024-07-18 21:58:14 +00:00
Tooru Fujisawa
dd9a53aa0d Bug 1896709 - Part 9: Add ScriptLoadRequest::CacheEntryFound. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215878
2024-07-18 21:58:13 +00:00
Tooru Fujisawa
c6a331f334 Bug 1896709 - Part 5: Add ScriptLoadRequest::IsCacheable. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215874
2024-07-18 21:58:11 +00:00
Tooru Fujisawa
16292d50d1 Bug 1896709 - Part 4: Accumulate cache expiration time in script load. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215873
2024-07-18 21:58:11 +00:00
Tooru Fujisawa
321fa48d05 Bug 1896709 - Part 2: Add const variant of ScriptLoadRequest::GetScriptLoadContext. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215871
2024-07-18 21:58:10 +00:00
Norisz Fay
471367226c Backed out 17 changesets (bug 1896709) for causing build bustage and mochitest failures CLOSED TREE
Backed out changeset 046f0f522ce7 (bug 1896709)
Backed out changeset 0271e50308e6 (bug 1896709)
Backed out changeset 26fac760de19 (bug 1896709)
Backed out changeset 6fa3424dfc40 (bug 1896709)
Backed out changeset b7bcb9904435 (bug 1896709)
Backed out changeset c6878c5fdde4 (bug 1896709)
Backed out changeset 8ca8a4082e44 (bug 1896709)
Backed out changeset 20ff83806cc6 (bug 1896709)
Backed out changeset 6c9338852a19 (bug 1896709)
Backed out changeset e8615b5d82ab (bug 1896709)
Backed out changeset 842f2047a4bd (bug 1896709)
Backed out changeset 54eea04a7342 (bug 1896709)
Backed out changeset 220b544127cb (bug 1896709)
Backed out changeset 52ce0ebfb29a (bug 1896709)
Backed out changeset 34fc79dc1ad7 (bug 1896709)
Backed out changeset 50b0f6a23e3c (bug 1896709)
Backed out changeset 89c4c6bb465a (bug 1896709)
2024-07-18 14:48:46 +03:00
Tooru Fujisawa
309452cddc Bug 1896709 - Part 13: Use SharedSubResourceCache in ScriptLoader. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215882
2024-07-18 09:15:28 +00:00
Tooru Fujisawa
2d77dfea62 Bug 1896709 - Part 9: Add ScriptLoadRequest::CacheEntryFound. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215878
2024-07-18 09:15:26 +00:00
Tooru Fujisawa
500c12673d Bug 1896709 - Part 5: Add ScriptLoadRequest::IsCacheable. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215874
2024-07-18 09:15:25 +00:00
Tooru Fujisawa
99e7436687 Bug 1896709 - Part 4: Accumulate cache expiration time in script load. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215873
2024-07-18 09:15:24 +00:00
Tooru Fujisawa
8e816052eb Bug 1896709 - Part 2: Add const variant of ScriptLoadRequest::GetScriptLoadContext. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D215871
2024-07-18 09:15:24 +00:00
Tooru Fujisawa
599af2d7d2 Bug 1899172 - Part 11: Move nsIScriptElement from ScriptFetchOptions to ScriptLoadContext. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D211912
2024-05-30 05:01:18 +00:00
Tooru Fujisawa
6e5b7d5d1b Bug 1898677 - Cache the result of bytecode encoding condition. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D211517
2024-05-27 06:31:16 +00:00
Yoshi Cheng-Hao Huang
d48c09dbea Bug 1894631 - Add CancelingImport state in ScriptLoadRequest::State. r=jonco
In the following module graph:

0.html
    +---- 1.mjs
        +---- 2.mjs (modulepreload)
            +---- 3.mjs (modulepreload)
            +---- 4.mjs
        +---- non_existing.mjs

Fetching non_existing.mjs will fail, which will notify its parent module
1.mjs with ModuleErrored(), and then 1.mjs will cancel its imports.

The sequence is as follows:
1. 1.mjs cancels 2.mjs, 2.mjs changes to Cancel state
2. 2.mjs cancels 3.mjs, 3.mjs is already preloaded, its state still remains Finished.
3. 2.mjs cancels 4.mjs, 4.mjs changes to Cancel state.

Now, 2.mjs will call ChildLoadComplete[1], which will call 1.mjs
ModuleErrored()[2] again (The 1st time is called when loading non_existing.mjs failed)

Now 1.mjs wants to cancel 2.mjs again, and 2.mjs has been canceled
previously, so it will do AssertAllImportsCanceled() check[3].

However, 3.mjs has been fetched by <modulepreload> and is in Finished
state, which triggers the assertion failure.

To fix this, I add a new state in ScriptLoadRequest::State called
CancelingImport, to fix the problem the CancelImport() call is called by
non_existing.mjs and 2.mjs.

[1]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/js/loader/ModuleLoadRequest.cpp#100
[2]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/js/loader/ModuleLoaderBase.cpp#954
[3]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/js/loader/ModuleLoadRequest.cpp#86

Differential Revision: https://phabricator.services.mozilla.com/D209218
2024-05-07 16:03:20 +00:00
Tooru Fujisawa
ae9c578ace Bug 1803810 - Part 1: Rename ComponentModuleLoader to SyncModuleLoader. r=jonco
The behavior is longer tightly associated with "component".

Differential Revision: https://phabricator.services.mozilla.com/D199453
2024-02-14 02:01:36 +00:00
Cosmin Sabou
6efefaa470 Backed out 10 changesets (bug 1803810) for xpcshell failures on test_import_global. CLOSED TREE
Backed out changeset d5df64b38425 (bug 1803810)
Backed out changeset b8f45cbb5596 (bug 1803810)
Backed out changeset c02d879622bd (bug 1803810)
Backed out changeset 9593275c0195 (bug 1803810)
Backed out changeset 2e2f01296233 (bug 1803810)
Backed out changeset 9699c18e5bf7 (bug 1803810)
Backed out changeset 84cdfd738db6 (bug 1803810)
Backed out changeset 58160b9119ef (bug 1803810)
Backed out changeset 4aa6e036fe7a (bug 1803810)
Backed out changeset 656b61cbd15c (bug 1803810)
2024-02-13 17:41:01 +02:00
Tooru Fujisawa
e39b7e1b3d Bug 1803810 - Part 1: Rename ComponentModuleLoader to SyncModuleLoader. r=jonco
The behavior is longer tightly associated with "component".

Differential Revision: https://phabricator.services.mozilla.com/D199453
2024-02-13 14:34:21 +00:00
Tooru Fujisawa
e29632369c Bug 1877596 - Use original URL as base URL for internal scheme also in worker. r=jonco,dom-storage-reviewers,janv,dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D200129
2024-02-05 01:12:24 +00:00
Nicolas B. Pierron
8de7851246 Bug 1800641 - Part 12: Move some ScriptLoadRequest fields into LoadedScript. r=nbp
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/D197921
2024-01-08 14:57:40 +00:00
Tooru Fujisawa
60ae165b14 Bug 1800641 - Part 11: Allocate script in ScriptLoadRequest::NoCacheEntryFound. r=nbp
Depends on D197848

Differential Revision: https://phabricator.services.mozilla.com/D197849
2024-01-08 14:57:40 +00:00
Tooru Fujisawa
ed418d41dd 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
ad3f8f8a06 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
9b4d6d328e 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
Tooru Fujisawa
e45786c019 Bug 1800641 - Part 6: Add ScriptLoadRequest::{,Set}ReceivedScriptTextLength. r=nbp
Depends on D197843

Differential Revision: https://phabricator.services.mozilla.com/D197844
2024-01-08 14:57:38 +00:00
Tooru Fujisawa
bcb3790794 Bug 1800641 - Part 5: Add ScriptLoadRequest::DropBytecode. r=nbp
Depends on D197842

Differential Revision: https://phabricator.services.mozilla.com/D197843
2024-01-08 14:57:37 +00:00
Tooru Fujisawa
168d0ccdd7 Bug 1800641 - Part 4: Add ScriptLoadRequest::{Get,Set}SRILength. r=nbp
Depends on D197841

Differential Revision: https://phabricator.services.mozilla.com/D197842
2024-01-08 14:57:37 +00:00
Tooru Fujisawa
929368a3f4 Bug 1800641 - Part 3: Add ScriptLoadRequest::SRIAndBytecode. r=nbp
Depends on D197840

Differential Revision: https://phabricator.services.mozilla.com/D197841
2024-01-08 14:57:36 +00:00
Tooru Fujisawa
59f39b43f5 Bug 1800641 - Part 2: Add ScriptLoadRequest::Bytecode and let JSExecutionContext::Decode receive JS::TranscodeRange. r=nbp
Depends on D197839

Differential Revision: https://phabricator.services.mozilla.com/D197840
2024-01-08 14:57:36 +00:00
Tooru Fujisawa
cac32b6d4d Bug 1800641 - Part 1: Move ScriptFetchOptions into its own file. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D197839
2024-01-08 14:57:36 +00:00
Noemi Erli
46e817bca8 Backed out changeset 4d6294424819 (bug 1800641) for causing Bug 1872347 2023-12-29 16:23:18 +02:00
Nicolas B. Pierron
7ad7f045d4 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
78d82c8098 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
d60b4bd3b1 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
Yoshi Cheng-Hao Huang
0060499938 Bug 1841859 - Part 2: Parse the referrer policy from http header and update the referrer policy. r=jonco,smaug
This implementes the following requirement from the spec:

https://html.spec.whatwg.org/#fetch-a-single-module-script

12. In both cases, let processResponseConsumeBody given response response and null, failure, or a byte sequence bodyBytes be the following algorithm:

  5. Let referrerPolicy be the result of parsing the `Referrer-Policy` header given response.
  6. If referrerPolicy is not the empty string, set options's referrer policy to referrerPolicy.

Differential Revision: https://phabricator.services.mozilla.com/D186944
2023-09-20 17:32:15 +00:00
Yoshi Cheng-Hao Huang
2b03ca80a7 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
Tooru Fujisawa
d2ffe31339 Bug 1846194 - Remove off-thread compilation and decode API. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D185125
2023-09-01 03:43:21 +00:00
Mirko Brodesser
3de23172d3 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
Gregory Pappas
f10c953ffc Bug 1842462 - Remove dom.script_loader.external_scripts.utf8_parsing.enabled and dom.worker.script_loader.utf8_parsing.enabled prefs r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D186640
2023-08-22 21:29:11 +00:00
Cosmin Sabou
70b514ed8e 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
fcb70e3246 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
1ea8eb8868 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
e0b84f81a4 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
bee296d117 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
Tom Schuster
91477557ae 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
bcfda085d6 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
b42c5eaa6a 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
320e8d0d9d 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
91054529c2 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