Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
95 changes: 95 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,101 @@
]
}
},
{
"files": ["e2e/**"],
"rules": {
"eslint/no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@playwright/test",
"allowTypeImports": true,
"message": "Only e2e/support.ts imports values from Playwright, so that every journey gets the shared fixture and its contexts (ADR 0015). Import types only, and take test, expect, and the helpers from ./support.js."
},
{
"name": "playwright",
"allowTypeImports": true,
"message": "Only e2e/support.ts imports values from Playwright, so that every journey gets the shared fixture and its contexts (ADR 0015). Import types only, and take test, expect, and the helpers from ./support.js."
},
{
"name": "playwright/test",
"allowTypeImports": true,
"message": "Only e2e/support.ts imports values from Playwright, so that every journey gets the shared fixture and its contexts (ADR 0015). Import types only, and take test, expect, and the helpers from ./support.js."
},
{
"name": "playwright-core",
"allowTypeImports": true,
"message": "Only e2e/support.ts imports values from Playwright, so that every journey gets the shared fixture and its contexts (ADR 0015). Import types only, and take test, expect, and the helpers from ./support.js."
}
],
"patterns": [
{
"regex": "(^|/)generated(/|$)",
"message": "Only the facade packages/api-client/src/index.ts imports the generated client."
},
{
"regex": "^telemetry-web-api-client/",
"message": "Import the package root telemetry-web-api-client only."
}
]
}
],
"eslint/no-restricted-properties": [
"error",
{
"property": "newContext",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"property": "launch",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"property": "launchPersistentContext",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"property": "launchServer",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"property": "connect",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"property": "connectOverCDP",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
},
{
"object": "browser",
"property": "newPage",
"message": "Open browser contexts and pages through the helpers of e2e/support.ts, so that the Firefox workaround applies (ADR 0015)."
}
]
}
},
{
"files": ["e2e/support.ts", "e2e/playwright.config.ts"],
"rules": {
"eslint/no-restricted-imports": [
"error",
{
"patterns": [
{
"regex": "(^|/)generated(/|$)",
"message": "Only the facade packages/api-client/src/index.ts imports the generated client."
},
{
"regex": "^telemetry-web-api-client/",
"message": "Import the package root telemetry-web-api-client only."
}
]
}
],
"eslint/no-restricted-properties": "off"
}
},
{
"files": ["packages/api-client/src/index.ts"],
"rules": {
Expand Down
3 changes: 2 additions & 1 deletion STACK.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ at the pin.
| @tanstack/react-query | 5.108.4 | `telemetry-web-spa` | Server state and cache | MIT |
| zod | 4.6.7 | `telemetry-web-api-client` | Executed validation of responses and problem bodies | MIT |
| @hey-api/openapi-ts | 0.99.0 | `telemetry-web-api-client` (dev) | Generation of the SDK, types, and Zod schemas | MIT |
| @playwright/test | 1.65.1 | root, `telemetry-web-e2e` | Browser journeys | Apache-2.0 |
| @playwright/test | 1.65.1 | root, `telemetry-web-e2e` | Browser journeys; ships Chromium build 1255, Firefox 159.0 build 1572, and WebKit build 2388 (`browsers.json` of `playwright-core`) | Apache-2.0 |
| @axe-core/playwright | 4.14.1 | `telemetry-web-e2e` | Accessibility checks in the journeys | MPL-2.0 (test only; the image holds no file of it) |
| @types/react, @types/react-dom, @types/node | 19.3.3, 19.3.0, 24.19.4 | dev | Types; `@types/node` follows the Node 24 runtime | MIT |

Expand Down Expand Up @@ -589,6 +589,7 @@ approval.
| §1: `exactOptionalPropertyTypes` off for `packages/api-client/src/generated/` | The copied client runtime of Hey API is not checked with that one flag. | Nothing edits the directory; `contract-check`; every other strict flag stays on; the facade and the SPA keep the flag and read the generated code only as declarations. | ADR 0010 | A Hey API release whose runtime passes the flag. |
| §3: no scan of the web builder images `node:<version>-trixie-slim` and `rust:<version>-slim-trixie` | A vulnerability in Node, npm, pnpm, or a builder Debian package that changes the SPA files or the server binary is not found by a scanner. | The tags equal the pins of `mise.toml` and `rust-toolchain.toml` (`crates/server/tests/deployment.rs`); `deps` prints the newest tags; `pnpm audit` and the source scan cover the npm packages of the build; `vuln` allows only the binary and `web/dist` out of the builder stages; `image-check` runs the built image; manual KEV comparison. | ADR 0010 | A scanner of the built image in CI; a builder-stage advisory in CISA KEV; a change of a builder image. |
| §14: build and test of the web image before merge | The Railway build, settings, and healthcheck of `telemetry-web` are unverified before the merge. | A green `image-check` job of the PR head (`image-check-web.sh`); the post-release checks and the recovery of `docs/web-release.md`. | ADR 0008, ADR 0010 | Railway documents its Dockerfile build, or the Railway builder can run before the merge. |
| §3, §14: Firefox journeys of `e2e/` hide `ariaLabelledByElements` | In the project `firefox`, `e2e/support.ts` deletes the property from `Element.prototype` in the main world, because Firefox build 1572 crashes when two worlds read it (Mozilla bug 2090055). axe in Firefox does not check a reference that a script sets only through the property. Chromium and WebKit are unchanged. | `e2e/firefox-aria-reflection.spec.ts`: the regression test, the axe challenge test, the context test of `newBrowserContext`, the axe equivalence test in Chromium and WebKit, the source check of `web/src` and `packages/api-client/src`, and the removal guard. Each slice that adds a page or a state with an axe check adds the page or state to the equivalence test. The lint rules for `e2e/**` keep the fixture in front of every page: only `e2e/support.ts` and `e2e/playwright.config.ts` import values from Playwright, and only `e2e/support.ts` opens a context; ADR 0015 lists their known limits. | ADR 0015 | A stable Playwright release with Firefox build 1575 or later is older than 1440 minutes, or by 2027-02-28. The removal guard fails when the pinned Playwright ships such a build. |
| Web profile §15: one image for server and SPA | The ingest service is a second image (Tesla's upstream server). | The application still ships as one image. | ADR 0009 | Permanent while the upstream server is used. |

---
Expand Down
178 changes: 178 additions & 0 deletions docs/adr/0015-firefox-aria-reflection-workaround.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# ADR 0015: Firefox ARIA reflection workaround in the browser journeys

- Status: Accepted, 28 November 2026. A scoped exception under
`DOCTRINE.md` "Exceptions". Decided by the lead within delegated
authority, with approval by an independent reviewer (qa-enforcer) in PR
#51: <https://github.com/jonikanerva/telemetry/pull/51#pullrequestreview-6093024203>,
with the conditions of the addendum
<https://github.com/jonikanerva/telemetry/pull/51#issuecomment-7227466133>.
- Responsible lead: the lead agent of the delivery task.
- Scope: the Playwright journeys of `e2e/` in the project `firefox` only,
with Playwright 1.65.1 and its Firefox 159.0, build 1572. The workaround
does not change the application, the release image, or the journeys in
Chromium and WebKit.

## Context

- The Firefox of Playwright 1.65.1 (Firefox 159.0, build 1572) crashes its
content process (SIGSEGV in
`Element::GetAttrAssociatedElementsForBindings`) when two JavaScript
worlds read `ariaLabelledByElements` of one element:
- Playwright's utility world reads the property in the accessible name
computation of a role query with a name, of `ariaSnapshot()`, and of a
polling `expect`.
- The page's main world reads the property in axe-core 4.14.1 (rule data
`prop: 'ariaLabelledByElements'`, function `getIdrefsValue`) and in
`page.evaluate`.
- Playwright then reports "Page crashed". A minimal page reproduces the
crash without the application:
`<section aria-labelledby="t"><h1 id="t">x</h1></section>`, a
`getByRole('region', { name: 'x' })` query, then a main-world read of
the property.
- The crash is not specific to macOS. CI on linux/amd64 crashed six
Firefox journeys of the battery-view slice:
<https://github.com/jonikanerva/telemetry/actions/runs/46054099506/job/140692284877>.
- Upstream records:
- Mozilla bug 2090055 (RESOLVED FIXED, Firefox 163):
<https://bugzilla.mozilla.org/show_bug.cgi?id=2090055>.
- Playwright issues 43967 and 44135 (closed):
<https://github.com/microsoft/playwright/issues/43967>,
<https://github.com/microsoft/playwright/issues/44135>.
- Playwright PR 43982 rolls Firefox to build 1575 (merged):
<https://github.com/microsoft/playwright/pull/43982>.
- axe-core issue 5549 (open):
<https://github.com/dequelabs/axe-core/issues/5549>.
- On 28 November 2026, the npm tag `latest` of `@playwright/test` is
1.65.1. The tag `next` is 1.66.0-alpha. No stable release ships Firefox
build 1575 or later.
- The Playwright 1.65.1 utility world reads only `ariaLabelledByElements`
of the eight ARIA element-reflection properties of WAI-ARIA 1.3
(`ariaActiveDescendantElement`, `ariaControlsElements`,
`ariaDescribedByElements`, `ariaDetailsElements`,
`ariaErrorMessageElements`, `ariaFlowToElements`,
`ariaLabelledByElements`, `ariaOwnsElements`). A reproduction with each
property, a role query, a description query, an error message query,
an `ariaSnapshot()`, and a main-world read crashed only for
`ariaLabelledByElements`. The crash of the other seven properties is
not reachable from the utility world of Playwright 1.65.1.
- The same reproduction with the Firefox build 1584 (Firefox 160.0),
driven by Playwright 1.65.1 on macOS arm64, did not crash. Build 1575
was not tested.
- The application on `main` passes the Firefox journeys without the
workaround. The crash comes when a journey queries a name and then runs
axe on an element with `aria-labelledby`.

## Decision

1. In the Playwright project `firefox` only, the shared fixture of
`e2e/support.ts` adds an init script to each browser context. The init
script deletes `ariaLabelledByElements` from `Element.prototype` in the
main world, before any page script runs. axe-core then reads
`aria-labelledby` from the content attribute. The list of deleted
properties is `HIDDEN_ARIA_REFLECTION_PROPERTIES` in `e2e/support.ts`.
2. `e2e/support.ts` is the only e2e file that imports values from
`@playwright/test`, `playwright`, `playwright/test`, or
`playwright-core`. Every other file under `e2e/` imports types only
from these modules, and takes `test`, `expect`, and the helpers from
`e2e/support.ts`. The lint rule `no-restricted-imports` for `e2e/**` in
`.oxlintrc.json` enforces this, also for a default import, a re-export,
a spec in a subdirectory, and a helper file. `e2e/playwright.config.ts`
is the second exempt file, because it needs `defineConfig` and
`devices`.
3. A test that needs a further browser context opens it with
`newBrowserContext` of `e2e/support.ts`. In Firefox, that context gets
the same init script. The lint rule `no-restricted-properties` for
`e2e/**` fails on `newContext`, `launch`, `launchPersistentContext`,
`launchServer`, `connect`, and `connectOverCDP` of any object, and on
`browser.newPage`, outside `e2e/support.ts`. A page of a context from
the fixture or from `newBrowserContext` gets the init script.
4. Each slice that adds a page or a state with an axe check adds the page
or state to the equivalence test.
5. Chromium and WebKit run unchanged. The journeys use no retry, skip no
engine, and disable no axe rule.

## Compensating evidence

`e2e/firefox-aria-reflection.spec.ts` holds these tests. Each test can
fail:

- Regression (Firefox): a role query with a name, a main-world read of
the property, axe, and a second role query on a page with
`aria-labelledby` do not crash the page. Without the fixture, the test
fails with "Page crashed".
- Challenge (Firefox, with the fixture): axe reports a `button-name`
violation for a button whose `aria-labelledby` names a missing id, and a
pass for a button with a resolved reference.
- Context (Firefox): a second page of the fixture context and a page of a
context from `newBrowserContext` do not have the property in the main
world.
- Equivalence (Chromium and WebKit): on each page and state that a
journey checks with axe, and on the not-found page, in both colour
schemes, the axe violations, passes, and incomplete results are equal
with and without the deletion. The test checks that the property is
present in the control and absent with the deletion. Each case states
whether its page has an element with `aria-labelledby`, and the test
checks that statement; for a page with such an element, it checks that
axe checked a node with `aria-labelledby`.
- Source check (Firefox project, no browser): the application source in
`web/src` and `packages/api-client/src`, without `generated/`, does not
name a property of `HIDDEN_ARIA_REFLECTION_PROPERTIES`.
- Removal guard (Firefox project, no browser): the test fails when the
Firefox revision in `browsers.json` of the pinned `playwright-core` is
1575 or later. The message tells the reader to remove the workaround
and this exception.

The lint rules of decisions 2 and 3 support these tests: they keep the
fixture in front of every page. Their known limits:

- They do not find a dynamic `import()` or a `require()` of a Playwright
module.
- The rule for `newPage` names the object `browser` only. A `Browser`
under another variable name can call `newPage` without a finding.
`context.newPage()` stays allowed, because the context comes from the
fixture or from `newBrowserContext`.

## Key alternatives

- Wait for a stable Playwright release with Firefox build 1575 or later.
Rejected: no such release exists, and the open slices need green
Firefox journeys now.
- Adopt Playwright 1.66 alpha. Rejected: a prerelease needs a reviewed
exception of its own (`DOCTRINE.md` P7), and it changes every browser.
- Downgrade Playwright. Rejected: P7 requires the latest stable release.
- Change the markup (no `aria-labelledby`). Rejected: the accessible name
from the visible heading is the better markup, and a test tool must not
decide the markup.
- Run axe only in Chromium and WebKit. Rejected: it removes the axe check
of one engine completely.
- Exclude the axe rules that read `aria-labelledby`. Rejected: it removes
those checks in every engine.
- Retry the failed journeys. Rejected: a retry hides a failure
(`DOCTRINE.md` P6), and the crash is deterministic.

## Consequences

- In Firefox, axe does not check a reference that a script sets only
through the property `ariaLabelledByElements`, with no content
attribute. The application sets no such reference; the source check
enforces this. Chromium and WebKit still check such a reference.
- A context that a test opens with `newBrowserContext` gets the
workaround. A context that bypasses the helper through a gap of the lint
rules does not.
- The journeys do not show whether a stock Firefox 159 crashes for a user,
for example with a browser extension that reads the property in a
second world. This is not verified.

## Cost of reversal

Low. Remove the fixture override and the constants from `e2e/support.ts`,
the spec `e2e/firefox-aria-reflection.spec.ts`, the two lint overrides
for `e2e/` in `.oxlintrc.json` if no other reason keeps them, and the row in `STACK.md`
§13. Then set the status of this ADR to "Superseded" or "Expired".

## Reassessment

Remove the workaround when a stable Playwright release with Firefox build
1575 or later is older than 1440 minutes, or on 2027-02-28, whichever
comes first. The removal guard fails when the pinned Playwright ships
such a build.
3 changes: 2 additions & 1 deletion e2e/auth-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
// tests (playwright.config.ts runs one worker). Call `resetAuth` before a
// test that logs in, so the test starts with no session, a full throttle
// bucket, and the real clock.
import { expect } from '@playwright/test';
import type { APIRequestContext, Page } from '@playwright/test';

import { expect } from './support.js';

/**
* The password of the test server. It is a test-only value: the test
* server hashes it at each start (playwright.config.ts). It is never a
Expand Down
2 changes: 1 addition & 1 deletion e2e/e4-cookie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// The requests run inside the page with fetch, so the cookie store of the
// engine decides. The `request` fixture of Playwright has its own cookie
// store and would give the same answer in every engine.
import { expect, test } from '@playwright/test';
import { expect, test } from './support.js';

type Outcome = { readonly setStatus: number; readonly checkStatus: number; readonly body: unknown };

Expand Down
Loading