Commit Graph
389 Commits
Author SHA1 Message Date
Valentin Gosu cb003cfaa8 Bug 1911759 - Add triggeringPrincipal override to RequestInit r=necko-reviewers,webidl,smaug,kershaw
This allows code with Chrome priviledges to use the fetch API
to specify a triggering principal instead of needing to use
XMLHttpRequest.
The triggeringPrincipal is only used when the fetch principal
is already the systemPrincipal.

Differential Revision: https://phabricator.services.mozilla.com/D213418
2024-08-07 09:16:20 +00:00
Tom Schuster feaa0c77a1 Bug 1904004 - Use OriginAttributes::IsPrivateBrowsing instead of open coding PBM checks. r=timhuang,cookie-reviewers,anti-tracking-reviewers,profiler-reviewers,necko-reviewers,kershaw,dom-storage-reviewers,janv,canaltinova,dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D214532
2024-06-24 11:06:18 +00:00
Frédéric Wang 5b24b1b91a Bug 1881040 - Use the destination to refine the fetchpriority mapping. r=valentin
According to step 15 of [1], request’s destination is used in an
implementation-defined manner to set the internal priority but we
currently always use the preferences corresponding to the adjustments
of the global fetch API.

This patch handle destinations corresponding to CSP directives
"font-src", "script-src", "style-src", "img-src" and "media-src" [2]
specially by respectively using the adjustment preferences named
"link-preload-font", "link-preload-script", "link-preload-style"
"images" and a new preference "media".

Special handling of these destinations is motivated by the fact that
they are mentioned explicitly on [3]. For "media" we choose preferences
following the suggestions from that article (i.e. media is low
priority). However, for now we don't change the default value and make
sure fetchpriority=high/low preserves the invariants tested by
fetchpriority-adjustments.html

[1] https://fetch.spec.whatwg.org/#concept-fetch
[2] https://fetch.spec.whatwg.org/#destination-table
[3] https://web.dev/articles/fetch-priority?hl=en#browser_priority_and_fetchpriority

Differential Revision: https://phabricator.services.mozilla.com/D208467
2024-06-12 07:50:42 +00:00
Frédéric Wang 3f4b36821a Bug 1881040 - Add and propagate internal priority when copying Request. r=edenchuang
Step 12 of [1] says that internal prirority is copied by the Request
constructor so this patch adds such a member on InternalRequest and
makes sure it is copied by InternalRequest::GetRequestConstructorCopy.

Additionally, this patch also makes sure the original request's internal
priority is preserved when calling fetch(event.request) from a worker
on an intercepted fetch event (e.g. [2] for HTML images).

[1] https://fetch.spec.whatwg.org/#dom-request
[2] https://searchfox.org/mozilla-central/rev/b3f40fd7c4671537ed29a232e76c962977650045/testing/web-platform/tests/fetch/api/request/destination/fetch-destination.https.html#37

Differential Revision: https://phabricator.services.mozilla.com/D210283
2024-06-12 07:50:41 +00:00
Frédéric Wang 3dc8bbf3eb Bug 1881040 - Propagate InterceptedHttpChannel information when using PFetch. r=edenchuang
This interception information was introduced in bug 1658869 and is used
when calling fetch from the main thread. However, after bug 1351231 we
are not propagating that information when using PFetch, because it is
not copied by ToIPCInternalRequest here:
https://searchfox.org/mozilla-central/rev/14ff5b1650123600698f4bb8998ee02b102b8d2f/dom/fetch/Fetch.cpp#632

