fix: the play page offers a new tab or another browser where the player cannot start (#116)
Closes #116.
Where the player cannot start for the frame's sake or the browser's, the play page now says so and gives the way on, in place of a technical error. A content error of the activity's own is shown as before.
How the page knows, from the browser alone
- Before anything is built: no secure context (a chat on plain http), no origin (a frame sandboxed without one), or no Service Worker at all. Nothing is built then. Not in a tab that only saves (
&save=1), which needs no player. - After the build: the player's
no-workererror (a worker that could not register, as where third-party cookies are blocked), and, framed only,bad-archiveorquota. The page built that archive a moment before, so a read or store that fails is the frame's, not the package's.
What is seen (a new seventh state, elsewhere, in the stage's place, in the design of the other states)
- Framed: an icon, "Open it in a new tab", one line on why (the chat's page not on a secure connection; the chat not letting the player start inside its reply, for a frame with no origin; or the browser not letting it, as where it blocks third-party cookies), the solid button Open in a new tab, and under it "If no tab opens, copy this address into your browser." with the address in a read-only field and Copy. A parent that opens links is handed the address (the click handler already in place for
target="_blank"); elsewhere the link opens a tab where the frame lets it. The address carries the addresses the parent gave for the person's files (&links=), so the tab plays them from there, and never&save=1(fragmentWithLinkstakessave = falsefor it). - In a tab with no worker (an app's built-in browser): "Open it in another browser", why, and the address to copy into one. No button.
- In a tab off https: "Open it on a secure connection", with the https address to copy.
- The address is built from
location.origin, which is the URL's origin even in a frame with no origin of its own (self.originis"null"there): checked in Chromium, Firefox and WebKit. - Download stays where a package was built: it is the person's even where it does not play.
- Light and dark, 760 px and 360 px wide: the text wraps in the panel, the address scrolls in its field, the button and the Copy button keep their size.
A save with no word. A parent that took the package to save and says nothing for 10 s: "Nothing saved yet? Right-click Download, or press and hold it, and open the link in a new tab." under the stage, Download pressable again. Before, "The chat is saving the .h5p…" for a minute. A yes that comes later is still said, as before.
Checked against this branch's build, the page served from 127.0.0.1 and a stand-in chat from localhost (another site, so the frame is third-party, as in a chat), the stand-in saying it opens links:
| Case | Before | Now | The tab the chat opens |
|---|---|---|---|
| Chromium, defaults | plays | plays | – |
| Chrome, "Block third-party cookies" (real Chrome profile) | "Could not register …" | Open it in a new tab | plays |
Firefox, third-party cookies refused (cookieBehavior 1) | "Could not register …" | Open it in a new tab | plays |
| Firefox, defaults | plays | plays | – |
| WebKit (Playwright's), framed by another site | "Could not read the archive index" | Open it in a new tab | plays |
| Frame sandboxed without an origin | the technical no-Service-Worker error | Open it in a new tab, at once | – |
Parent on plain http (chat.test) | "It could not be built…" | Open it in a new tab, at once | plays |
| Tab with no Service Worker | the technical error | Open it in another browser | – |
Tab that only saves (&save=1), no Service Worker | – | builds and downloads the .h5p | – |
The page itself on plain http (site.test) | "It could not be built…" | Open it on a secure connection, the https address | – |
| Parent that saves and never answers | "saving…" a minute | the way by hand at 10 s | – |
pnpm typecheck and pnpm build pass. cubic's review: four points fixed in 0764266 (the save-only tab, the two wordings, the name placeholders); the fifth, location.origin in a frame with no origin, answered with the three engines' values. Not tried: Safari itself, iOS in-app browsers, the real chats' frames.
Paired with missing-elements/h5p-toolkit#276, the card's and the server's fallbacks; neither needs the other.
Summary by cubic
Fixes the play page so that when the player cannot start inside a chat's frame or the browser, it explains why and offers a new tab or another browser with a copyable address, instead of a technical error. A save the chat never confirms now says how to save by hand after 10 seconds instead of waiting a minute.
- The page tells why before anything is built (no secure context, no origin, no Service Worker) or from the player's
no-workererror, and a framedbad-archiveorquotaerror. - The offered tab's address carries the file links the parent gave, without
&save=1, so it plays from there; on plain http the address is rewritten to https. - The check is skipped in a tab that only saves, which builds and downloads with no player.
- A frame sandboxed without an origin and a tab off https get wording of their own.
- The activity's name placeholder is not shown beside the way on.
- Download stays where a package was built, even when it does not play.