Handlers

Integration census: every way a web app can be opened

Port Authority is about what two pages can do once they hold a port to each other. This page is about the step before that: how a web app gets opened in the first place. A link with a scheme of its own, a file double-clicked in the operating system, a share from another app, an icon on the home screen, a message to a service worker.

Each row below is checked in the browser you are reading this with, when the page loads. A green bar means the browser has it. A red bar means it is missing or was refused. Nothing on this page asks you for anything until you press a button.

The checks are running.

How this page was opened

This page is also an installable app. Its manifest declares a handler for web+census: links, for .txt and .census files, a share target and a launch handler. Every route ends up here, and this list records what arrived. Install the page, then open it each way from Try each route.

  1. Opened as an ordinary page, with nothing handed to it.

The installed app

Handlers in the manifest only take effect once the page is installed. These rows check what a page can learn about that, and what an installed window adds.

SurfaceHereWhat happened
A manifest
Reading back what the browser accepted
display-mode
beforeinstallprompt
navigator.install
getInstalledRelatedApps
setAppBadge
windowControlsOverlay

Files

With file_handlers in its manifest, an installed app appears in the operating system's Open with list for the file types it names. The files arrive on launchQueue as handles, which can be written back to. launch_handler decides whether each launch opens a new window or goes to one already open.

SurfaceHereWhat happened
launchQueue
A way back from a launch
showOpenFilePicker

Sharing

navigator.share sends text, a link or files out through the system share sheet. share_target in a manifest puts an installed app into that sheet. On this page the share arrives at the service worker as a form, which keeps it and sends the window here. I wrote about registering as a share target and receiving files when they first shipped.

SurfaceHereWhat happened
navigator.share
Sharing a file
Knowing about a share target

Messages to a service worker

A service worker runs for an origin with no page open, which makes it the obvious place to receive work from outside. These rows send this page's own service worker a message and check each way it can answer. The last two rows check what it cannot do. Joining two sites' service workers shows the workaround for the other-origin case.

SurfaceHereWhat happened
An answer on a MessagePort
An answer with client.postMessage
An answer on a BroadcastChannel
Another origin's service worker
A launch event in the worker

What people could build with these

Each row is something I would want from a web app, the surfaces it would use, and whether it can be built today. The rows marked Blocked are the ones that need something back from the app that was opened, which none of these routes can carry. Where Port Authority already does the round trip a different way, the row links to it.

UseBuilt fromToday
Follow someone from any page, on your own Mastodon or ActivityPub serverregisterProtocolHandler for web+follow:Works. Works in a tab. The page with the link cannot tell whether anything will open it.
Email links that open the webmail you useregisterProtocolHandler for mailto:Works. Works in a tab, on desktop.
Open a .csv from the desktop in a web spreadsheet, and save back to the same filefile_handlers, file handles on launchQueueWorks. Works once installed, on desktop.
A music player that queues a file into the window already playingfile_handlers, launch_handler focus-existingWorks. Works once installed.
A chat app where every link focuses the one open windowprotocol_handlers, launch_handlerWorks. Works once installed.
Send an article to a read-later appshare_targetPartly. Works once installed, and a window opens every time, even though there is nothing to show.
Share photos to an editor and get the edited photos backnavigator.share, share_targetBlocked. Cannot be built: a share has no answer.
Pick a payment app with a link, and get a confirmation backregisterProtocolHandler for web+pay:Blocked. Half of it: the payment app opens, and nothing can be sent back. Port Authority's picker does the round trip with a port.
An agent asks a site to do a task and gets the resulta web+ link, or WebMCP toolsBlocked. Not through the operating system. Port Authority does it with a hub that hands the agent a port.
Two apps on different origins that share one background workerservice worker messagingBlocked. Only through a frame from the other origin, which Port Authority shows working.
An unread count on the app's iconsetAppBadgeWorks. Works once installed, where the platform shows badges.
A page that offers to install itself so that it can open your filesnavigator.install, beforeinstallpromptPartly. Depends on the browser. Every manifest handler waits on that install.
Links on a partner's origin that open your installed appscope_extensionsBlocked. Proposed, and not checked on this page yet.

Try each route

These ask the browser or you for something, so they wait for a press. Each result is written under its button.

Install this page

Uses navigator.install where it exists, and the held-back beforeinstallprompt where it does not.

Handle web+census links

Registers this page with registerProtocolHandler. Then the link opens this page with the link in its address, and the list at the top records it.

Open web+census:hello-from-the-census

Open a file in the app

Once installed, right-click a .txt file in your file manager and choose Open with, Integration census. Or download sample.census and open that. A picker inside the page, for comparison:

Share to and from the app

Shares a small text file. Once the page is installed it appears in the share sheet itself, so you can share to it from here or from any other app.

What this page declares

The whole of manifest.json, as the browser fetches it:

Loading.

How this census was made

Every check is in probes.js, the buttons and the launch list in launches.js, and the service worker in sw.js. A check that finds a function only says it is there. It does not prove that the browser shows it to people, which on some platforms it does not. The routes that need an installed app are only proved by trying them.

I have run it in Chromium on Linux only so far, in a tab and not installed. The gaps it finds are written up, with what each would let people build, on What is missing. If a row is wrong in your browser, please open an issue.