Differential Revision: https://phabricator.services.mozilla.com/D209330
2024-06-12 07:50:40 +00:00
Iulian Moraru d78c84b1d1 Backed out 6 changesets (bug 1881040) for causing base-toolchains build bustages on FetchDriver.cpp. CLOSED TREE
Backed out changeset 320a5e2465e3 (bug 1881040)
Backed out changeset 13645c9ec29b (bug 1881040)
Backed out changeset 14ac42b80c59 (bug 1881040)
Backed out changeset 4c1cf7254f78 (bug 1881040)
Backed out changeset db29da0a049a (bug 1881040)
Backed out changeset 4f99700fa668 (bug 1881040)
2024-06-11 22:42:28 +03:00
Frédéric Wang 6431f5d22c Bug 1881040 - Use the destination to refine the fetchpriority mapping. r=valentin
According to step 15 of [1], request’s destination is used in an
implementation-defined manner to set the internal priority but we
currently always use the preferences corresponding to the adjustments
of the global fetch API.

This patch handle destinations corresponding to CSP directives
"font-src", "script-src", "style-src", "img-src" and "media-src" [2]
specially by respectively using the adjustment preferences named
"link-preload-font", "link-preload-script", "link-preload-style"
"images" and a new preference "media".

Special handling of these destinations is motivated by the fact that
they are mentioned explicitly on [3]. For "media" we choose preferences
following the suggestions from that article (i.e. media is low
priority). However, for now we don't change the default value and make
sure fetchpriority=high/low preserves the invariants tested by
fetchpriority-adjustments.html

[1] https://fetch.spec.whatwg.org/#concept-fetch
[2] https://fetch.spec.whatwg.org/#destination-table
[3] https://web.dev/articles/fetch-priority?hl=en#browser_priority_and_fetchpriority

Differential Revision: https://phabricator.services.mozilla.com/D208467
2024-06-11 09:14:15 +00:00
Frédéric Wang 8daf0cf05a Bug 1881040 - Add and propagate internal priority when copying Request. r=edenchuang
Step 12 of [1] says that internal prirority is copied by the Request
constructor so this patch adds such a member on InternalRequest and
makes sure it is copied by InternalRequest::GetRequestConstructorCopy.

Additionally, this patch also makes sure the original request's internal
priority is preserved when calling fetch(event.request) from a worker
on an intercepted fetch event (e.g. [2] for HTML images).

[1] https://fetch.spec.whatwg.org/#dom-request
[2] https://searchfox.org/mozilla-central/rev/b3f40fd7c4671537ed29a232e76c962977650045/testing/web-platform/tests/fetch/api/request/destination/fetch-destination.https.html#37

Differential Revision: https://phabricator.services.mozilla.com/D210283
2024-06-11 09:14:14 +00:00
Frédéric Wang 94a917f345 Bug 1881040 - Propagate InterceptedHttpChannel information when using PFetch. r=edenchuang
This interception information was introduced in bug 1658869 and is used
when calling fetch from the main thread. However, after bug 1351231 we
are not propagating that information when using PFetch, because it is
not copied by ToIPCInternalRequest here:
https://searchfox.org/mozilla-central/rev/14ff5b1650123600698f4bb8998ee02b102b8d2f/dom/fetch/Fetch.cpp#632

Differential Revision: https://phabricator.services.mozilla.com/D209330
2024-06-11 09:14:13 +00:00
Sean a18c979054 Bug 1894288 - Remove network.fetch.redirect.stripAuthHeader and network.http.redirect.stripAuthHeader prefs r=sunil,edgul,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D209393
2024-05-22 15:10:48 +00:00
Tim Huang cf64742fc5 Bug 1873631 - Part 2: Set the isInThirdPartyContext bit to the loadInfo of the channel for the fetch reqeust in workers. r=bvandersloot,asuth
We propergate the isInThirdPartyContext bit from the workerPrivate to
the fetchDrvier. So, we can set the bit for the channel that loads the
fetch request for workers.

Differential Revision: https://phabricator.services.mozilla.com/D207139
2024-04-22 16:02:51 +00:00
Emilio Cobos Álvarez de09ab0dd6 Bug 1887719 - More consistently use UTF8String/nsCString for URLs. r=necko-reviewers,webidl,anti-tracking-reviewers,places-reviewers,jari,kershaw,janv,smaug,hsivonen
Sorry for the massive patch but I found it hard to split without
introducing a bunch of copies around...

