Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict background fetch loads to HTTP family #10792

Conversation

youennf
Copy link
Contributor

@youennf youennf commented Feb 28, 2023

39186fb

Restrict background fetch loads to HTTP family
https://bugs.webkit.org/show_bug.cgi?id=253073
rdar://problem/106026139

Reviewed by Alex Christensen.

Update BackgroundFetch to handle the case of a synchronously failure.
Previously, the responseReady promise would not resolve given the failure will happen before the responseReady callback is registered.
We are now making sure to answer the responseReady callback if the failure happened before the registration.

Add HTTP check in BackgroundFetchLoad to fail lood immediately for non HTTP loads.

We update the WPT test to cover the case where the fetch registration happens but the load fails.
This is inline with other checks like CSP done at individual fetch level.

* LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window.js:
(testBgFetch):
(backgroundFetchTest):
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window.js:
(backgroundFetchTest.async t):
* Source/WebCore/workers/service/background-fetch/BackgroundFetch.cpp:
(WebCore::BackgroundFetch::didFinishRecord):
(WebCore::BackgroundFetch::recordIsCompleted):
(WebCore::BackgroundFetch::Record::didFinish):
(WebCore::BackgroundFetch::Record::retrieveResponse):
* Source/WebCore/workers/service/background-fetch/BackgroundFetch.h:
* Source/WebKit/NetworkProcess/BackgroundFetchLoad.cpp:

Canonical link: https://commits.webkit.org/260994@main

9bd4254

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@youennf youennf requested a review from cdumez as a code owner February 28, 2023 14:03
@youennf youennf self-assigned this Feb 28, 2023
@youennf youennf added the Service Workers Component for Service Workers bugs. label Feb 28, 2023
@youennf youennf added the merge-queue Applied to send a pull request to merge-queue label Mar 1, 2023
https://bugs.webkit.org/show_bug.cgi?id=253073
rdar://problem/106026139

Reviewed by Alex Christensen.

Update BackgroundFetch to handle the case of a synchronously failure.
Previously, the responseReady promise would not resolve given the failure will happen before the responseReady callback is registered.
We are now making sure to answer the responseReady callback if the failure happened before the registration.

Add HTTP check in BackgroundFetchLoad to fail lood immediately for non HTTP loads.

We update the WPT test to cover the case where the fetch registration happens but the load fails.
This is inline with other checks like CSP done at individual fetch level.

* LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window.js:
(testBgFetch):
(backgroundFetchTest):
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window.js:
(backgroundFetchTest.async t):
* Source/WebCore/workers/service/background-fetch/BackgroundFetch.cpp:
(WebCore::BackgroundFetch::didFinishRecord):
(WebCore::BackgroundFetch::recordIsCompleted):
(WebCore::BackgroundFetch::Record::didFinish):
(WebCore::BackgroundFetch::Record::retrieveResponse):
* Source/WebCore/workers/service/background-fetch/BackgroundFetch.h:
* Source/WebKit/NetworkProcess/BackgroundFetchLoad.cpp:

Canonical link: https://commits.webkit.org/260994@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Restrict-background-fetch-loads-to-HTTP-family branch from 9bd4254 to 39186fb Compare March 1, 2023 10:34
@webkit-commit-queue
Copy link
Collaborator

Committed 260994@main (39186fb): https://commits.webkit.org/260994@main

Reviewed commits have been landed. Closing PR #10792 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 39186fb into WebKit:main Mar 1, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Service Workers Component for Service Workers bugs.
Projects
None yet
4 participants