Closed Bug 1690306 Opened 3 years ago Closed 3 years ago

[wpt-sync] Sync PR 27444 - Resolve Service Worker redirects based on the response

Categories

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

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: mozilla.org, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

b'David Benjamin <davidben@chromium.org>' wrote:

Resolve Service Worker redirects based on the response

We currently resolve Service-Worker-forwarded location headers using the
request. While this matches Firefox, this does not match the spec or
Safari's behavior. Instead, the spec says to resolve the location header
based on the response's URL.

This comes up if the FetchEvent was for /, but the Service Worker
responded with ev.respondWith(fetch("/foo/", {redirect: "manual"})). In
that case, a Location: bar.html header would result in /bar.html by our
version and /foo/bar.html by the spec's version.

Align with the spec. This makes the redirect go where it would have gone
under {redirect: "follow"}. This has two platform-visible behavior
changes:

  • First, cases like the above will result in a different URL.

  • Second, script-constructed Response objects do not have a URL list. If
    the URLs are absolute, this works fine. If they are relative, those
    fetches will now result in a network error. Note Response.redirect()
    internally constructs absolute URLs, so those continue to work. This
    only affects ev.respondWith(new Response(... location: "bar.html"}})).

Both of these changes match Safari.

Note that, as of writing, the Fetch spec describes this behavior in
terms of a location URL property on the response object. This would
require computing the location URL earlier and preserving it across many
layers, including persisting in CacheStorage. See
https://chromium-review.googlesource.com/c/chromium/src/+/2648648.

Instead, this CL uses the equivalent formulation in
https://github.com/whatwg/fetch/pull/1149. See also discussion in
https://github.com/whatwg/fetch/issues/1146.

Bug: 1170379
Change-Id: Ibb6b12566244fd259029e67787dd7f08edeece9d
Reviewed-on: https://chromium-review.googlesource.com/2665871
WPT-Export-Revision: a106a1529217f1e9886533e791951c920941569f

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

CI Results

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

Total 15 tests and 10 subtests

Status Summary

Firefox

OK : 14[Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows10-64-debug, Gecko-windows10-64-qr-debug, Gecko-windows7-32-debug] 15[Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-qr-debug-geckoview, Gecko-windows10-64-opt, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt, GitHub]
PASS : 347[Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows10-64-debug, Gecko-windows10-64-qr-debug, Gecko-windows7-32-debug] 379[Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-qr-debug-geckoview, Gecko-windows10-64-opt, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt, GitHub]
FAIL : 7[Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows10-64-debug, Gecko-windows10-64-qr-debug, Gecko-windows7-32-debug] 14[Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-qr-debug-geckoview, Gecko-windows10-64-opt, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt, GitHub]

Chrome

OK : 15
PASS : 376
FAIL : 17

Safari

OK : 14
PASS : 340
FAIL : 52
TIMEOUT: 2

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

Firefox-only Failures

/service-workers/service-worker/fetch-csp.https.html
Verify CSP control of fetch() in a Service Worker: FAIL

New Tests That Don't Pass

/service-workers/service-worker/navigation-redirect.https.html?client: OK [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-qr-debug-geckoview, Gecko-windows10-64-opt, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt, GitHub], SKIP [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows10-64-debug, Gecko-windows10-64-qr-debug, Gecko-windows7-32-debug] (Chrome: OK, Safari: OK)
SW-fallbacked redirect to same-origin out-scope.: FAIL (Chrome: PASS, Safari: FAIL)
SW-generated redirect to same-origin out-scope.: FAIL (Chrome: PASS, Safari: FAIL)
SW-generated redirect to same-origin out-scope with a hash fragment.: FAIL (Chrome: PASS, Safari: FAIL)
SW-generated redirect to same-origin out-scope with different hash fragments.: FAIL (Chrome: PASS, Safari: FAIL)
SW-fetched redirect to same-origin out-scope.: FAIL (Chrome: PASS, Safari: FAIL)
Redirect to same-origin out-scope with opaque redirect response.: FAIL (Chrome: PASS, Safari: FAIL)
Redirect to same-origin out-scope with opaque redirect response which is passed through Cache.: FAIL (Chrome: PASS, Safari: FAIL)
/service-workers/service-worker/fetch-csp.https.html
Verify CSP control of fetch() in a Service Worker: FAIL (Chrome: PASS, Safari: PASS)
/service-workers/service-worker/navigation-redirect-resolution.https.html
test relative opaqueredirect: FAIL (Chrome: FAIL, Safari: PASS)
test relative opaqueredirect with CacheStorage: FAIL (Chrome: FAIL, Safari: PASS)
test relative opaqueredirect with clone: FAIL (Chrome: FAIL, Safari: PASS)
/service-workers/service-worker/next-hop-protocol.https.html
nextHopProtocol reports H1 correctly when routed via a service worker.: FAIL (Chrome: PASS, Safari: FAIL)
nextHopProtocol reports H2 correctly when routed via a service worker.: FAIL (Chrome: FAIL, Safari: FAIL)
/service-workers/service-worker/redirected-response.https.html
mode: "follow", generated relative redirect response: FAIL (Chrome: FAIL, Safari: PASS)

Tests Disabled in Gecko Infrastructure

/service-workers/service-worker/navigation-redirect.https.html?client: OK [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-qr-debug-geckoview, Gecko-windows10-64-opt, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt, GitHub], SKIP [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows10-64-debug, Gecko-windows10-64-qr-debug, Gecko-windows7-32-debug] (Chrome: OK, Safari: OK)

Pushed by wptsync@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f5404d5590f5
[wpt PR 27444] - Resolve Service Worker redirects based on the response, a=testonly
https://hg.mozilla.org/integration/autoland/rev/b4d49cf528d3
[wpt PR 27444] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.