This mostly makes necko and DOM agree on which strings to use, which
should result on less copies and conversions.

Differential Revision: https://phabricator.services.mozilla.com/D205601
2024-04-04 11:49:57 +00:00
Thomas Wisniewski 70221d18ca Bug 1847358 part 3: add a fullMimeType attribute to nsIBaseChannel and use it to make our Data URI content-type header parsing standards-compliant for XHR and Fetch; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D203380
2024-03-04 21:34:27 +00:00
Thomas Wisniewski d782822b0f Bug 1847358 part 2: create and use nsIBaseChannel to reduce code debt and better-encapsulate logic for range-requests on nsBaseChannel classes; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D203379
2024-03-04 21:34:27 +00:00
Thomas Wisniewski cb7f1f5558 Bug 1847358 part 1: move nsBaseChannel::ContentRange content out into its own class as mozilla::net::ContentRange; r=dlrobertson,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D203378
2024-03-04 21:34:27 +00:00
Ziran Sun 9064e5419a Bug 1839319 - Add fetchpriority support for fetch() API. r=valentin,necko-reviewers,webidl,saschanaz,fredw
This is to add basic fetch priority support. It introduces preference of
fetch priority adjustment as per to recent discussions. We need to refine the
fetchpriority mapping taking into account of destination, which will be
addressed in Bug 1881040.

In addition, this changes the relervant prefs type to atomic type to accommodate
the access of the prefs off the main thread in the worker case.

