reload-service-worker-fetch-event.html is served over HTTP (no .https), and its worker calls event.transitionWhile() instead of respondWith()

Open Beginner friendly
#65,407 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Read navigation-api/navigation-methods/reload-service-worker-fetch-event.html and navigation-api/navigation-methods/resources/fetch-event-test-worker.js; the report identifies both the insecure HTTP test URL and the invalid FetchEvent method. Rename the test with the .https.html suffix and restore event.respondWith(...) in the worker. Done means the test runs in a secure context and the fetch handler returns the expected reload navigation text.

Written by the indexing model from the issue text.

Description

navigation-api/navigation-methods/reload-service-worker-fetch-event.html registers a service worker with service_worker_unregister_and_register from /service-workers/service-worker/resources/test-helpers.sub.js. The file name has no .https flag, so the test is served from an http:// origin. That is not a secure context, navigator.serviceWorker is not exposed (it is [SecureContext]), and the test throws before the reload:

  • Chrome: TypeError: Cannot read properties of undefined (reading 'getRegistration')
  • Firefox: TypeError: can't access property "getRegistration", navigator.serviceWorker is undefined
  • Safari: TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.getRegistration')

The result is 0/1 in all six wpt.fyi runs aligned at 71b58bb191. Stable: Chrome 158.0.8127.36 (run 5091530419994624), Firefox 160.0.1 (5102456061820928), Safari 27.2 (5121161130934272). Experimental: Chrome 160.0.8168.0 (5165587534446592), Firefox 162.0a1 (5188734707040256), Safari Technology Preview 256 (5096019650674688).

https://wpt.fyi/results/navigation-api/navigation-methods/reload-service-worker-fetch-event.html?run_id=5091530419994624&run_id=5102456061820928&run_id=5121161130934272

Renaming the file is not enough on its own. Its worker, navigation-api/navigation-methods/resources/fetch-event-test-worker.js, responds with

event.transitionWhile(new Response(body));

FetchEvent has no transitionWhile(). The line was event.respondWith(new Response(body)) until 93e7dda5c5 ("App history: rename respondWith() to transitionWhile()", 2021-08-18), which renamed this FetchEvent call along with the app history method. As it stands, the fetch handler throws and the request falls back to the network. The frame then shows the text of service-worker-page.html instead of "method = GET, isReloadNavigation = ...".

Suggested fix

  1. Rename the test to reload-service-worker-fetch-event.https.html.
  2. In resources/fetch-event-test-worker.js, change event.transitionWhile(...) back to event.respondWith(...).
Dominant language
HTML
Stars
6.3k
Forks
4.1k
Avg merge
17h 20m
Merged PRs (30d)
841

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web-platform-tests/wpt

All issues in web-platform-tests/wpt

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.