Closed Bug 2079467 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63357 - Enforce CORS in Background Fetch

Categories

(Core :: DOM: Service Workers, task, P4)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 63357 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/63357
Details from upstream follow.

Hubert Chao <hchao@chromium.org> wrote:

Enforce CORS in Background Fetch

Previously, the DownloadService previously defaulted all fetch requests
to kNavigate (which bypasses CORS). This CL updates the Background
Fetch delegate to pass the original fetch request mode down to the
DownloadService, so that the network service can correctly enforce CORS
checks on Background Fetch requests.

This additionally updates the proto serialization to persist the request
mode across browser restarts, and modify testing handlers to ensure the
CORS enforcement properly blocks requests that lack required
Access-Control headers. The browser tests have been updated to initiate
these fetches from the Window context instead of the Service Worker to
sidestep kRestrictBackgroundFetchFromServiceWorker restrictions.

Additionally, to prevent old suspended downloads from resuming and
bypassing CORS after the browser updates, EntryFromProto explicitly
upgrades the request mode to kCors if the fetch_request_mode is missing
and the client is BACKGROUND_FETCH.

The CORS enforcement and legacy proto upgrade logic are gated behind a
new kBackgroundFetchCorsEnforcement feature kill switch.

TAG=agy
CONV=96c12324-004c-4da1-bec2-9436ea828a56

Bug: 515243254, 496008447, 495903812, 485855931, 40059500, 500171457, 498000798
Change-Id: I1dc5266d08c20c23ee56340a3c20b7b988befb59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8103044
Reviewed-by: Colin Blundell \<blundell@chromium.org>
Reviewed-by: Yoshisato Yanagisawa \<yyanagisawa@chromium.org>
Commit-Queue: Hubert Chao \<hchao@chromium.org>
Reviewed-by: Camille Lamy \<clamy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1713422}

Component: web-platform-tests → DOM: Service Workers
Product: Testing → Core

CI Results

Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 14 tests

Status Summary

Firefox

OK : 1
FAIL : 14

Chrome

PASS : 2
TIMEOUT: 2
NOTRUN : 11

Safari

OK : 1
FAIL : 14

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.