Differential Revision: https://phabricator.services.mozilla.com/D200778
2024-02-23 15:14:17 +00:00
Eden Chuang c215bd9694 Bug 1871498 - Let FetchDriver::RunAbortAlogrithm() resolving FetchInstance::mPromises by calling FetchObserver::OnResponseEnd(). r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D198685
2024-01-29 11:02:14 +00:00
Norisz Fay cbb0667a13 Backed out changeset 07a3a86e82ee (bug 1871498) for causing multiple leakcheck failures CLOSED TREE 2024-01-25 18:35:45 +02:00
Eden Chuang 222ca6c2de Bug 1871498 - Let FetchDriver::RunAbortAlogrithm() resolving FetchInstance::mPromises by calling FetchObserver::OnResponseEnd(). r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D198685
2024-01-25 13:32:48 +00:00
sunil mayya e1acb8a42f Bug 1810805 - update mObserver modifications in FetchDriver. r=necko-reviewers,edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D194220
2023-11-27 10:31:54 +00:00
sunil mayya 8fc5324936 Bug 1851992 - implement nsIThreadRetargetableStreamListener::OnDataFinished to multiple listeners. r=necko-reviewers,extension-reviewers,jesup,rpl
Differential Revision: https://phabricator.services.mozilla.com/D187833
2023-10-27 13:30:11 +00:00
Narcis Beleuzu a71d185ff5 Backed out 6 changesets (bug 1851992) for DT failure on browser_net_image_cache.js . CLOSED TREE
Backed out changeset 3ceaf46f8f55 (bug 1851992)
Backed out changeset c9d322362e22 (bug 1851992)
Backed out changeset 673df3f83249 (bug 1851992)
Backed out changeset 46e18c56dd39 (bug 1851992)
Backed out changeset f9f9143ac713 (bug 1851992)
Backed out changeset 38c40d735ab7 (bug 1851992)
2023-10-24 13:16:40 +03:00
sunil mayya 69ed451168 Bug 1851992 - implement nsIThreadRetargetableStreamListener::OnDataFinished to multiple listeners. r=necko-reviewers,extension-reviewers,jesup,rpl
Differential Revision: https://phabricator.services.mozilla.com/D187833
2023-10-24 01:48:09 +00:00
Cristina Horotan c792918ab6 Backed out 5 changesets (bug 1851992) for causing multiple failures
Backed out changeset d28399b3d947 (bug 1851992)
Backed out changeset 95e4df69007a (bug 1851992)
Backed out changeset fa61d4e76827 (bug 1851992)
Backed out changeset 79969d9eb5cd (bug 1851992)
Backed out changeset 03c17255f1af (bug 1851992)
2023-10-17 14:48:23 +03:00
sunil mayya 40a8c4d35c Bug 1851992 - implement nsIThreadRetargetableStreamListener::OnDataFinished to multiple listeners. r=necko-reviewers,extension-reviewers,jesup,rpl
Differential Revision: https://phabricator.services.mozilla.com/D187833
2023-10-17 08:27:49 +00:00
Thomas Wisniewski 489aea0550 Bug 1845006 - store the fully-serialized MimeType on data url channels so XHR and fetch may use it for content-type response headers, and clean up the data url parsing code to better match the spec. r=kershaw,sunil,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D184713
2023-08-02 23:41:24 +00:00
Narcis Beleuzu 701fed4368 Backed out changeset f96e24bbd71c (bug 1845006) for bustages on nsDataHandler.cpp 2023-08-02 22:39:40 +03:00
Thomas Wisniewski 453464c0ca Bug 1845006 - store the fully-serialized MimeType on data url channels so XHR and fetch may use it for content-type response headers, and clean up the data url parsing code to better match the spec. r=kershaw,sunil,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D184713
2023-08-02 16:33:41 +00:00
Cristina Horotan 8c78774d7d Backed out changeset 8d98996f824c (bug 1845006) for causing build bustage at FetchDriver.cpp CLOSED TREE 2023-08-02 17:22:58 +03:00
Thomas Wisniewski 4faa886152 Bug 1845006 - store the fully-serialized MimeType on data url channels so XHR and fetch may use it for content-type response headers, and clean up the data url parsing code to better match the spec. r=kershaw,sunil,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D184713
2023-08-02 13:39:48 +00:00
Thomas Wisniewski 1ffb72e885 Bug 1784880 - Support range requests on blob URLs in fetch/XMLHttpRequest; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D184281
2023-08-01 18:50:37 +00:00
Cristian Tuns 8acd1060a3 Backed out changeset 384e4f88f047 (bug 1784880) for causing wpt failures in parsedepth.html CLOSED TREE 2023-08-01 05:41:04 -04:00
Thomas Wisniewski 21f4de34c5 Bug 1784880 - Support range requests on blob URLs in fetch/XMLHttpRequest; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D184281
2023-08-01 02:48:47 +00:00
Thomas Wisniewski 55a011c8ab Bug 1576602 - fetch response body should be empty for HEAD/CONNECT requests, per spec; r=kershaw,sunil
Differential Revision: https://phabricator.services.mozilla.com/D183434
2023-07-19 02:44:01 +00:00
Nika Layzell a51fa32bd1 Bug 1826206 - Require nsISerialEventTarget for RetargetDeliveryTo, r=necko-reviewers,valentin
This avoids potential issues where multiple OnDataAvailable callbacks or
similar could theoretically be called concurrently on different
StreamTransportService threads when targeting the STS - these cases will
now target a TaskQueue on the STS instead, structurally ensuring serial
execution.

Differential Revision: https://phabricator.services.mozilla.com/D179984
2023-06-07 14:48:38 +00:00
Eden Chuang 1cad963a91 Bug 1819570 - P4 Propagte stack trace notification back to the content process for PFetch. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor watches channels and NetEvents, stack traces are only caught in the content process.
That means PFetch should notify the netmonitor about the stack trace of the fetch at the proper moment.

In original fetch steps, FetchDriver would notify the netmonitor the fetch stack trace at
https://searchfox.org/mozilla-central/rev/cdddec7fd690700efa4d6b48532cf70155e0386b/dom/fetch/FetchDriver.cpp#834

When PFetch is enabled, PFetch needs also to propagate this notification back to the content process.

Depends on D174442

