@dasl/tile-loader 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +680 -37
- package/dist/at.d.ts.map +1 -1
- package/dist/at.js +11 -3
- package/dist/at.js.map +1 -1
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +6 -2
- package/dist/car.js.map +1 -1
- package/dist/guard.d.ts +110 -10
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +647 -59
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +176 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +265 -35
- package/dist/index.js.map +1 -1
- package/dist/lib/tab-order.d.ts +16 -0
- package/dist/lib/tab-order.d.ts.map +1 -0
- package/dist/lib/tab-order.js +66 -0
- package/dist/lib/tab-order.js.map +1 -0
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +4 -1
- package/dist/mount.js.map +1 -1
- package/package.json +2 -2
- package/src/at.ts +11 -3
- package/src/car.ts +6 -2
- package/src/guard.ts +701 -55
- package/src/index.ts +300 -35
- package/src/lib/tab-order.ts +66 -0
- package/src/mount.ts +4 -1
package/README.md
CHANGED
|
@@ -75,7 +75,14 @@ Four cooperating layers, all talking over `postMessage`:
|
|
|
75
75
|
- `conf.namedOrigin` (`conf.tileHost` before 3.1, still accepted): a tile origin to run tiles on, by name
|
|
76
76
|
(`notes.tiles.example`), instead of a fresh random one per load; for a
|
|
77
77
|
deployment whose tiles share an origin or keep their storage. The tile server
|
|
78
|
-
has to
|
|
78
|
+
has to take the name for a tile origin: list it in the `namedOrigins` of
|
|
79
|
+
[`@dasl/tile-server`](../tile-server). A tile on a name it does not take
|
|
80
|
+
does not start: the dock will not frame it. A name that is a tile's CID is
|
|
81
|
+
not one to give here, and throws: see `conf.cidOrigins`.
|
|
82
|
+
- `conf.cidOrigins`: `true` to run each tile on the origin its own content
|
|
83
|
+
names, the CID of its manifest, which is kept: what the tile stores there it
|
|
84
|
+
finds again the next time it runs. `false` when left out. See "Origins named
|
|
85
|
+
by a tile's CID". Not with `namedOrigin` (it throws).
|
|
79
86
|
- `conf.webrtcGuard`: `'exhaust'` (default) has the shuttle spend Chromium's
|
|
80
87
|
per-process WebRTC budget before the tile loads (see Security model); `'none'`
|
|
81
88
|
skips it, for hosts that block WebRTC themselves (an Electron app with the
|
|
@@ -130,11 +137,17 @@ Four cooperating layers, all talking over `postMessage`:
|
|
|
130
137
|
|
|
131
138
|
- **`await renderCard(options?)`** — a DOM element showing the tile's card
|
|
132
139
|
(metadata only; safe to render many at once). `options.contentHeight` presets the
|
|
133
|
-
height used when the card is clicked to expand.
|
|
134
|
-
|
|
140
|
+
height used when the card is clicked to expand, and `options.frame` is what
|
|
141
|
+
you ask of the frame it then opens, as for `renderContent()`.
|
|
142
|
+
- **`renderContent(height?, options?)`** — the sandboxed iframe that runs the
|
|
143
|
+
tile. `options` say what else the frame is to be: see "The frame a tile
|
|
144
|
+
runs in".
|
|
135
145
|
- **`await close()`** — you are done with the tile: its runtime tidies up, its
|
|
136
146
|
frame is removed, and the tile forgets it (a `close` event says when). It can
|
|
137
147
|
be rendered again afterwards. See "When a tile goes away".
|
|
148
|
+
- **`ephemeral`** — whether the origin the tile runs on is made for one load,
|
|
149
|
+
and wiped when it is closed: `false` on a named origin, and on the origin a
|
|
150
|
+
tile's CID names (see "Origins named by a tile's CID").
|
|
138
151
|
- The **`load`** event — the tile's runtime is up, and its root document is
|
|
139
152
|
being fetched for it. It says that all went well so far, not that anything
|
|
140
153
|
is on screen; and for a tile that cannot start it never comes, which is
|
|
@@ -174,6 +187,15 @@ Four cooperating layers, all talking over `postMessage`:
|
|
|
174
187
|
the deadline (`timeout`, stage `content`); with no deadline, or a long
|
|
175
188
|
one, the tile's worker gives up on it after a minute, and that is
|
|
176
189
|
reported as `content`.
|
|
190
|
+
- `integrity`: the tile runs on the origin its CID names (`cidOrigins`),
|
|
191
|
+
and the runtime there refused the manifest it was handed: not the one
|
|
192
|
+
that CID names, or not one it reads (a .tile file whose header is not
|
|
193
|
+
written in DRISL's one form). Nothing of the tile is served.
|
|
194
|
+
|
|
195
|
+
For a tile on the origin its CID names, `version` also means that the
|
|
196
|
+
tile server's dock did not say that its runtime holds such an origin to
|
|
197
|
+
its tile (a server from before 4.0, or another that does not): the tile is
|
|
198
|
+
not run there, and nothing of it is handed down.
|
|
177
199
|
|
|
178
200
|
A start (a frame the tile is attached to, each time it loads) fires one
|
|
179
201
|
`error` at most, and none once `close()` is called: closing ends the start,
|
|
@@ -278,6 +300,299 @@ Each is a subpath export; add the ones you need:
|
|
|
278
300
|
the HTTP-fetching loaders extend. The `TileLoader` and `TilePathLoader` interfaces
|
|
279
301
|
are exported from the package root for writing your own.
|
|
280
302
|
|
|
303
|
+
## The frame a tile runs in
|
|
304
|
+
|
|
305
|
+
`renderContent(height?, options?)` makes the frame, and `renderCard({ frame })`
|
|
306
|
+
hands the same options to the frame its card opens. Each option is checked,
|
|
307
|
+
and one the loader cannot honour throws (a card is refused when it is made),
|
|
308
|
+
so that you are never left believing in a frame you do not have.
|
|
309
|
+
|
|
310
|
+
| Option | When left out | What it is |
|
|
311
|
+
| --- | --- | --- |
|
|
312
|
+
| `sandbox` | `'allow-scripts allow-same-origin allow-forms'` | the frame's sandbox attribute in full |
|
|
313
|
+
| `credentialless` | `true` on an origin made for the load, `false` on a named origin and on the origin a tile's CID names (`tile.ephemeral`) | whether the frame is credentialless |
|
|
314
|
+
| `tabindex` | none: the frame is in the tab order, unless the focus guard is on it | the frame's tabindex, `-1` to have Tab pass over the tile |
|
|
315
|
+
| `refuse` | `['sync-xhr']` | features of the browser to take from the tile, the list in full |
|
|
316
|
+
|
|
317
|
+
A frame of your own making (`attachIframe()`) gets none of these: give it the
|
|
318
|
+
attributes yourself (`sandbox`, `credentialless`, `tabindex`, `allow`), before
|
|
319
|
+
the frame goes in the document. `allow="sync-xhr 'none'"` is what the loader
|
|
320
|
+
writes when nothing is said of `refuse`.
|
|
321
|
+
|
|
322
|
+
### `sandbox`
|
|
323
|
+
|
|
324
|
+
The runtime the frame loads has a sandbox of its own (`tileSandbox` in
|
|
325
|
+
`@dasl/tile-lexicon`: `allow-downloads allow-forms allow-modals
|
|
326
|
+
allow-same-origin allow-scripts`), and a frame's sandbox only ever takes
|
|
327
|
+
away: a tile gets what both grant. The frame leaves out dialogs and
|
|
328
|
+
downloads, so a tile in your page:
|
|
329
|
+
|
|
330
|
+
- raises no dialog: `alert()` returns at once, `confirm()` false, `prompt()`
|
|
331
|
+
null, `print()` does nothing, and a page that asks to hold the user when
|
|
332
|
+
they leave (`beforeunload`) is not heard. The same through the runtime's
|
|
333
|
+
page above the tile, which the tile can script;
|
|
334
|
+
- starts no download, by itself or on a press: not from a link with
|
|
335
|
+
`download`, a `blob:` or `data:` address, or a file served as an
|
|
336
|
+
attachment.
|
|
337
|
+
|
|
338
|
+
It keeps what it runs on: scripts, its own origin and so its worker and its
|
|
339
|
+
storage (`localStorage`, IndexedDB, the Cache API), forms it submits to
|
|
340
|
+
itself, the link, size and data protocols, closing and the wipe. And what the
|
|
341
|
+
sandbox has no say in stays as it was: on a press, a tile can still open a
|
|
342
|
+
file picker, play sound and video, and write to the clipboard with
|
|
343
|
+
`execCommand('copy')`; it gets no fullscreen and no reading of the clipboard
|
|
344
|
+
unless your frame's `allow` attribute gives them, and no pointer lock, popups
|
|
345
|
+
or navigation of your page, which the runtime's own sandbox refuses.
|
|
346
|
+
|
|
347
|
+
A page where someone runs one tile on purpose, a workbench, may want dialogs
|
|
348
|
+
and downloads back (Blastile's preview asks for them):
|
|
349
|
+
|
|
350
|
+
```js
|
|
351
|
+
tile.renderContent(300, { sandbox: 'allow-scripts allow-same-origin allow-forms allow-modals allow-downloads' });
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
`allow-scripts` and `allow-same-origin` have to be in it: without them the
|
|
355
|
+
runtime's service worker cannot run and no tile loads. `allow-forms` is yours
|
|
356
|
+
to leave out, and then a tile's forms do nothing. A token the runtime does
|
|
357
|
+
not grant would do nothing under it, so the loader refuses it.
|
|
358
|
+
|
|
359
|
+
### `credentialless`
|
|
360
|
+
|
|
361
|
+
A tile's origin is a subdomain of the loading server's site
|
|
362
|
+
(`<random>.example.site`), and cookies go by site, not by origin: in a plain
|
|
363
|
+
frame a tile reads the cookies that site keeps for its whole domain, and
|
|
364
|
+
sets cookies there. In a credentialless frame Chromium gives everything
|
|
365
|
+
inside cookies and storage of their own, empty to begin with and gone with
|
|
366
|
+
the page: the tile sees none of the site's cookies, what it sets stays in that
|
|
367
|
+
jar, and the browser's password manager keeps out of the frame. Firefox and
|
|
368
|
+
Safari ignore the attribute: there it protects nothing.
|
|
369
|
+
|
|
370
|
+
So the frame is credentialless, unless the tile runs on a named origin
|
|
371
|
+
(below). A host that wants it otherwise says so, either way:
|
|
372
|
+
|
|
373
|
+
```js
|
|
374
|
+
tile.renderContent(300, { credentialless: false });
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
`true` or `false`; anything else throws, the empty text of an attribute that
|
|
378
|
+
is there included. What to know of it:
|
|
379
|
+
|
|
380
|
+
- The tiles of one page share that jar, about 11 kB in Chrome, and all of it
|
|
381
|
+
goes to the loading server with every request a tile there makes. Over
|
|
382
|
+
HTTP/2 Chrome sends each cookie as a field of its own, and a server counts
|
|
383
|
+
that as about 19 kB of headers. A loading server that refuses a request of
|
|
384
|
+
that size, or a front before it that does (Node reads 16 kB by default,
|
|
385
|
+
Caddy 16 KiB from 2.11.6 on, some fronts 8 kB to a line), leaves one tile
|
|
386
|
+
able to keep the next ones on its page from loading, until the page is
|
|
387
|
+
loaded again. `@dasl/tile-server`'s command reads 1 MiB; its README says
|
|
388
|
+
what a front has to take.
|
|
389
|
+
- A tile on a named origin (`namedOrigin`), or on the origin its CID names
|
|
390
|
+
(`cidOrigins`), is there to find its storage again, and a credentialless
|
|
391
|
+
frame loses it with every page: its frame is a plain one unless you ask.
|
|
392
|
+
In Chrome a plain frame has the cookies of the loading server's domain,
|
|
393
|
+
which Chrome does not keep apart by site unless its user blocks third-party
|
|
394
|
+
cookies: see "Origins named by a tile's CID".
|
|
395
|
+
|
|
396
|
+
Closing a tile in such a frame wipes its origin from a credentialless frame
|
|
397
|
+
too, since that is where what it stored is.
|
|
398
|
+
|
|
399
|
+
### `tabindex`
|
|
400
|
+
|
|
401
|
+
Whoever has the focus in a tile types into the tile. Every key goes to it,
|
|
402
|
+
Tab and Escape with the rest, and your page hears none of them, so a tile
|
|
403
|
+
that will not let Tab go keeps the keyboard; and each key pressed there
|
|
404
|
+
counts as its user having acted in the tile. On a page with more on it than
|
|
405
|
+
tiles, someone tabbing down it should end up in neither position: `-1` has
|
|
406
|
+
the Tab key pass over the tile. A click in the tile gives it the keyboard as
|
|
407
|
+
before.
|
|
408
|
+
|
|
409
|
+
Then nobody reaches the tile with the keyboard alone unless you give them the
|
|
410
|
+
means, so do: a control of your own that puts the keyboard in the frame
|
|
411
|
+
through its window (`frame.contentWindow.focus()`).
|
|
412
|
+
|
|
413
|
+
The focus guard (see "The keyboard" below) does all of this itself: a frame
|
|
414
|
+
it guards is out of the tab order whatever its `tabindex` says, and in its
|
|
415
|
+
place in the tab order the guard puts a stop of its own, which is the way
|
|
416
|
+
in. Where you would rather have your own, tell the guard (`tabOrder:
|
|
417
|
+
'out'`) and let it put the keyboard in, or it takes that focus for a
|
|
418
|
+
script's and gives it back:
|
|
419
|
+
|
|
420
|
+
```js
|
|
421
|
+
import { guardFocus } from '@dasl/tile-loader/guard';
|
|
422
|
+
|
|
423
|
+
const frame = tile.renderContent(300);
|
|
424
|
+
const guard = guardFocus(tile, frame, { tabOrder: 'out' });
|
|
425
|
+
const enter = document.createElement('button');
|
|
426
|
+
enter.textContent = `Use the keyboard in ${tile.manifest.name || 'this tile'}`;
|
|
427
|
+
enter.addEventListener('click', () => guard.focus());
|
|
428
|
+
document.body.append(enter, frame);
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
After that the next Tab goes to the first thing in the tile that takes it.
|
|
432
|
+
Tab past the last, or Shift+Tab before the first, comes back to your page if
|
|
433
|
+
the tile lets it: from inside, only the tile and the browser's own shortcuts
|
|
434
|
+
let the keyboard out. `engage()` has a way in of its own, its layer.
|
|
435
|
+
|
|
436
|
+
With the guard, a user who goes in with a press (a click or a tap on your
|
|
437
|
+
control) has the keyboard put on into the tile itself by its dock, so that
|
|
438
|
+
what they type next reaches the tile at once: its document, and a field of
|
|
439
|
+
it once they press or Tab into one, or the tile puts the keyboard there. A
|
|
440
|
+
Tab from there goes on from wherever they were in the tile last, if they
|
|
441
|
+
had been in it. One who goes in from the keyboard (Enter or Space on your
|
|
442
|
+
control) has it left where the next Tab goes to the first thing in the
|
|
443
|
+
tile, and what they type before that Tab reaches nothing. Call
|
|
444
|
+
`guard.focus()` from your control's own handler: called from anywhere else
|
|
445
|
+
(after an `await`, say), the guard cannot tell a press from a key, and
|
|
446
|
+
takes it for a key.
|
|
447
|
+
|
|
448
|
+
From the keyboard, that works in Chrome alone. In answer to a key, Firefox
|
|
449
|
+
and WebKit (Safari, and every WebView on iOS) do not let a page put the
|
|
450
|
+
keyboard into a frame: Enter or Space on your control leaves the keyboard on
|
|
451
|
+
your control, and a user with only a keyboard has no way in. (Measured in
|
|
452
|
+
Firefox 160, headless, where a press does go in, and in the WebKit of macOS
|
|
453
|
+
15.7, in a WKWebView kept off screen, which was sent keys and no press.) The
|
|
454
|
+
guard's own stop does not go in that way, and works in all three: keep it
|
|
455
|
+
(the default) unless you need a way in of your own.
|
|
456
|
+
|
|
457
|
+
This is about the Tab key and no more: a tile's script can still put the
|
|
458
|
+
focus in the tile itself, with no click and no key, and `tabindex` does
|
|
459
|
+
nothing about that (the focus guard does). The option takes a whole number
|
|
460
|
+
from -32767 to 32767; anything else throws, since a browser would read it as
|
|
461
|
+
no tabindex at all.
|
|
462
|
+
|
|
463
|
+
### `refuse`
|
|
464
|
+
|
|
465
|
+
A browser hands some features to every frame unasked. In Chrome 157 a tile
|
|
466
|
+
has fifteen of them unless they are refused: picture-in-picture and the
|
|
467
|
+
gamepad among them, so that it can put a window of its own over whatever its
|
|
468
|
+
user is doing, or read a game controller, and synchronous requests, unload
|
|
469
|
+
handlers and the client hints that say which browser and device this is.
|
|
470
|
+
Refuse a feature, and it is refused to everything in the frame, the frames
|
|
471
|
+
the tile makes included, whatever those ask for.
|
|
472
|
+
|
|
473
|
+
`refuse` is the list in full, as `sandbox` is the attribute in full. When
|
|
474
|
+
nothing is said it is `['sync-xhr']`: a synchronous request holds up the
|
|
475
|
+
thread the tile shares with its runtime, and never brings a tile its own
|
|
476
|
+
files (Chrome and Safari do not hand it to the tile's worker, so the
|
|
477
|
+
loading server answers it with a 404; Firefox hands it to a worker whose
|
|
478
|
+
answer has to come through the very thread it holds, so it fails a minute
|
|
479
|
+
later). What a tile loses is a synchronous request for a `blob:` or `data:`
|
|
480
|
+
address; and one for its own files, which had the loading server's 404, now
|
|
481
|
+
throws a `NetworkError` at once, which stops a script that does not catch
|
|
482
|
+
it. A list of your own takes the place of that one, so name `sync-xhr`
|
|
483
|
+
in it to keep it refused; `[]` refuses nothing, and the frame then has no
|
|
484
|
+
`allow` attribute:
|
|
485
|
+
|
|
486
|
+
```js
|
|
487
|
+
import { REFUSABLE } from '@dasl/tile-loader';
|
|
488
|
+
|
|
489
|
+
tile.renderContent(300, { refuse: ['sync-xhr', 'picture-in-picture', 'gamepad'] });
|
|
490
|
+
tile.renderContent(300, { refuse: REFUSABLE }); // everything the loader knows
|
|
491
|
+
tile.renderContent(300, { refuse: [] }); // nothing: synchronous requests given back
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Each name goes into the frame's `allow` attribute as `'none'`. It only takes
|
|
495
|
+
away: nothing given here grants a feature. The names the loader knows are
|
|
496
|
+
those of `REFUSABLE` (from `refusableFeatures` in `@dasl/tile-lexicon`), and
|
|
497
|
+
a name it does not know throws. An `allow` attribute you set on the frame
|
|
498
|
+
yourself replaces the one the loader wrote, its default with it.
|
|
499
|
+
|
|
500
|
+
A browser goes by the names it knows and passes over the others, so the same
|
|
501
|
+
list takes away less outside Chrome. What each name does, as of 22 November
|
|
502
|
+
2026: "refused" where that was seen in Chrome 157, Firefox 160 or the WebKit
|
|
503
|
+
of Safari 26.4 (in a WKWebView on macOS 15.7), as said below the table;
|
|
504
|
+
"refused (source)" where the browser's own code says so and nothing was run;
|
|
505
|
+
"not refused" where the browser has the feature and no policy for it, so
|
|
506
|
+
that the name does nothing there; "none" where the browser has no such
|
|
507
|
+
feature. Below "unasked" are the features a frame has in Chrome without
|
|
508
|
+
being given them; in Chrome a tile has the others only where your own
|
|
509
|
+
frame's `allow` attribute gives them. Firefox 160 gives a frame four of them
|
|
510
|
+
unasked: `aria-notify`, `gamepad`, `picture-in-picture` and
|
|
511
|
+
`storage-access`.
|
|
512
|
+
|
|
513
|
+
| Name | What it is | Chrome | Firefox | Safari |
|
|
514
|
+
| --- | --- | --- | --- | --- |
|
|
515
|
+
| `accelerometer` | motion sensors | refused | none | refused (source) |
|
|
516
|
+
| `gyroscope` | | refused | none | refused (source) |
|
|
517
|
+
| `magnetometer` | | refused | none | refused (source) |
|
|
518
|
+
| `autoplay` | sound and video without a press | refused | not refused | not refused |
|
|
519
|
+
| `camera` | | refused | refused | refused (source) |
|
|
520
|
+
| `microphone` | | refused | refused | refused (source) |
|
|
521
|
+
| `clipboard-read` | reading the clipboard | refused | not refused | not refused |
|
|
522
|
+
| `clipboard-write` | writing to it | refused | not refused | not refused |
|
|
523
|
+
| `display-capture` | sharing the screen | refused | refused | refused (source) |
|
|
524
|
+
| `encrypted-media` | DRM | refused | not refused | not refused |
|
|
525
|
+
| `fullscreen` | | refused | refused | refused (source) |
|
|
526
|
+
| `geolocation` | | refused | refused | refused (source) |
|
|
527
|
+
| `midi` | MIDI devices | refused | not refused | none |
|
|
528
|
+
| `screen-wake-lock` | keeping the screen on | refused | refused | refused (source) |
|
|
529
|
+
| `web-share` | the system's share sheet | refused | refused | refused (source) |
|
|
530
|
+
| `xr-spatial-tracking` | WebXR | refused | none | refused (source), where Safari has it |
|
|
531
|
+
| **unasked:** | | | | |
|
|
532
|
+
| `gamepad` | game controllers | refused | refused | refused |
|
|
533
|
+
| `picture-in-picture` | a video in a window of its own | refused | refused | not refused |
|
|
534
|
+
| `sync-xhr` | synchronous requests; refused when nothing is said | refused | not refused | refused |
|
|
535
|
+
| `media-playback-while-not-visible` | playing on while out of view | refused | not refused | not refused |
|
|
536
|
+
| `unload` | unload handlers | refused | not refused | not refused |
|
|
537
|
+
| `storage-access` | asking for the site's cookies (the sandbox refuses it anyway) | refused | refused | refused (source) |
|
|
538
|
+
| `aria-notify` | announcements to a screen reader | refused | refused | none |
|
|
539
|
+
| `deferred-fetch-minimal` | requests put off until the page has gone (`fetchLater`) | refused | none | none |
|
|
540
|
+
| `private-state-token-issuance` | private state tokens | refused | none | none |
|
|
541
|
+
| `private-state-token-redemption` | | refused | none | none |
|
|
542
|
+
| `ch-ua` | client hints: which browser, in a request's headers | refused | none | none |
|
|
543
|
+
| `ch-ua-mobile` | whether it is a phone | refused | none | none |
|
|
544
|
+
| `ch-ua-platform` | which system | refused | none | none |
|
|
545
|
+
| `ch-ua-high-entropy-values` | the details: versions, model, architecture | refused | none | none |
|
|
546
|
+
| `ch-save-data` | whether the user saves data | refused | none | none |
|
|
547
|
+
|
|
548
|
+
Seen: every name refused in Chrome (with `refuse: REFUSABLE`,
|
|
549
|
+
`document.featurePolicy.allowedFeatures()` is empty in the tile, in a frame
|
|
550
|
+
it makes asking for every feature with `*`, and in its runtime's page above
|
|
551
|
+
it); the same in Firefox, which shows a page what it allows once a
|
|
552
|
+
preference says so (`dom.security.permissionsPolicy.webidl.enabled`, which
|
|
553
|
+
changes nothing it enforces): the names it knows are those it refuses in the
|
|
554
|
+
table, and with `refuse: REFUSABLE` its `allowedFeatures()` is empty in the
|
|
555
|
+
same three places, `navigator.getGamepads()` throws and
|
|
556
|
+
`document.pictureInPictureEnabled` is false, as `picture-in-picture` alone
|
|
557
|
+
makes it; a synchronous request there still holds the tile for a minute. In
|
|
558
|
+
Safari's WebKit the gamepad and synchronous requests are refused,
|
|
559
|
+
`document.pictureInPictureEnabled` stays true, and there is no `ariaNotify`
|
|
560
|
+
and no `fetchLater` yet. Refusing the client hints leaves
|
|
561
|
+
`navigator.userAgentData.brands` as it was, which the runtime reads to tell
|
|
562
|
+
Chromium, and `getHighEntropyValues()` then gives the brands, the platform
|
|
563
|
+
and whether it is a phone, and nothing more. Read in the browsers' code:
|
|
564
|
+
Chromium's `permissions_policy_features.json5` and WebKit's
|
|
565
|
+
`Source/WebCore/html/PermissionsPolicy.cpp`; and MDN's pages on
|
|
566
|
+
`Permissions-Policy`, with its compatibility data. Neither Firefox nor Safari
|
|
567
|
+
reads a `Permissions-Policy` header (both were seen to pass over one; Firefox
|
|
568
|
+
bug 1531012): the `allow` attribute is the one setting that every engine
|
|
569
|
+
takes. Browsers move, and Firefox only lately came to picture-in-picture:
|
|
570
|
+
check again before you count on a row.
|
|
571
|
+
|
|
572
|
+
#### What `refuse` cannot take away
|
|
573
|
+
|
|
574
|
+
Outside Chrome, some of what a tile has unasked no setting of a page
|
|
575
|
+
reaches. A host that cannot live with it there has no way but not to show
|
|
576
|
+
tiles in that browser, or, in an app, the WebView's own settings:
|
|
577
|
+
|
|
578
|
+
- **Safari, and every WebView on iOS:** picture-in-picture (a tile can pop a
|
|
579
|
+
video of its own out over everything, on a press), unload handlers, sound
|
|
580
|
+
and video by the browser's own rules, encrypted media, and the clipboard
|
|
581
|
+
on a press: writing to it, and reading it once the user picks the
|
|
582
|
+
browser's "Paste".
|
|
583
|
+
- **Firefox:** synchronous requests (one holds the tile's thread for a
|
|
584
|
+
minute, and then fails), unload handlers, sound and video by the browser's
|
|
585
|
+
own rules, encrypted media, and the clipboard on a press, as in Safari.
|
|
586
|
+
- **Every browser:** copying on a press with `execCommand('copy')`, and what
|
|
587
|
+
a live region of the tile's own announces to a screen reader, which no
|
|
588
|
+
policy governs.
|
|
589
|
+
- **In an app's WebView:** on iOS, `allowsPictureInPictureMediaPlayback =
|
|
590
|
+
false` and `mediaTypesRequiringUserActionForPlayback = .all` on the
|
|
591
|
+
`WKWebViewConfiguration`; on Android, deny in
|
|
592
|
+
`WebChromeClient.onPermissionRequest()` and
|
|
593
|
+
`onGeolocationPermissionsShowPrompt()`, and
|
|
594
|
+
`setMediaPlaybackRequiresUserGesture(true)`.
|
|
595
|
+
|
|
281
596
|
## Keeping a tile from steering the user
|
|
282
597
|
|
|
283
598
|
A tile cannot reach your page, but it runs in the middle of it, and the person
|
|
@@ -312,6 +627,9 @@ It still does not mean "the user asked for this link": any press or key inside
|
|
|
312
627
|
the tile makes its requests activated for a few seconds, and the tile picks
|
|
313
628
|
which address to send. Show the user where a link goes, and let them decide.
|
|
314
629
|
|
|
630
|
+
The focus guard asks the dock something more of the keyboard (see "The
|
|
631
|
+
keyboard"); `activated` is the same for that.
|
|
632
|
+
|
|
315
633
|
A loading server from before its dock said this (`@dasl/tile-server` 3.1 and
|
|
316
634
|
earlier) leaves `activated` with the meaning it had: the user did something on
|
|
317
635
|
the page, somewhere. Nothing that arrives in the dock's name is ever used to
|
|
@@ -439,9 +757,17 @@ double click on its buttons.
|
|
|
439
757
|
### The keyboard
|
|
440
758
|
|
|
441
759
|
A tile's script can call `focus()` on a field of its own with nobody having
|
|
442
|
-
touched anything.
|
|
443
|
-
|
|
444
|
-
|
|
760
|
+
touched anything. Where that takes the keyboard, what the user types next,
|
|
761
|
+
meaning it for a field of yours, goes to the tile; in Firefox nothing in a
|
|
762
|
+
frame's sandbox governs that. Chrome, from 158 on, refuses a sandboxed frame
|
|
763
|
+
`focus-without-user-activation` unless its `allow` attribute names it. A
|
|
764
|
+
tile's document is in a frame of the shuttle's, in one of the dock's, in the
|
|
765
|
+
loader's, all of them sandboxed, and none of them names it: there such a
|
|
766
|
+
`focus()` leaves the keyboard where it was, and naming it on the loader's
|
|
767
|
+
frame alone changes nothing (measured in Chrome 158, headless). In WebKit a
|
|
768
|
+
frame of another origin did not take the keyboard that way either, sandboxed
|
|
769
|
+
or not (measured in a WKWebView on macOS 15.7, not in Safari). If your page
|
|
770
|
+
has fields of its own, turn the guard on when you render the tile:
|
|
445
771
|
|
|
446
772
|
```js
|
|
447
773
|
import { guardFocus } from '@dasl/tile-loader/guard';
|
|
@@ -449,17 +775,212 @@ const frame = tile.renderContent();
|
|
|
449
775
|
guardFocus(tile, frame);
|
|
450
776
|
```
|
|
451
777
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
778
|
+
A guarded tile is out of the tab order: someone tabbing down your page
|
|
779
|
+
passes over its frame, and never ends up typing into the tile, or handing it
|
|
780
|
+
their keys, by chance. In the frame's place in the tab order the guard puts
|
|
781
|
+
a stop of its own, right before the frame: a button of your page's (the
|
|
782
|
+
class `tile-enter`, `ENTER_CLASS`) that takes no room and cannot be seen
|
|
783
|
+
until it has the keyboard. Then it lies over the tile, with a ring round it
|
|
784
|
+
as the guard's layer has (below), and says "Use the keyboard in" and the
|
|
785
|
+
tile's name (its first 60 characters), or "this tile" for a tile with none,
|
|
786
|
+
which is also its name for assistive technology; `enterLabel` gives your
|
|
787
|
+
own words. It takes no press while it shows: a press or a tap where it lies
|
|
788
|
+
goes into the tile, to what is under it, as it would with no stop.
|
|
789
|
+
|
|
790
|
+
Enter or Space on the stop lets the frame into the tab order for the user's
|
|
791
|
+
next Tab, and the stop then says "Press Tab to go in" (`tabLabel` gives your
|
|
792
|
+
own words). That Tab goes from the stop into the tile, as a Tab into any
|
|
793
|
+
frame in the tab order does, and your page sees it. So does a press that the
|
|
794
|
+
browser aims at the stop itself, as it does for a screen reader, which also
|
|
795
|
+
puts the keyboard on the stop where it was not. It is the same in Chrome,
|
|
796
|
+
Firefox and WebKit, which is why the stop does not put the keyboard in the
|
|
797
|
+
frame itself (see "`tabindex`" above). The frame is out of
|
|
798
|
+
the tab order again as soon as the keyboard has left the stop, into the
|
|
799
|
+
tile or anywhere else, ten seconds after the stop was pressed, or once
|
|
800
|
+
another layer lies over the tile (below), and the stop then says what it
|
|
801
|
+
said before. While it
|
|
802
|
+
is in, only a Tab forward from the stop counts as the user going into it,
|
|
803
|
+
and once that Tab has taken them in it counts for nothing more: should the
|
|
804
|
+
keyboard go on into another frame and the tile take it back, that is judged
|
|
805
|
+
afresh. So it is where the keyboard went anywhere else before the tile had
|
|
806
|
+
it (another tile taking it on the way, say).
|
|
807
|
+
|
|
808
|
+
While another layer lies over the tile (the guard's own after a refusal, or
|
|
809
|
+
`engage`'s over a tile that is not picked), that layer is where Tab stops,
|
|
810
|
+
and the guard's stop is out of the tab order. The stop goes into the shadow
|
|
811
|
+
tree the frame is in, is put right before the frame once the frame is in
|
|
812
|
+
your page (and again if anything comes between them), leaves your page with
|
|
813
|
+
the frame and comes back with it, and goes when the guard stops. Its look is
|
|
814
|
+
the layer's, a sheet whose rules weigh nothing: your rules for `.tile-enter`
|
|
815
|
+
and `.tile-pick-label` win.
|
|
816
|
+
|
|
817
|
+
What that costs keyboard users: two keys more to start typing in a tile,
|
|
818
|
+
Enter on the stop and then Tab, where Tab alone took them in before, and
|
|
819
|
+
what they type before that Tab reaches nothing. In Chrome and Firefox that
|
|
820
|
+
Tab lands on the first field of the tile. In WebKit it lands on the tile's
|
|
821
|
+
page, where what is typed reaches the tile but no field of it, and the next
|
|
822
|
+
Tab goes to the first field. Tab out of a tile's last field goes on to the
|
|
823
|
+
next tile's stop, or to what comes after the tile on your page. Shift+Tab
|
|
824
|
+
out of a tile's first field lands on that tile's own stop, which shows over
|
|
825
|
+
the tile again: one more Shift+Tab goes on back, and Enter and Tab there go
|
|
826
|
+
back in. (Measured in Chrome 157 and Firefox 160, headless, and in the
|
|
827
|
+
WebKit of macOS 15.7 in a WKWebView kept off screen and sent keys: the same
|
|
828
|
+
keys in all three.) Nothing typed on the way in lands in a page of the
|
|
829
|
+
dock's, so a press into another guarded tile just after is judged as any
|
|
830
|
+
other: in Chrome, one 0.8 s after was the user's. After your own way in from
|
|
831
|
+
the keyboard it is refused for a few seconds (see below).
|
|
832
|
+
|
|
833
|
+
What it costs mouse and touch users: nothing, unless they press Tab. One who
|
|
834
|
+
presses Tab out of a tile, or Shift+Tab, has the keyboard on a stop, which
|
|
835
|
+
shows over its tile and takes no press: their next press or tap goes where
|
|
836
|
+
they aim it, into that tile as anywhere else, and what they type before it
|
|
837
|
+
is lost.
|
|
838
|
+
|
|
839
|
+
What it costs screen reader users: one more button for each tile, and on a
|
|
840
|
+
phone a swipe through the page stops on it. Reading what is in a tile works
|
|
841
|
+
as before, but one whose screen reader takes the keyboard into the tile by
|
|
842
|
+
its own means has it given back (below): the stop is their way in, activated
|
|
843
|
+
and then followed by Tab. What was measured is Chrome's accessibility tree,
|
|
844
|
+
which has a button for each stop, named for its tile, focusable (also while
|
|
845
|
+
it takes no press), focused where the keyboard is, and named "Press Tab to
|
|
846
|
+
go in" once pressed. No screen reader was run: whether one reads out the new
|
|
847
|
+
name, and how a press of one on the stop goes, were not tried (the loader's
|
|
848
|
+
own tests, which run without a browser, hold that a press aimed at the stop
|
|
849
|
+
lets the frame in as a key does). A checker of accessibility may flag the
|
|
850
|
+
frame (a frame out of the tab order with things in it that take the
|
|
851
|
+
keyboard), though the stop is a way in. And the stop is an element of yours
|
|
852
|
+
in the box that holds the frame: a framework that owns that box may take it
|
|
853
|
+
away, and the guard puts it back when it next looks.
|
|
854
|
+
|
|
855
|
+
Firefox and WebKit do not let a page put the keyboard into a frame in answer
|
|
856
|
+
to a key: there `focus()` called from a key leaves the keyboard where it
|
|
857
|
+
was (measured in Firefox 160, headless, driven over WebDriver BiDi, where it
|
|
858
|
+
goes in when called from a press, and in the WebKit of macOS 15.7 in a
|
|
859
|
+
WKWebView, which was sent keys and no press; neither in a window of its
|
|
860
|
+
own). The guard's stop does not depend on it, and works there. What still
|
|
861
|
+
goes in that way does nothing there from the keyboard: Enter or Space on a
|
|
862
|
+
control of yours that calls `focus()` (with `tabOrder: 'out'`), and a pick
|
|
863
|
+
by Enter or Space on `engage`'s layer or on the guard's own layer after a
|
|
864
|
+
refusal (below). A press or a tap on any of them works in Firefox.
|
|
865
|
+
|
|
866
|
+
So say otherwise if you have to: `tabOrder: 'out'` keeps the frame out of
|
|
867
|
+
the tab order with no stop of the guard's, for a page that has its own way
|
|
868
|
+
in (it calls `focus()` on what `guardFocus` returned); `tabOrder: 'keep'`
|
|
869
|
+
leaves the frame in the tab order as you made it, as the guard did in
|
|
870
|
+
`@dasl/tile-loader` 3 and earlier. A `tabindex` you give the frame through
|
|
871
|
+
`renderContent()` does not keep it in: only `tabOrder: 'keep'` does.
|
|
872
|
+
|
|
873
|
+
Focus arriving in the tile's frame stays there when the user went in by your
|
|
874
|
+
way in, tabbed into it (from the guard's stop, or into a frame you keep in
|
|
875
|
+
the tab order), or pressed in it. Your page sees the Tab key, and where it
|
|
876
|
+
took the user: one that took them to another field of yours is not one into
|
|
877
|
+
the tile, and nor is one while the frame is out of the tab order, which
|
|
878
|
+
cannot have taken them there. It cannot see the press, so the guard asks the
|
|
879
|
+
tile's dock, which knows whether the user pressed or typed inside that tile
|
|
880
|
+
(see "What `activated` means"). In every other case focus goes back to the
|
|
881
|
+
element that had it: when the user was typing in a field of yours a moment
|
|
882
|
+
ago, when a mouse is somewhere else on the page, and when the dock says the
|
|
883
|
+
user did not act in the tile. Where nothing of yours had it then (the user
|
|
884
|
+
had pressed on the plain text of the page, say, or gone on into another
|
|
885
|
+
tile), it goes back to the page and to no element: not to a button they used
|
|
886
|
+
a while ago, which their next Space or Enter would press. That holds each
|
|
887
|
+
time the keyboard arrives, also when it comes from another frame of your
|
|
888
|
+
page: a tile the user went into once does not get to take the keyboard back
|
|
889
|
+
from the next one they go into.
|
|
890
|
+
|
|
891
|
+
Your page sees nothing of the keyboard going from one frame of yours into the
|
|
892
|
+
tile, and the guard finds it there only when it next looks (`pollMs`). So
|
|
893
|
+
while the keyboard is in a frame of your page, the guard has the tile's dock
|
|
894
|
+
watch it come in. Each time it comes in, the dock notes whether the user had
|
|
895
|
+
just pressed or typed in the tile. Where they had not, the dock says so at
|
|
896
|
+
once, without waiting to be asked, and the keyboard is given back as for the
|
|
897
|
+
dock's no. Keys the user typed into the tile before it was given back would
|
|
898
|
+
make them look as if they had acted there afterwards, so that no stands: the
|
|
899
|
+
dock goes on saying no each time the keyboard comes into the tile, until
|
|
900
|
+
those keys no longer count (about five seconds after the last of them), and
|
|
901
|
+
goes on watching for that long after the guard has stopped asking. A Tab on
|
|
902
|
+
your page into the tile, or your own way in, is the user going in, and ends
|
|
903
|
+
it at once. All of this only ever refuses: where the dock says the user had
|
|
904
|
+
acted, or cannot say, the guard goes by what it did before. The dock looks
|
|
905
|
+
every few milliseconds while it watches, which costs a little (in Chrome on a
|
|
906
|
+
laptop, under one percent of a core for each tile watching), and only while
|
|
907
|
+
the keyboard is in a frame of your page and for those few seconds after; a
|
|
908
|
+
loading server whose dock does not watch (`@dasl/tile-server` 3.2 and
|
|
909
|
+
earlier) leaves the guard with the dock's word as it stands when the guard
|
|
910
|
+
asks.
|
|
911
|
+
|
|
912
|
+
What that costs: a press or a tap of the user's into the tile is refused,
|
|
913
|
+
and the keyboard given back, in the few seconds after a key of theirs reached
|
|
914
|
+
the tile before it was given back, or after a press of theirs into it was
|
|
915
|
+
refused: the dock cannot tell such a press from keys typed into the tile. It
|
|
916
|
+
is refused too in the few seconds after the user went into any tile of the
|
|
917
|
+
page by your way in from the keyboard, and pressed Tab or typed (those keys
|
|
918
|
+
land in a page of the dock's own), as it was before; when the docks of the
|
|
919
|
+
page were kept busy for a moment as it came
|
|
920
|
+
(on a slow phone, a page adding another tile does that for a few hundred
|
|
921
|
+
milliseconds); and after a press into the tile that did not bring the
|
|
922
|
+
keyboard along, at such a moment. The dock's word comes within a few
|
|
923
|
+
milliseconds, so a key reaches the tile only when it is typed that quickly,
|
|
924
|
+
or when the dock is slow to answer.
|
|
925
|
+
|
|
926
|
+
Each of those refusals is only the dock's best guess: someone did act in the
|
|
927
|
+
tile, and it may have been the user. The dock says so, and the guard does
|
|
928
|
+
not count such a refusal against the tile. Instead a layer of your page's
|
|
929
|
+
lies over the tile until the user picks it: a press or a tap on it, or Enter
|
|
930
|
+
or Space while it has the keyboard, puts the keyboard in the tile as your
|
|
931
|
+
way in does, and ends the dock's no. Picked with a press or a tap, the
|
|
932
|
+
keyboard goes on into the tile, where what they type next reaches it; picked
|
|
933
|
+
with Enter or Space, it is where their Tab goes on into the tile (in Chrome:
|
|
934
|
+
in Firefox and WebKit a pick from the keyboard leaves the keyboard outside
|
|
935
|
+
the tile, see above). So a user who presses again picks the tile, what they
|
|
936
|
+
type then reaches it, and their next press goes where they aim. Until it is
|
|
937
|
+
picked, the keyboard coming into that tile is never taken for the user's
|
|
938
|
+
doing: it is given back and counted, so the layer spares the tile at most
|
|
939
|
+
one giving back. Neither the tile nor anything but the user lifts it: only a
|
|
940
|
+
press, a tap or a key the browser says is theirs, or your own way in
|
|
941
|
+
(`focus()`); or the dock, once its no is over. The guard asks it now and
|
|
942
|
+
then (every half second at most) while the keyboard is out of the tile, and
|
|
943
|
+
the layer lifts on its own when the dock says that what its no went by has
|
|
944
|
+
run out with the keyboard elsewhere: about five seconds after the user's
|
|
945
|
+
last press into the tile, unless they are on the layer itself. Then the next
|
|
946
|
+
press into the tile is judged as any other. Such a refusal in the minute
|
|
947
|
+
after a layer lifted on its own (`spareMs`) is counted all the same, with a
|
|
948
|
+
layer as well: a tile that could have its dock's nos taken for guesses, and
|
|
949
|
+
waited each time for the layer to go, is held to the same count as before. A
|
|
950
|
+
pick of the user's, or your way in, spares the next one again. The layer is
|
|
951
|
+
right after the frame, in the element that holds it, which is made a
|
|
952
|
+
positioned box (`position: relative`) while the layer is there if it is not
|
|
953
|
+
one already; the layer is where Tab stops meanwhile, in place of the guard's
|
|
954
|
+
stop (and of the frame, which is out of the tab order then even with
|
|
955
|
+
`tabOrder: 'keep'`). It is the same kind of layer as `engage`'s (see "Press
|
|
956
|
+
to use"), with the class `tile-engage` and its own, `tile-pick`
|
|
957
|
+
(`PICK_CLASS`). It shows that the tile waits for the user: a ring round the
|
|
958
|
+
tile, and in the middle a label (`tile-pick-label`, `PICK_LABEL_CLASS`) that
|
|
959
|
+
says "Tap or click to use", which is also its name for assistive technology;
|
|
960
|
+
`pickLabel` gives your own words. That look is a style sheet the guard gives
|
|
961
|
+
your page once, whose rules weigh nothing (`:where`), so that any rule of
|
|
962
|
+
yours for `.tile-pick` or `.tile-pick-label` wins; it is an adopted sheet
|
|
963
|
+
where the browser has those, which a policy that refuses inline style does
|
|
964
|
+
not refuse, and a style element first in the head otherwise. A frame in a
|
|
965
|
+
shadow tree has its layer there, and the sheet is given to that tree once as
|
|
966
|
+
well, where your rules for it go too. The faint background the layer needs
|
|
967
|
+
to take a press over a frame is set on the element itself. With `pick:
|
|
968
|
+
false` such a refusal is counted like any other, and three in ten seconds
|
|
969
|
+
stop the tile. A loading server whose dock does not say whether it was sure
|
|
970
|
+
(`@dasl/tile-server` 3.2 and earlier) has every refusal counted, as before.
|
|
971
|
+
|
|
972
|
+
A way in of your own goes through the guard: a control of yours calls
|
|
973
|
+
`focus()` on what `guardFocus` returned, not on the frame, and the keyboard
|
|
974
|
+
it puts in the tile is the user's, as if they had tabbed in (see "The frame
|
|
975
|
+
a tile runs in"). Give the guard `tabOrder: 'out'` then, unless you want its
|
|
976
|
+
stop as well. From the keyboard it goes in in Chrome alone (see
|
|
977
|
+
"`tabindex`").
|
|
978
|
+
|
|
979
|
+
Whatever the frame, do not put the keyboard in it by calling `focus()` on the
|
|
980
|
+
frame itself while a guard is on a tile of your page: in Chrome the page then
|
|
981
|
+
goes on naming that frame as the one with the keyboard after it has gone to
|
|
982
|
+
another, and a guard goes by what the page names. Where a frame has no guard
|
|
983
|
+
to ask, go in through its window: `frame.contentWindow.focus()`.
|
|
463
984
|
|
|
464
985
|
What it costs a tile that means no harm: its own `focus()` with no press in
|
|
465
986
|
it (an `autofocus`) does not stick. And a click into the tile within a second
|
|
@@ -470,6 +991,20 @@ the tile by its own means, with no Tab and no press that your page or the
|
|
|
470
991
|
dock sees, has it given back as a script's would be, each time. That has not
|
|
471
992
|
been tried with a screen reader; try it with yours before you turn this on.
|
|
472
993
|
|
|
994
|
+
Nor does your page see a Tab pressed inside another frame. A guarded tile
|
|
995
|
+
is out of the tab order, so nobody tabs out of one tile straight into it.
|
|
996
|
+
Where you keep it in (`tabOrder: 'keep'`), a user who does has the keyboard
|
|
997
|
+
given back, and counted, as a script's would be: three times in ten seconds
|
|
998
|
+
stops the tile.
|
|
999
|
+
|
|
1000
|
+
On a screen that takes fingers as well as a mouse (a touch laptop), your page
|
|
1001
|
+
sees nothing of a finger in a frame. Before the guard has seen any pointer, a
|
|
1002
|
+
tap into a guarded tile from your page itself is asked about. One from another
|
|
1003
|
+
frame of your page is given back and counted in the same way, and so is any
|
|
1004
|
+
tap into the tile once the guard last saw the mouse elsewhere: it cannot tell
|
|
1005
|
+
them from the tile's script taking the keyboard. The way in serves these users
|
|
1006
|
+
too.
|
|
1007
|
+
|
|
473
1008
|
What it does not do:
|
|
474
1009
|
|
|
475
1010
|
- Giving focus back does not win against a tile that takes it again at once:
|
|
@@ -477,16 +1012,20 @@ What it does not do:
|
|
|
477
1012
|
keyboard three times in ten seconds is reported (`onAbuse('focus', count)`)
|
|
478
1013
|
and stopped (see "A tile that keeps at it is stopped").
|
|
479
1014
|
- For about five seconds after a real press or key in the tile, the tile can
|
|
480
|
-
take the keyboard back and keep it.
|
|
481
|
-
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1015
|
+
take the keyboard back and keep it, where nothing was refused in between.
|
|
1016
|
+
- Until the guard has heard from the dock, a key the user types goes to the
|
|
1017
|
+
tile: a few milliseconds where the dock watches, up to `pollMs` where it
|
|
1018
|
+
does not and the keyboard came from another frame. A key typed in the few
|
|
1019
|
+
milliseconds before the dock first finds the keyboard in the tile counts as
|
|
1020
|
+
their having acted in it, and so does any key, where the dock does not
|
|
1021
|
+
watch. The dock gets `dockMs` to answer; one that has answered before and
|
|
1022
|
+
now does not is taken to say no, so keeping it busy gains a tile nothing.
|
|
485
1023
|
- With a loading server whose dock does not answer (`@dasl/tile-server` 3.1
|
|
486
1024
|
and earlier), the guard has only what your page can see. A mouse resting on
|
|
487
1025
|
the tile, and any touch screen, cannot be told from a press there, and the
|
|
488
1026
|
tile keeps the keyboard.
|
|
489
|
-
-
|
|
1027
|
+
- Where you keep guarded tiles in the tab order (`tabOrder: 'keep'`), a
|
|
1028
|
+
user who tabs out of one tile straight into the next, with nothing of
|
|
490
1029
|
yours to stop at between them, has the keyboard given back: your page saw
|
|
491
1030
|
no Tab, and the second tile's dock no key. Put something of yours that
|
|
492
1031
|
takes focus between two tiles.
|
|
@@ -496,7 +1035,11 @@ A guard listens to your page, so it does not go with the tile the way
|
|
|
496
1035
|
you call `stop()` on what it returned. Turn it on when you render the tile,
|
|
497
1036
|
before the tile runs. Its numbers are first guesses: `FOCUS_GUARD` has them,
|
|
498
1037
|
and the options override any (`tabMs`, `typingMs`, `grabs`, `withinMs`,
|
|
499
|
-
`dockMs`, `pollMs`).
|
|
1038
|
+
`dockMs`, `pollMs`, `spareMs`). `pick: false` turns off the layer the user
|
|
1039
|
+
picks a tile on after a refusal the dock was not sure of, and `pickLabel`
|
|
1040
|
+
gives it your own words. `tabOrder` says where the frame is in the tab
|
|
1041
|
+
order (`'stop'`, the default, `'out'` or `'keep'`), `enterLabel` gives
|
|
1042
|
+
the guard's stop your own words, and `tabLabel` what it says once pressed.
|
|
500
1043
|
|
|
501
1044
|
### Scrolling
|
|
502
1045
|
|
|
@@ -664,9 +1207,13 @@ layer back; so does `release()`.
|
|
|
664
1207
|
|
|
665
1208
|
Tab does not go into a tile that is not picked (its frame has
|
|
666
1209
|
`tabindex="-1"` meanwhile, and gets back what it had when it is picked). It
|
|
667
|
-
stops at the layer, which comes
|
|
668
|
-
picks the tile and puts the keyboard in its frame, and the next Tab
|
|
669
|
-
the first thing in the tile
|
|
1210
|
+
stops at the layer, which comes after the frame in its box: Enter or Space
|
|
1211
|
+
there picks the tile and puts the keyboard in its frame, and the next Tab
|
|
1212
|
+
goes to the first thing in the tile (in Chrome: Firefox and WebKit do not
|
|
1213
|
+
let the keyboard in that way, see "The keyboard"; a press works there). With
|
|
1214
|
+
the focus guard on as well, the frame stays out of the tab order once the
|
|
1215
|
+
tile is picked: the guard's stop is the way back in to a picked tile, and
|
|
1216
|
+
the layer to one that is not.
|
|
670
1217
|
|
|
671
1218
|
Start a tile the user has just started themselves with `start: 'engaged'`;
|
|
672
1219
|
one that starts by itself, in a feed, not picked.
|
|
@@ -679,6 +1226,12 @@ What it does not do: once picked, a tile can hold a finger, take the
|
|
|
679
1226
|
keyboard and be scrolled through again, until the user presses elsewhere.
|
|
680
1227
|
The other guards still apply then.
|
|
681
1228
|
|
|
1229
|
+
The focus guard puts a layer of the same kind over a tile after a refusal
|
|
1230
|
+
its dock was not sure of (see "The keyboard"). On a tile that waits to be
|
|
1231
|
+
picked, that layer is under `engage`'s: where `engage`'s is back over the
|
|
1232
|
+
tile, the user picks the tile there, and then once more on the guard's,
|
|
1233
|
+
which puts the keyboard in.
|
|
1234
|
+
|
|
682
1235
|
The layer is an element of your page's (`tile-engage`, also `layer` on what
|
|
683
1236
|
`engage` returns), a button to assistive technology, named by `label`. It
|
|
684
1237
|
paints, too faintly to see, and has to: a block that paints nothing does not
|
|
@@ -733,7 +1286,97 @@ runtime lets its worker's registration go, best effort. What the tile stored
|
|
|
733
1286
|
stays until the browser evicts it.
|
|
734
1287
|
|
|
735
1288
|
A tile on a named origin (`namedOrigin`) is the exception throughout: that origin
|
|
736
|
-
is kept on purpose, so `close()` wipes nothing there.
|
|
1289
|
+
is kept on purpose, so `close()` wipes nothing there. So is a tile on the origin
|
|
1290
|
+
its CID names (`cidOrigins`); `tile.ephemeral` says which a tile is.
|
|
1291
|
+
|
|
1292
|
+
## Origins named by a tile's CID
|
|
1293
|
+
|
|
1294
|
+
```js
|
|
1295
|
+
const mothership = new TileMothership({ loadDomain: 'load.webtil.es', cidOrigins: true });
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
With `cidOrigins`, a tile runs on the origin its own content names,
|
|
1299
|
+
`<cid>.<base>`, where `<cid>` is the CID of its manifest as this loader
|
|
1300
|
+
computed it from the bytes it loaded: the DRISL of the record's `tile` on AT
|
|
1301
|
+
(`tile.manifestCid`), the header of a .tile file as the file has it
|
|
1302
|
+
(`tile.cid`). No option takes a CID, and no address names one: a host cannot
|
|
1303
|
+
point a tile at another tile's origin. `tile.getLoadSource()` and the frames
|
|
1304
|
+
`renderContent()` makes name that origin, every time, and so does every page
|
|
1305
|
+
that runs the same tile.
|
|
1306
|
+
|
|
1307
|
+
What is that for: a tile that keeps what it stores, for as long as it is that
|
|
1308
|
+
tile. A game's saves, a document's notes, its preferences, a tile in a feed
|
|
1309
|
+
that keeps its state when it is scrolled away and back. Its worker stays
|
|
1310
|
+
registered there too.
|
|
1311
|
+
|
|
1312
|
+
What it takes:
|
|
1313
|
+
|
|
1314
|
+
- **The tile server's runtime holds the origin to its tile.** Anyone can name
|
|
1315
|
+
such an origin, and every byte served there comes from the page's loader,
|
|
1316
|
+
so the runtime on the origin checks what it is handed against its own name:
|
|
1317
|
+
the manifest's bytes against the CID, each resource against the CID the
|
|
1318
|
+
manifest lists for it, and serves the headers the manifest lists, never the
|
|
1319
|
+
loader's (a `hardenResponse()` of yours adds nothing there). The loader
|
|
1320
|
+
hands it the manifest, and runs a tile there only once the dock has said
|
|
1321
|
+
that its runtime does this (`@dasl/tile-server` 4.0 and later): otherwise
|
|
1322
|
+
the tile fires `error` with `version`, and a refusal from the runtime is
|
|
1323
|
+
`integrity`. The loading server has to be at `load.<base>`.
|
|
1324
|
+
- **A tile with nothing to be named by** runs on an origin made for the load,
|
|
1325
|
+
as without the option: a webxdc tile, one in memory, and one whose loader
|
|
1326
|
+
has no manifest bytes to give. `tile.ephemeral` is `false` for a tile on the
|
|
1327
|
+
origin its CID names, `true` otherwise.
|
|
1328
|
+
- **It is kept**: `close()` wipes nothing and resolves `false`, and the frame
|
|
1329
|
+
is plain unless you ask for `credentialless: true`, which keeps nothing past
|
|
1330
|
+
the page in Chromium.
|
|
1331
|
+
|
|
1332
|
+
What a tile keeps there, it keeps per tile content, per top-level site and per
|
|
1333
|
+
browser profile, and for as long as the browser keeps it:
|
|
1334
|
+
|
|
1335
|
+
- **A new version starts with nothing.** Another manifest has another CID,
|
|
1336
|
+
and another origin. Nothing carries data from one version to the next: a
|
|
1337
|
+
tile that must gives it to its host over a protocol (tp-data). The old
|
|
1338
|
+
version's origin stays in the browser until it is cleared. The same tile as
|
|
1339
|
+
a .tile file and on AT has two CIDs, and two origins.
|
|
1340
|
+
- **Every run of the tile on one site shares it**: its storage, its worker,
|
|
1341
|
+
and on one page each other's documents. What one run is given, all can have.
|
|
1342
|
+
Do not run on such an origin a tile whose runs must be kept apart (one tile
|
|
1343
|
+
shown across private conversations, say).
|
|
1344
|
+
- **Each site that shows it has its own.** Where the browser keeps storage
|
|
1345
|
+
apart by the top-level site:
|
|
1346
|
+
|
|
1347
|
+
| | Storage and the worker | Cookies of the loading server's domain, in a plain frame |
|
|
1348
|
+
| --- | --- | --- |
|
|
1349
|
+
| Chrome | per top-level site (and per whether an ancestor is of another site) | the same jar on every site, unless its user blocks third-party cookies: a channel between tiles across sites |
|
|
1350
|
+
| Firefox | per top-level site | per top-level site |
|
|
1351
|
+
| Safari | per top-level site; what script wrote may be deleted after seven days of use without a visit to the site | blocked |
|
|
1352
|
+
| A WKWebView | the app's own store | the app's |
|
|
1353
|
+
| Android's WebView | not known | not known |
|
|
1354
|
+
|
|
1355
|
+
Where the page that shows tiles is on the tile server's own site (as
|
|
1356
|
+
webtil.es and its tiles are), every frame is of the same site and a tile's
|
|
1357
|
+
store is that site's own: every page of the site shares it, a link to one
|
|
1358
|
+
included. So are the cookies of that site, in every browser: where it is
|
|
1359
|
+
your site too (as `t.mu.social` is under `mu.social`), a tile in a plain
|
|
1360
|
+
frame there reads the cookies of yours that a script can read, and sets
|
|
1361
|
+
cookies your site then receives. Keep such origins off there.
|
|
1362
|
+
- **Best effort.** Storage is cleared under pressure and by its user.
|
|
1363
|
+
|
|
1364
|
+
And what it costs:
|
|
1365
|
+
|
|
1366
|
+
- **The host name says which tile is shown**, to DNS resolvers, to the
|
|
1367
|
+
network unless the browser hides it (Encrypted Client Hello), and to the
|
|
1368
|
+
tile server and whatever is in front of it. A minted name says nothing.
|
|
1369
|
+
- **Pages of the same site, and every frame in them, can use what the tile
|
|
1370
|
+
kept.** Any page of the site the tile is shown under can run the genuine
|
|
1371
|
+
tile on its origin, with what it kept there, and feed it whatever it likes
|
|
1372
|
+
over the tile protocols, or answer none of its requests, or have its origin
|
|
1373
|
+
wiped. So can any frame in such a page, whatever site the frame is from: an
|
|
1374
|
+
ad, an embedded player, a widget, and whatever they frame in turn. The
|
|
1375
|
+
browser keeps the tile's store by the site at the top, and not by who
|
|
1376
|
+
frames the tile (measured in Chrome and Firefox). None can run any other
|
|
1377
|
+
tile there, nor other bytes or headers. Treat what a tile kept as the
|
|
1378
|
+
tile's, not as yours to trust, and run tiles on the origins their CIDs name
|
|
1379
|
+
only on pages whose frames you would let do this.
|
|
737
1380
|
|
|
738
1381
|
## Loading a tile
|
|
739
1382
|
|
|
@@ -927,15 +1570,15 @@ A tile's origin is a dead end, by three layers that all read one policy
|
|
|
927
1570
|
whose runtime tries to leave (the `stopped` event). A `frame-src` of your
|
|
928
1571
|
own that only allows the tile server's host is a second lock on the same
|
|
929
1572
|
door.
|
|
930
|
-
- **Your frame
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1573
|
+
- **Your frame takes more away.** The frame `renderContent()` returns is
|
|
1574
|
+
sandboxed without dialogs and downloads, so a tile raises no dialog and
|
|
1575
|
+
starts no download in your page, and refuses a tile synchronous requests;
|
|
1576
|
+
it can be credentialless, out of the tab order, and refuse a tile more
|
|
1577
|
+
features of the browser, fewer of which other browsers than Chrome know.
|
|
1578
|
+
See "The frame a tile runs in". A frame's sandbox only takes away from
|
|
1579
|
+
what runs under it, so two things have to stay in it, `allow-scripts` and
|
|
1580
|
+
`allow-same-origin`: without them the runtime's service worker cannot
|
|
1581
|
+
run, and no tile loads.
|
|
939
1582
|
- **A tile opens nothing.** No popups in the sandbox, so no window to send
|
|
940
1583
|
anywhere. A link out is a request over the link protocol, and your page
|
|
941
1584
|
decides (`tileLinks`), opening it somewhere of its own.
|