Skip to content

Commit d3dfa02

Browse files
committed
Force align test sources with upstream WPT
While implementing DOM features I noticed the coding agent engaging in the following pathological behaviors: 1. changing the WPT tests in order to accomodate a feature I was adding to the DOM, and allowing it to drift from upstream. 2. Writing its own test cases outside the WPT suite for behavior that was explicitly covered by the WPT 3. Not being sure what exactly each WPT test was supposed to cover. This adds stricter guardrails around what is allowed in the WPT and instructs future agents to respect them. It stipulates that every test file must mirror the upstream path of the source from which it derives. The specific revision of the WPT is in the /WPT_REVISION file. This allows agents to quickly navigate to the source of the test. Furthermore, it strengthens the language to say that the upstream WPT should be followed very closely when adding new tests, or implementing functionality. Then, I had it re-sync with the upstream WPT and ended up with a test suite that is much more faithful to the original implementation. In fact, it got me thinking that once we have HTML parsing as part of our functionality, we can switch to use the upstream tests directly. Select upstream sources and cases with optional include/exclude rules, with explicit includes taking precedence. Remove feature prerequisite gates so each selected case exercises its own supporting operations. Configure global bindings alongside test selection in wpt.config.ts, including factories that resolve bindings for each fresh document.
1 parent b990b53 commit d3dfa02

647 files changed

Lines changed: 59390 additions & 19795 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/wpt-suite-fidelity.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bomb.sh/web-platform-tests': patch
3+
---
4+
5+
Align the DOM compatibility suite with upstream WPT cases at a shared revision, mirror upstream source paths in test filenames, and remove locally authored scenarios. Expose typed document and global bindings through the test fixture. Configure global bindings alongside upstream file and case selection in `wpt.config.ts`, with includes taking precedence over exclusions instead of requiring other test groups to be enabled. Register a todo when every case is excluded.

‎.eslintignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Preserve upstream WPT conventions. The shared harness files remain linted.
2+
packages/web-platform-tests/src/compatibility/*/**/*.ts
3+
packages/web-platform-tests/src/wpt/**/*.ts

‎.github/workflows/check.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ jobs:
5353
- run: pnpm --filter @bomb.sh/web-platform-tests typecheck
5454
- run: pnpm --filter @bomb.sh/web-platform-tests exec playwright install --with-deps chromium
5555
- run: pnpm --filter @bomb.sh/web-platform-tests test:wpt-selectors
56-
- run: pnpm --filter @bomb.sh/web-platform-tests test:browser:input
56+
- name: Report Chromium input compatibility
57+
# Browser conformance differences are informational, not UI build failures.
58+
continue-on-error: true
59+
run: pnpm --filter @bomb.sh/web-platform-tests test:browser:input
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { describe, it, expect } from 'vitest';
22
import { testDOMCompatibility } from '@bomb.sh/web-platform-tests';
3-
import { Document, Element, Node, Text } from './dom.ts';
4-
import { domFeatures } from '../test/dom-features.ts';
3+
import { Document } from './dom.ts';
4+
import config from '../test/wpt.config.ts';
55

66
testDOMCompatibility({
77
runner: { describe, it, expect },
8-
features: domFeatures,
8+
config,
99
create: () => new Document(() => {}),
10-
globals: { Document, Element, Node, Text },
1110
});

‎packages/ui/test/README.md‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UI tests
22

3-
Tests live alongside the implementation in `src/`; this directory contains their shared fixtures and the DOM feature manifest. Run the UI tests from the workspace root:
3+
Tests live alongside the implementation in `src/`; this directory contains their shared fixtures and WPT configuration. Run the UI tests from the workspace root:
44