Differential Revision: https://phabricator.services.mozilla.com/D174443
2023-05-05 15:24:10 +00:00
Eden Chuang cb8c37dd2a Bug 1819570 - P2 Save worker's associated BrowsingContextID in channel's LoadInfo for the netmonitor. r=necko-reviewers,valentin
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor also watches the channels in the parent process, the created channel still loses the BrowsingContext information for netmonitor to connect the network event and the channel.

In P1, https://phabricator.services.mozilla.com/D174249, we propagate the BrowsingContext ID through PFetch.
In this patch, we need to save it in channel's LoadInfo for netmonitor.

In order not to confuse with nsILoadInfo's BrowsingContextID, we create a new attribute WorkerAssociatedBrowsingContextID in nsILoadInfo.

Depends on D174249

Differential Revision: https://phabricator.services.mozilla.com/D174441
2023-05-05 15:24:09 +00:00
Iulian Moraru 3c45645f59 Backed out 5 changesets (bug 1819570) for causing dt failures on browser_net_worker_stacks.js. CLOSED TREE
Backed out changeset e73379145f9a (bug 1819570)
Backed out changeset addc41903c2f (bug 1819570)
Backed out changeset c8534cf58f86 (bug 1819570)
Backed out changeset 81e926cf92dc (bug 1819570)
Backed out changeset 7d73ec5415a4 (bug 1819570)
2023-05-04 07:19:13 +03:00
Eden Chuang fdbcb9980c Bug 1819570 - P4 Propagte stack trace notification back to the content process for PFetch. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor watches channels and NetEvents, stack traces are only caught in the content process.
That means PFetch should notify the netmonitor about the stack trace of the fetch at the proper moment.

In original fetch steps, FetchDriver would notify the netmonitor the fetch stack trace at
https://searchfox.org/mozilla-central/rev/cdddec7fd690700efa4d6b48532cf70155e0386b/dom/fetch/FetchDriver.cpp#834

When PFetch is enabled, PFetch needs also to propagate this notification back to the content process.

Depends on D174442

Differential Revision: https://phabricator.services.mozilla.com/D174443
2023-05-04 02:46:31 +00:00
Eden Chuang d4acff34b0 Bug 1819570 - P2 Save worker's associated BrowsingContextID in channel's LoadInfo for the netmonitor. r=necko-reviewers,valentin
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor also watches the channels in the parent process, the created channel still loses the BrowsingContext information for netmonitor to connect the network event and the channel.

In P1, https://phabricator.services.mozilla.com/D174249, we propagate the BrowsingContext ID through PFetch.
In this patch, we need to save it in channel's LoadInfo for netmonitor.

In order not to confuse with nsILoadInfo's BrowsingContextID, we create a new attribute WorkerAssociatedBrowsingContextID in nsILoadInfo.

Depends on D174249

Differential Revision: https://phabricator.services.mozilla.com/D174441
2023-05-04 02:46:31 +00:00
Kershaw Chang f446ba9e37 Bug 1808323 - Add telemetry for the page load time and the time to first paint for sites that supports Early Hints response, r=manuel,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D165966
2023-05-02 08:08:44 +00:00
sunil mayya 231604e35b Bug 1823502 - do not drop auth header for HSTS and internal redirects. r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D173523
2023-03-28 00:56:23 +00:00
sunil mayya 6160bd9c95 Bug 1817980 - replace ReferrerInfo::IsCrossOriginRequest with nsScriptSecurityManager::CheckSameOriginURI for determining cross-origin redirects. r=necko-reviewers,valentin
Since Bug 1802086, we strip authentication headers when redirected to a cross-origin page. However, the api   ReferrerInfo::IsCrossOriginRequest  used for determining whether a request is cross-origin cannot be used as it compares the triggering principal's uri with the redirected channel's uri. This comparison might sometimes yield to false positives.
For e.g consider the following scenario:
1. Load `https://example.org/` and send the following fetch request from browser console
```
fetch("https://test.com/some_location", {
  "headers": {
    "Authorization": "Token foo"
  }
});
```
2. Server responds with  a redirect to https://test.com/another_location

