w3c / w3c/ServiceWorker

Edge case in https://w3c.github.io/ServiceWorker/#clients-openwindow

Open
#1,639 0 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

https://w3c.github.io/ServiceWorker/#clients-openwindow step 7 .1 reads as:
Let newContext be a new top-level browsing context.

In some edge cases, newContext might be null, and it is not clear what should happen.
With the current spec wording, it seems openWindow promise would never resolve, which is not great.

I see two possibilities:

  1. Resolve the promise with null. This somehow aligns with window.open which returns null in that case. The web app will not be able to differentiate the case where a tab is opened vs. a tab is not opened
  2. Reject the promise. This allows the web app to differentiate the case where a tab is opened vs. no tab is opened. That leaves a chance for the web app to do alternative things (focus an existing tab if any and navigate it for instance).

Thoughts?

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 by reading the Clients.openWindow algorithm at Service Worker specification step 7.1 and the issue's comparison with window.open. Determine the intended result when newContext is null, then update the specification wording so the promise behavior is explicit. Done means the edge case has an agreed resolution and the algorithm no longer leaves the promise outcome ambiguous.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.