Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 56 additions & 19 deletions docs/ACCESSIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,66 @@ WebFront does not make a page accessible by itself.
## Checking a page in `wf test`

[axe-core](https://github.com/dequelabs/axe-core) (MPL-2.0) checks the rules of WCAG 2.1 A and AA that a program can
decide. Install it as a dependency of the project and run it from a spec:
decide. Lock it beside Jasmine; nothing else is declared, and `wf test` loads it before the specs:

```sh
wf install axe-core@4.10.3
wf install jasmine-core@7.0.2 axe-core@4.10.3
wf test
```

```js
import axe from 'axe-core';

it('has no accessibility violation', async () => {
const report = await axe.run(document, {runOnly: {type: 'tag', values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']}});
expect(report.violations.map(rule => rule.id)).toEqual([]);
await expectAsync(document).toBeAccessible();
});

it('would catch a button without an accessible name', async () => {
const root = document.body.appendChild(document.createElement('div'));
root.innerHTML = '<button></button>';
await expectAsync(root).not.toBeAccessible();
root.remove();
});
```

For a page in a frame, run `frame.contentWindow.eval(axe.source)` and call the frame's `axe.run`, as
`test/web/suite/specs/accessibility-specs.mjs` does. A passing run is **not** a WCAG conformance statement: such checks
find only a part of the problems, and say nothing of the order of focus, the sense of a label or a keyboard trap.
`toBeAccessible` takes a document or an element and, optionally, the options of `axe.run`; by default it runs the rules
tagged `wcag2a`, `wcag2aa`, `wcag21a` and `wcag21aa`. A failure names each rule, its description and the elements.
Without axe-core in the lock the matcher fails and says what to install. It needs an environment built from these
sources (1.3.2); the published 1.3.1 does not have it.

The `app` and `life` starters carry this spec (`accessibility.spec.mjs`), and `wf init` declares it in `test.specs`.
`wf create` prints what to install. In a project that already has a manifest, where `wf init` will not run again, it
declares the spec when there is no `test` entry, and otherwise says what to add to `test.specs`; before `wf init`, for
another destination than `ui`, it says what to declare.

A passing run is **not** a WCAG conformance statement: such checks find only a part of the problems, and say nothing of
the order of focus, the sense of a label or a keyboard trap. Rules axe cannot decide (`incomplete`, such as contrast
over a gradient or a canvas) do not fail the matcher.

## What the browser suite checks
## What WebFront's suite checks

| Interface | Automated check |
| Interface | Check |
| --- | --- |
| Forms and tables generated from C++ descriptions ([forms](FORMS.md)) | no violation |
| Embedded fallback page | no violation |
| Developer terminal, inspectors | not checked |
| `app` and `life` starters | not checked |
| React and DOM island examples | not checked |
| Forms and tables generated from C++ descriptions ([forms](FORMS.md)) | axe: no violation |
| Embedded fallback page | axe: no violation |
| Developer terminal, collapsed and floating, its tab menu, the inspector panels and their window | axe: no violation (`developer_integration`, part `jasmine`) |
| `app` and `life` starters | their own spec: no violation (same part) |
| Host-loop, PTY and `life/react` examples | fixed by review; not checked by axe |
| DOM islands | not checked: their content is the application's |

## Keyboard in the developer environment

- The terminal tab is a button. Shift+F10 on it opens the menu, whose entries take the arrow keys, Enter and Escape.
- In the terminal, Tab completes and belongs to the terminal; **Shift+Tab leaves it**, so the keyboard is never trapped.
The terminal runs in xterm's screen reader mode and its input is labelled.
- An inspector window takes the focus when it opens; Escape, in its bar or in its panel, closes it and gives the focus back to what opened it.

The tests send these keys as DOM events: they check what the page does with them, not how each engine moves the focus.

## The page's tree for an agent

The MCP operation `accessibility` (grant `inspect`, [automation](AUTOMATION.md)) returns the roles, accessible names
and states of the running page, without what was typed in fields (an editable control is listed without its
content), bounded to 300 nodes and 30 000 bytes. It is **computed by WebFront from the DOM and ARIA attributes**,
with a simplified version of the naming rules: it is not the tree of the engine, and not what a screen reader says.

## What stays with the application

Expand All @@ -49,11 +81,16 @@ find only a part of the problems, and say nothing of the order of focus, the sen

| Frontend | Platform interface of the engine | Measured with WebFront |
| --- | --- | --- |
| WebKitGTK | AT-SPI | the tree of a probe page, once (below) |
| WebView2 | UI Automation | no |
| WKWebView | NSAccessibility | no |
| WebKitGTK | AT-SPI | no |
| CEF | the platform's; CEF turns accessibility on when a client asks | no |
| System browser | the browser's own | no |

These are what the engines document, not results obtained here: try your application with the screen reader of each
platform you ship.
The WebKitGTK measure was made by hand on 2026-12-05 with WebKitGTK 6.0 version 2.52.6 under Xvfb, by reading the AT-SPI
tree of a window of `WebKitGTKFrontend` from a private D-Bus session (not part of the test suite). It showed: the page as
`document web` named by its `title`, `main` as `landmark`, the heading, a labelled field as `entry` with its label, buttons
with their text or `aria-label`, an unnamed button with an empty name, a checked box as `check box` with its state,
`role="status"` as `status bar`, a canvas with `role="img"` as `image` with its label, and a button added by a script
after loading. No screen reader (Orca, NVDA, JAWS, VoiceOver) was run, so nothing is known here of what one reads out. The
other rows are what the engines document. Try your application with the screen reader of each platform you ship.
1 change: 1 addition & 0 deletions docs/AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Operations and their arguments:
| `build`, `preview` | `{entry?}` | Operation's own grant |
| `test` | `{pattern?}` | `test` |
| `inspect` | `{}` | `inspect` |
| `accessibility` | `{}` (the preview's roles, accessible names and states; environment 1.3.2) | `inspect` |
| `init` | `{name?}` | `init` |
| `create` | `{starter, directory?}` | `create` |
| `install` | `{package?}` (one `name[@range]`; none installs the locked graph) | `install` |
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ these entries stays in the GitHub releases and the Git history.
- Open an embedded window maximized, full screen, without a frame or with a minimum size (`WindowOptions`), on WebKitGTK and CEF (#764, `docs/FRONTENDS.md`).
- `wf dev` applies a change of the stylesheet alone without reloading the page, once an environment with it is published (#763, ADR-014).
- Check your pages for accessibility in `wf test` with axe-core: a guide says how, and the forms generated from C++ and the fallback page are checked in CI (#768, `docs/ACCESSIBILITY.md`).
- Fail a spec on an accessibility violation with `await expectAsync(document).toBeAccessible()` once `axe-core` is locked; the `app` and `life` starters carry such a spec (environment 1.3.2, not yet published, #768, `docs/ACCESSIBILITY.md`).
- Use the developer terminal and the inspectors with the keyboard alone: Shift+Tab leaves the terminal, Escape closes an inspector window and gives the focus back; the terminal supports screen readers (environment 1.3.2, #768).
- Toggle the cells of the Game of Life with the keyboard, in the starter and the React example, with more legible text (#768).
- Give an agent the roles, names and states of the page with the MCP operation `accessibility` (grant `inspect`), computed from the DOM (#768, `docs/AUTOMATION.md`).
- Declare who may call a C++ function at registration (`webfront::callers::localView`, `localClient`, `space`, `when`): WebFront refuses the others with `webfront.denied` before the function runs (#761, ADR-008, `docs/CONTENT_POLICY.md`).
- Use C++ state stores from any UI library: `webfront::store::Store` with `@webfront/store` (React, Solid and Preact are tested); `webfront::react::Store` stays as its former name (#767, ADR-010, `docs/STORE.md`).
- Opt-in reconnection of the bridge (`webFront.reconnect`), with its states and `onDisconnect`/`onReconnect`, and the identity of the page for C++ (`ui.pageId()`); the Life React example restores its simulation (#760, ADR-004, `docs/ASYNC_EXECUTION.md`).
Expand Down
10 changes: 7 additions & 3 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ environment. `life` is this example; `app` (environment 0.9.2) is a minimal Type
application: `ui/main.ts` calls one C++ callback, `app.greet`, and each of its elements has an `id`. Every starter carries an
`AGENTS.md` that states the model and how an agent runs `wf` (the text of `js/developer/starters/agent-guide.md`).

The starter contains editable TSX/CSS and a recipe of exact versions; `wf init` does not copy it, so list the dependencies with `wf install` and declare `test.specs`, `entries` and `providers` in the manifest yourself.
The starter contains editable TSX/CSS and a recipe of exact versions; `wf init` does not copy it, so list the dependencies with `wf install` and declare `entries` and `providers` in the manifest yourself. From environment 1.3.2, `wf init` declares the starter's accessibility spec in `test.specs` ([accessibility](ACCESSIBILITY.md)); with an earlier one, declare `test.specs` too.
`wf create life another-directory` selects a different new destination; existing directories
are never replaced. React DOM pulls scheduler transitively and checks its React peer.
Edit the local files in your normal editor and use `wf dev` for automatic rebuilds, or run `wf preview` again. Escape (while no
Expand All @@ -169,8 +169,9 @@ view make the simulation interactive. Generation and population counters expose
Every step awaits `webFront.cppFunction('life.step')(cells)`; no Life rules run in JavaScript.
Only one generation request can be outstanding. Replacing a pattern or clearing the field stops
animation and discards stale replies. Errors stop playback and appear in the interface.
Canvas rendering has an accessible description; patterns and simulation controls work with the
keyboard. Individual canvas cells are pointer-editable, without keyboard cell navigation.
The board, the patterns and the simulation controls work with the keyboard: with the board focused,
the arrow keys choose a cell and Space or Enter toggles it, and its position and state are announced,
and again when the board changes it; nothing is announced while the simulation plays.
No fonts, images, 3D library or additional UI framework are downloaded.

![The native Game of Life demo at generation 26](images/life-preview.jpg)
Expand Down Expand Up @@ -816,6 +817,9 @@ and integrity. Nothing else is needed, and no public network once the package is
directory of the run's own, `.webfront/developer/test/<run id>/`, and served by the developer HTTP provider; two
sessions on a project never run each other's specs. The files are removed when the run ends (an empty directory
remains) and the frame is removed at the end, on a time limit and on an interruption.
- With `axe-core` in the lock too, specs have the matcher `await expectAsync(document).toBeAccessible()`
([accessibility](ACCESSIBILITY.md)). The starters carry a spec using it, which `wf init` declares in `test.specs`
(environment 1.3.2 and later).
- `pattern` keeps the specs whose full name (suites and spec names) contains it; the others count as filtered out.
The order is fixed: no random shuffling.
- The terminal shows `.`, `F` and `*` (passed, failed, pending) as specs end, then a summary line (`PASSED: 3 specs,
Expand Down
1 change: 1 addition & 0 deletions docs/DEVELOPING_WITH_AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ The MCP column is the `operation` and `arguments` of the `webfront.start` tool,
| `wf build [entry]` | `build`, `{"entry": "ui/main.ts"}` | `build` |
| `wf embed ui/main.ts --output generated/AppUI.hpp` | `embed`, `{"entry": ..., "output": ...}` | `embed` |
| look at the page | `inspect` | `inspect` |
| read roles, names and states of the page | `accessibility` (environment 1.3.2) | `inspect` |
| click, type | `click` `{"pageId", "elementId"}`, `fill` adds `"value"` | `interact` |
| call a C++ callback the owner listed | `call`, `{"callback": ..., "value": ...}` | `call` |
| `wf list --tree` | `list` | `packages` |
Expand Down
9 changes: 7 additions & 2 deletions docs/FRONTENDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ engines show it only after a user gesture on the page); its wiring is implemente

## Assistive technologies

Each engine exposes the page through its platform's accessibility interface; none has been measured with WebFront. See
[accessibility](ACCESSIBILITY.md#engines-and-assistive-technologies).
Each engine exposes the page through its platform's accessibility interface. What was measured is limited:

- WebKitGTK (AT-SPI): the tree of a probe page was read once under Xvfb; roles, names, states and later changes of the
DOM were there. Not part of the tests.
- WebView2 (UI Automation), WKWebView (NSAccessibility), CEF and the system browser: not measured.

No screen reader was run on any of them. See [accessibility](ACCESSIBILITY.md#engines-and-assistive-technologies).

## Adding a frontend

Expand Down
3 changes: 2 additions & 1 deletion docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ are retained for investigation; diagnostics alone do not establish a correction.
WebView2 runs on any thread that is not already MTA (`webfront::UIThread`). Hidden WKWebView tests
require macOS 14+ and a WindowServer session. Automated CEF coverage is Linux/Xvfb;
Windows/macOS CEF deployment is not qualified. WebView2 needs its installed Evergreen runtime;
fixed-version runtime packaging, application installers and accessibility remain application work.
fixed-version runtime packaging, application installers and accessibility remain application work (checks and
measured limits: [accessibility](ACCESSIBILITY.md)).
- `WebView2Frontend::open()` releases the STA it initialized. When a window is closed while the runtime is still
starting, or by a page that closes it on a load failure, the WebView2 runtime (observed with 157.0.4341.46) can keep a
COM initialization of its own: the thread is then still in an STA (apartment type 3, qualifier 0) when `open()` returns
Expand Down
2 changes: 2 additions & 0 deletions examples/host-loop/HostLoopUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ inline constexpr std::string_view page = R"js(
#host-loop [name=cuda]:disabled { cursor: not-allowed; opacity: .6; }
`});
const canvas = add(root, "canvas", {width: 960, height: 720});
canvas.setAttribute("role", "img");
canvas.setAttribute("aria-label", "Image computed by the host: a ray-traced ball");
const stats = add(root, "pre", {className: "stats panel"});
// The engine is one switch, large enough to be read on a capture: lit, CUDA computes; dark, the CPU does.
const cuda = add(root, "button", {name: "cuda", className: "panel", disabled: true});
Expand Down
29 changes: 25 additions & 4 deletions examples/life/react/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {StrictMode, useEffect, useRef} from 'react';
import React, {StrictMode, useEffect, useRef, useState} from 'react';
import {createRoot} from 'react-dom/client';
import {Island, createStore, useStore} from '@webfront/react';
// The optional interpreter is served by WebFront, not bundled into the adapter.
Expand All @@ -15,28 +15,49 @@ async function main() {
const {installDomInterpreter} = await import(interpreterUrl);
const dom = installDomInterpreter(webFront);
const store = createStore<[Uint8Array, number, number]>('life', [new Uint8Array(128), 0, 0]);
const toggle = (index: number) => void webFront.cppFunction('life.react.toggle')(index).catch(showError);
function Life({started}: {started: boolean}) {
const [cells, generation, population] = useStore(store);
const [cursor, setCursor] = useState(0);
// The live region speaks once the keyboard is used: the chosen cell and its state, again when C++ changes it.
const [keyboard, setKeyboard] = useState(false);
const alive = (cells[cursor >> 3] & (1 << (cursor & 7))) !== 0;
const said = keyboard ? `Row ${(cursor >> 5) + 1}, column ${cursor % 32 + 1}: ${alive ? 'alive' : 'dead'}` : '';
const canvas = useRef<HTMLCanvasElement>(null);
useEffect(() => {
const context = canvas.current!.getContext('2d')!;
for (let i = 0; i < 1024; ++i) {
context.fillStyle = cells[i >> 3] & (1 << (i & 7)) ? '#81efbd' : '#16362c';
context.fillRect((i % 32) * 12, (i >> 5) * 12, 11, 11);
}
}, [cells]);
context.strokeStyle = '#ffd27d';
context.strokeRect((cursor % 32) * 12 + .5, (cursor >> 5) * 12 + .5, 10, 10);
}, [cells, cursor]);
return <main style={{fontFamily: 'sans-serif', padding: 24, background: '#091d17', color: '#dcffed'}}>
<h1>Game of Life · React + C++ island</h1>
<p data-testid="react-status">Generation {generation} · {population} living cells</p>
<canvas ref={canvas} width={384} height={384} aria-disabled={!started} aria-label="Game of Life; click a cell to toggle it"
<canvas ref={canvas} width={384} height={384} role="application" tabIndex={0} aria-disabled={!started}
aria-label="Game of Life board. Click a cell, or choose it with the arrow keys and toggle it with Space or Enter."
onKeyDown={event => {
Comment thread
ambroise-leclerc marked this conversation as resolved.
Resolved
if (event.ctrlKey || event.altKey || event.metaKey) return;
const steps: Record<string, number[]> = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]};
if (Object.hasOwn(steps, event.key)) {
const [dx, dy] = steps[event.key];
setCursor(((cursor >> 5) + dy + 32) % 32 * 32 + (cursor % 32 + dx + 32) % 32);
} else if (started && (event.key === ' ' || event.key === 'Enter')) toggle(cursor);
Comment thread
ambroise-leclerc marked this conversation as resolved.
Resolved
else return;
event.preventDefault();
setKeyboard(true);
}}
onClick={event => {
if (!started) return;
const rect = event.currentTarget.getBoundingClientRect();
const x = Math.floor((event.clientX - rect.left) * 32 / rect.width);
const y = Math.floor((event.clientY - rect.top) * 32 / rect.height);
void webFront.cppFunction('life.react.toggle')(y * 32 + x).catch(showError);
toggle(y * 32 + x);
}}/>
<Island dom={dom} name="life-panel" data-testid="cpp-panel"/>
<p role="status">{said}</p>
<p id="error" role="alert"/>
</main>;
}
Expand Down
24 changes: 24 additions & 0 deletions examples/life/ui/accessibility.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// The accessibility check of the interface, with axe-core (WCAG 2.1 levels A and AA): wf install jasmine-core axe-core,
// then wf test. A passing run is not a conformance statement: see docs/ACCESSIBILITY.md of WebFront.
describe('Accessibility', () => {
let root;
beforeAll(async () => {
root = document.createElement('div');
root.id = 'root';
document.body.append(root);
await import('./main');
// The interface may render after its module ran.
for (let attempt = 0; attempt < 200 && !root.querySelector('h1'); ++attempt) await new Promise(resolve => setTimeout(resolve, 10));
});

it('finds no violation in the interface', async () => {
expect(root.querySelector('h1')).not.toBeNull();
await expectAsync(document).toBeAccessible();
});

it('reports a button without an accessible name', async () => {
const button = root.appendChild(document.createElement('button'));
try { await expectAsync(button).not.toBeAccessible(); }
finally { button.remove(); }
});
});
Loading
Loading