In the above scenario, the api ReferrerInfo::IsCrossOriginRequest  will yield the above request as cross origin since the triggering principal uri here is example.com. Hence, this will be treated as cross-origin redirect resulting in removal of auth headers.

Thus ReferrerInfo::IsCrossOriginRequest  has been replaced with nsScriptSecurityManager::CheckSameOriginURI  where we directly compare the origins for the two requests.

Differential Revision: https://phabricator.services.mozilla.com/D170868
2023-02-28 12:06:36 +00:00
Eden Chuang 6c50593abe Bug 1810816 - P2 Add new interface OnReportPerformanceTiming on FetchDriverObserver. r=dom-worker-reviewers,asuth
Response Timing should be reported before the body stream completing.

In the original implementation, the response timing is recorded when OnResponseEnd is called, but it is too late. Response timing could not be ready when response.text() or response.blob() resolves the promise.

This is the second patch to add a new interface OnReportPerformanceTiming() on FetchDriverObserver, so FetchDriver could control when to report the response timing.
The patch gives an empty implementation in FetchDriverObserver for MainThreadFetchResolver and WorkerFetchResolver. And FetchInstace overrides the method for PFetch and ServiceWorker NavigationPreload.

Depends on D167936

Differential Revision: https://phabricator.services.mozilla.com/D167937
2023-02-23 02:52:54 +00:00
Csoregi Natalia 5386413ef4 Backed out 4 changesets (bug 1810816) for causing high rate failures on /service-workers/service-worker/navigation-headers.https.html. CLOSED TREE
Backed out changeset 2479dc798994 (bug 1810816)
Backed out changeset e5eacedc370d (bug 1810816)
Backed out changeset b52649243851 (bug 1810816)
Backed out changeset 0aea172f9dd3 (bug 1810816)
2023-02-22 22:39:38 +02:00
Eden Chuang 70f3fc8d5b Bug 1810816 - P2 Add new interface OnReportPerformanceTiming on FetchDriverObserver. r=dom-worker-reviewers,asuth
Response Timing should be reported before the body stream completing.

In the original implementation, the response timing is recorded when OnResponseEnd is called, but it is too late. Response timing could not be ready when response.text() or response.blob() resolves the promise.

This is the second patch to add a new interface OnReportPerformanceTiming() on FetchDriverObserver, so FetchDriver could control when to report the response timing.
The patch gives an empty implementation in FetchDriverObserver for MainThreadFetchResolver and WorkerFetchResolver. And FetchInstace overrides the method for PFetch and ServiceWorker NavigationPreload.

Depends on D167936

Differential Revision: https://phabricator.services.mozilla.com/D167937
2023-02-22 16:49:50 +00:00
Kershaw Chang f15a8b54cc Bug 1685403 - Use NS_GetFinalChannelURI at some places, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D164656
2023-02-13 16:01:41 +00:00
Eden Chuang 6f4cd78191 Bug 1351231 - FetchService integration for PFetch. r=dom-worker-reviewers,jesup
Depends on D142436

Differential Revision: https://phabricator.services.mozilla.com/D142437
2023-01-20 09:09:17 +00:00
Noemi Erli 64b4ccc119 Backed out 5 changesets (bug 1351231) for causing multiple wpt failures CLOSED TREE
Backed out changeset 257553919696 (bug 1351231)
Backed out changeset 4fd92351d64b (bug 1351231)
Backed out changeset 7a4e3f5f674a (bug 1351231)
Backed out changeset 9da00c1364a5 (bug 1351231)
Backed out changeset 19b78046ffef (bug 1351231)
2023-01-18 18:16:01 +02:00
Eden Chuang 5d56464868 Bug 1351231 - FetchService integration for PFetch. r=dom-worker-reviewers,jesup
Depends on D142436

Differential Revision: https://phabricator.services.mozilla.com/D142437
2023-01-18 00:50:20 +00:00