55
```sh
66
pnpm --filter @clack/ui test
@@ -18,25 +18,24 @@ Rendering, scheduling, notifications, and lifecycle behavior belong in the UI te
1818

1919
## DOM compatibility
2020

21-
[`dom.compatibility.test.ts`](../src/dom.compatibility.test.ts) registers the shared compatibility suite with Vitest. Its synchronous factory creates a fresh instance of the real [`Document`](../src/dom.ts) for each case, with a no-op render notification callback. The supplied global bindings are the UI's `Document`, `Element`, `Node`, and `Text` classes. This fixture owns no external resources, so it needs no disposal callback.
21+
[`dom.compatibility.test.ts`](../src/dom.compatibility.test.ts) registers the shared compatibility suite with Vitest. Its synchronous factory creates a fresh instance of the real [`Document`](../src/dom.ts) for each case, with a no-op render notification callback. This fixture owns no external resources, so it needs no disposal callback.
2222

23-
[`dom-features.ts`](dom-features.ts) is the source of truth for the features this integration verifies. It satisfies the suite's `DOMFeatures` type and declares every leaf explicitly. The suite also validates the manifest at runtime: omitted, unknown, and non-boolean feature values are configuration errors.
23+
[`wpt.config.ts`](wpt.config.ts) supplies the implementation's `globals` and selects the upstream files and cases enforced by this integration. Add new global bindings there. Omitting `config` runs all adapted cases; `exclude` removes matches and explicit `include` rules take precedence. Source keys support `*` and `**`; values are `true` for a whole source or arrays of exact case names and regular expressions. Unmatched rules are configuration errors. No other test groups must be enabled to run a case.
2424

25-
A `true` leaf enables its registered cases; a `false` leaf leaves those cases unregistered. The suite does not infer support from available methods or turn disabled features into skipped tests. Required feature dependencies must also be enabled; missing dependencies fail configuration before any tests are registered. Individual cases with additional feature requirements run only when those requirements are enabled.
25+
The configuration explicitly excludes unsupported directories. Add includes or narrow exclusions as cases pass. Selecting a source runs all of our adapted cases from that file; it does not imply complete coverage of the upstream file or interface.
2626

27-
Feature names describe the behavior being asserted. For example, `node.basicAppend` covers detached tree construction, while `node.append` also requires moving nodes and rejecting cycles. Passing a narrow feature does not establish support for the broader interface or complete standards conformance. The shared [feature catalogue](../../web-platform-tests/src/compatibility/features.ts) and [registry](../../web-platform-tests/src/compatibility/registry.ts) lead to each feature's cases, prerequisites, and specification references.
27+
Include the source or case in the configuration while implementing it. Vitest's `-t` can narrow the configured selection by source path and case name:
2828

29-
When implementing a feature:
29+
```sh
30+
pnpm --filter @clack/ui test src/dom.compatibility.test.ts -t 'Document-createElement.html.*createElement\(foo\)'
31+
```
3032

31-
1. Read its registered cases and prerequisites to understand the behavior the flag promises.
32-
2. Implement that behavior in the UI, then enable the relevant leaves in `dom-features.ts`.
33-
3. Extend the compatibility fixture when the cases need additional constructors, document parsing options, host input, or resource cleanup.
34-
4. Run the UI tests and add implementation-specific regressions for rendering, notifications, or lifecycle effects.
33+
If the shared package is already built, avoid rebuilding by using `pnpm --filter @clack/ui exec bsh test src/dom.compatibility.test.ts` with the same name filter.
3534

36-
Keep support decisions in the manifest rather than duplicating flag values or test counts in documentation.
35+
When implementing behavior, read the source-named file under [`src/wpt`](../../web-platform-tests/src/wpt), implement its operations, and update the configuration once its cases pass. Extend the fixture when cases need document parsing, host input, or cleanup. Implementation-specific rendering, notification, and lifecycle checks remain in the UI tests.
3736

3837
## Host input
3938

40-
Host input features require a [`DOMInputDriver`](../../web-platform-tests/src/compatibility/input-driver.ts) that delivers input through the normal terminal input pipeline. A terminal adapter must resolve mouse targets through the UI's layout, await operation completion, and release held input during cleanup, including after failures. Calling `dispatchEvent`, invoking `.click()`, or directly assigning control values does not exercise that host behavior.
39+
Host input cases require a [`DOMInputDriver`](../../web-platform-tests/src/compatibility/input-driver.ts) that delivers input through the normal terminal input pipeline. A terminal adapter must resolve mouse targets through the UI's layout, await operation completion, and release held input during cleanup, including after failures. Calling `dispatchEvent`, invoking `.click()`, or directly assigning control values does not exercise that host behavior.
4140

42-
Keyboard/mouse delivery, platform interaction policies, and trusted-event support are separate feature decisions. Enable each only when the implementation and its adapter can satisfy its cases. The shared suite's [browser tooling](../../web-platform-tests/README.md#development) validates the input contract with Playwright; the UI adapter must use terminal layout and input semantics.
41+
Select keyboard/mouse delivery, platform interaction policies, and trusted-event cases independently as the implementation and its adapter support them. The shared suite's [browser tooling](../../web-platform-tests/README.md#development) validates the input contract with Playwright; the UI adapter must use terminal layout and input semantics.

‎packages/ui/test/dom-features.ts‎

Lines changed: 0 additions & 306 deletions
This file was deleted.

0 commit comments

Comments
 (0)