w3c / w3c/ServiceWorker

clients.get() should not resolve before sandboxing determines the origin of the client

Open
#1,385 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
3.6k
Forks
324
Avg merge
14d 22h
Merged PRs (30d)
1

Description

I think this is an oversight in the spec.

clients.get(id) does:
"Wait for either client’s execution ready flag to be set or for client’s discarded flag to be set."
https://w3c.github.io/ServiceWorker/#clients-get

The execution ready flag seems set at:
"7. Set the active document of browsingContext to document."
https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context

Which later on does:
"11. Implement the sandboxing for document."

Probably we must implement the sandboxing for document first, and if the document has a unique origin we "Run the environment discarding steps for reservedEnvironment." like a cross-origin redirect. Then we can set execution ready.

Chrome currently resolves to a WindowClient. Firefox resolves with undefined. I think the spec intent is undefined.

cc @annevk @wanderview

Contributor guide

Open the contributing guide

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.

Research direction

Start with the clients.get(id) algorithm in the ServiceWorker specification and the linked HTML steps for creating a browsing context. Compare when the execution ready flag is set with when document sandboxing and environment discarding occur. Done means the specification clearly defines the result for a document with a unique origin.

Written by the indexing model from the issue text.

Assessment

Domain
api, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.