Install this page
Uses navigator.install where it exists, and the held-back beforeinstallprompt where it does not.
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.
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.
A page can ask to receive every link that starts with a given scheme with registerProtocolHandler. An installed app can declare the same in its manifest with protocol_handlers. In both cases the handler is given the whole link as one string in its address. My earlier post Detecting if a URL scheme can be handled is about what happens when nothing handles it.
| Surface | Here | What happened |
|---|---|---|
registerProtocolHandler | ||
| The rules it enforces | ||
unregisterProtocolHandler | ||
| Asking whether a scheme has a handler |
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.
| Surface | Here | What happened |
|---|---|---|
| A manifest | ||
| Reading back what the browser accepted | ||
display-mode | ||
beforeinstallprompt | ||
navigator.install | ||
getInstalledRelatedApps | ||
setAppBadge | ||
windowControlsOverlay |
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.
| Surface | Here | What happened |
|---|---|---|
launchQueue | ||
| A way back from a launch | ||
showOpenFilePicker |
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.
| Surface | Here | What 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 |
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.
These ask the browser or you for something, so they wait for a press. Each result is written under its button.
Uses navigator.install where it exists, and the held-back beforeinstallprompt where it does not.
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.
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:
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.
The whole of manifest.json, as the browser fetches it:
Loading.
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.