whatwg / whatwg/html

`registerProtocolHandler` support triggering events in service worker instead of navigating to page

Open
#8,596 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

(I post this on both service worker spec #1665 and whatwg spec here)

I want to compare the behavior of web apps(and browser extensions) and native apps for a registered protocol.

Native apps behavior

When click a registered protocol link, the native app is woken up and the link is passed to the app for processing. Note: the current page doesn't be closed or navigate to other page, you can continue to click other links in the page and active the native app again.

Web behavior

Current registerProtocolHandler() spec says the behavior is "Navigate an appropriate navigable to resultURL". In other words, the current page is unload and navigate to another page. In some scenarios, this behavior is not expected, instead users expect the behavior like native apps.

Proposal

I hope registerProtocolHandler() support another behavior like native apps behavior. When users click a registered protocol link, fire an event with the link information in service worker, then the website(web app) handle it in service worker. This approach is more flexible for developers, and the current page does not navigate to other page. For example, in service worker, developers can open a new tab or popup window, or active(focus) an already opened page or popup window to handle it.

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 HTML Standard's custom handlers section and the linked ServiceWorker issue #1665. Compare the current navigate-to-resultURL behavior with the proposed service-worker event flow, including how link data and non-navigation handling should be specified. Done means the behavior and lifecycle are resolved in the relevant specification text.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
web-dev
Issue type
Feature
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.