Skip to content

Commit 8de8b8d

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 reference, via a comment, the upstream 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.
1 parent b990b53 commit 8de8b8d

273 files changed

Lines changed: 52146 additions & 12766 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.

‎.eslintignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Preserve upstream WPT conventions. The shared harness files remain linted.
2+
packages/web-platform-tests/src/compatibility/*/**/*.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

‎packages/ui/src/dom.compatibility.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { testDOMCompatibility } from '@bomb.sh/web-platform-tests';
33
import { Document, Element, Node, Text } from './dom.ts';
44
import { domFeatures } from '../test/dom-features.ts';
55

6+
// Keep this file runnable while all compatibility feature groups are disabled.
7+
it.todo('enable DOM compatibility coverage as the implementation catches up');
8+
69
testDOMCompatibility({
710
runner: { describe, it, expect },
811
features: domFeatures,

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { DOMFeatures } from '@bomb.sh/web-platform-tests';
22

33
export const domFeatures = {
44
document: {
5-
basicCreation: true,
5+
basicCreation: false,
66
creation: false,
77
lookup: false,
88
importNode: false,
@@ -11,7 +11,7 @@ export const domFeatures = {
1111
xmlSerialization: false,
1212
},
1313
node: {
14-
basicAppend: true,
14+
basicAppend: false,
1515
relationships: false,
1616
connectivity: false,
1717
liveCollections: false,
@@ -28,13 +28,13 @@ export const domFeatures = {
2828
adoption: false,
2929
},
3030
characterData: {
31-
stringStorage: true,
31+
stringStorage: false,
3232
data: false,
3333
editing: false,
3434
splitText: false,
3535
},
3636
element: {
37-
childElements: true,
37+
childElements: false,
3838
attributes: false,
3939
attributeNodes: false,
4040
namespaces: false,
@@ -285,11 +285,9 @@ export const domFeatures = {
285285
editing: false,
286286
multilineEditing: false,
287287
numberStepping: false,
288-
focusStyles: false,
289288
focusVisible: false,
290289
shadow: false,
291290
implicitSubmission: false,
292-
trustedEvents: false,
293291
},
294292
mouse: {
295293
delivery: false,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# WPT provenance and correspondence
2+
3+
This package is the long-term source of upstream WPT coverage for the UI.
4+
5+
Every shared DOM conformance case must faithfully reflect an existing, inspected
6+
upstream Web Platform Test. Do not invent cases, add local assertions to upstream
7+
cases, extend their inputs or matrices, or infer new tests from the specification.
8+
Independent subtleties, regressions, and implementation-specific checks belong in
9+
tests outside this package's WPT suite, even when they test standards behavior.
10+
A citation to a related upstream test does not make a local addition a WPT case.
11+
12+
This requirement applies to all feature groups, including disabled features.
13+
Existing cases without verified provenance and existing local extensions are
14+
migration work, not exceptions. Remove local additions from the WPT suite;
15+
retain only verified upstream adaptations here. Tests of the runner and fixtures
16+
are infrastructure tests, separate from WPT cases.
17+
18+
The suite shares one upstream revision in `WPT_REVISION`. Use that revision
19+
for source review; do not choose a separate revision for each case or file.
20+
A comment at the top of each adapted file is sufficient provenance, for example:
21+
22+
```ts
23+
// WPT: html/semantics/forms/the-option-element/option-selected.html
24+
```
25+
26+
Keep ordinary `context.test` and `expect` calls with readable test names. Do not
27+
introduce registration wrappers or runtime metadata for provenance.
28+
Destructure `document` and global bindings from the typed fixture. Their expected
29+
DOM types are asserted once at the fixture boundary.
30+
Default to source paths only in file headers. Shared attribution and license
31+
information belong in `test/wpt`.
32+
33+
When adding or migrating a case:
34+
35+
1. Read the upstream source at the suite revision. In the file's provenance
36+
comment, name the upstream path and any helper or data files that define the
37+
assertions. One comment per file is enough when the correspondence is clear.
38+
Identify original case names or groups in that comment when needed to locate
39+
selected cases; do not require a link or provenance annotation on every test.
40+
2. Preserve the upstream inputs, setup, operation order, assertions, exceptions,
41+
node identities, document ownership, and matrix rows. Separate documents,
42+
detached trees, and retained collections are meaningful test conditions.
43+
3. Limit adaptations to integration with the consumer's runner, fixtures, and
44+
input driver. Comment only on non-obvious adaptations, preserving the
45+
tested behavior without adding or removing behavioral checks. Keep the code
46+
close enough to upstream for a side-by-side review.
47+
4. Record the exact selected upstream cases and any exclusions with reasons.
48+
Selecting a subset of a file does not establish coverage of the entire file.
49+
Do not merge several upstream cases into a smaller example or drop assertions
50+
to accommodate an incomplete implementation.
51+
5. Keep upstream authorship and license notices. A specification URL, a directory
52+
link, or a reference to a merely similar test is insufficient provenance.
53+
Do not claim that an existing local case was derived from WPT
54+
without establishing that correspondence; replace it with a verified
55+
adaptation when necessary.
56+
6. Verify the source mapping and registered cases, review assertion correspondence,
57+
and run browser validation and the affected consumer tests. Matching names or
58+
passing against a browser alone does not establish correspondence.
59+
60+
Fix missing implementation behavior or declare its prerequisites explicitly.
61+
Never weaken a shared case, change its fixture semantics, or silently omit it
62+
just to make the UI implementation pass.
63+
64+
The selector source inventory and omission check are an existing example of
65+
traceability, not a waiver for other features. The entire suite must meet this
66+
requirement before it can be described as a fully traceable WPT adaptation.

‎packages/web-platform-tests/README.md‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ Private workspace package containing reusable DOM compatibility assertions. It c
44

55
The suite includes adaptations of [Web Platform Tests (WPT)](https://github.com/web-platform-tests/wpt) covering DOM operations, state/style interactions, input, shadow DOM, forms, CSSOM, selection, traversal, and parsing.
66

7-
Each adapted file records its upstream sources and original author attribution in comments or source metadata. The original WPT BSD-3-Clause notice and the html5lib parsing corpus MIT notice are retained. See [standards references and licenses](docs/references.md) for the pinned sources, attribution, and applicable licenses.
7+
The suite uses one upstream WPT revision, recorded in [WPT_REVISION](WPT_REVISION). Browse that revision [here](https://github.com/web-platform-tests/wpt/tree/b719612f963a05ece9c89a7dd7598c1c59618874). Each adapted file identifies its upstream path in a comment; the revision applies to all files and cases. The original WPT BSD-3-Clause notice and author credits are retained. See [standards references and licenses](docs/references.md) for attribution and applicable licenses.
8+
9+
### Required WPT correspondence
10+
11+
Each shared DOM conformance file must identify its inspected upstream source at the suite revision. A file comment is sufficient:
12+
13+
```ts
14+
// WPT: html/semantics/forms/the-option-element/option-selected.html
15+
```
16+
17+
Include helper/data paths and a short selection note when needed. Detailed selection boundaries belong in the [source inventories](docs/references.md). Keep ordinary `context.test` and `expect` calls and readable test names; per-case SHAs, links, and provenance wrappers are unnecessary. Preserve the upstream inputs, setup, operation order, assertions, exceptions, node identities, and relationships between documents. Humans and agents should be able to review the tests side by side. A specification link or a reference to a similar test does not establish provenance.
18+
19+
The WPT suite must contain only faithful adaptations of existing upstream cases. Do not invent scenarios, add local assertions, extend upstream input matrices, or create specification-derived cases here. Independently authored subtleties, regressions, and implementation-specific checks belong in separate tests outside this suite. Necessary harness adaptations must preserve the upstream behavior being tested. Tests of the harness itself are separate infrastructure tests.
20+
21+
The shared suite is the long-term home of upstream WPT coverage for the UI. Implementation-specific rendering, notification, and lifecycle checks belong in the corresponding UI integration tests.
822

923
```ts
1024
import { testDOMCompatibility, type DOMFeatures } from '@bomb.sh/web-platform-tests';
@@ -28,7 +42,7 @@ Supply a runner with `describe`, `it`, and Vitest-compatible `expect` matchers,
2842
### Harness
2943

3044
* `create(options?)`: A synchronous or asynchronous factory for a fresh `Document`. When a case supplies `DOMDocumentOptions`, honor its markup, MIME type, and URL fragment; the selector matrix uses these to test HTML, XHTML, and `:target`.
31-
* `globals`: An object containing the implementation's global bindings, or a function that returns them for a document. For example, a test looks up `HTMLInputElement` on this object.
45+
* `globals`: An object containing the implementation's global bindings, or a function that returns them for a document. Tests destructure typed bindings from the fixture, such as `({ document, Node, Text })`. Accessing a missing binding throws.
3246
* `input`: An optional factory for a `DOMInputDriver` session that delivers keyboard, text, and mouse input through the implementation's normal host input pipeline. This allows testing of default actions like focus on click, form submission on `Enter`, and trusted events.
3347
* `dispose(document)`: Optional cleanup for implementation-owned resources after each case, including failures.
3448

@@ -48,26 +62,17 @@ pnpm --filter @bomb.sh/web-platform-tests test:browser
4862
```
4963
To validate the test suite itself, run it against an actual browser runtime. Browser dependencies are development-only.
5064

51-
The automation CLI uses Playwright's Chromium with an isolated browser context and fresh standards-mode iframe per case.
65+
The automation CLI uses Playwright's Chromium with a fresh iframe per case and a new browser context every 500 cases to bound memory use.
5266

5367
The [selector WPT omission check](docs/wpt-selectors.md) compares the adapted registrations with actual pinned upstream case names. Its cache is ignored, and results are printed rather than committed.
5468

5569
The suite asserts resulting DOM behavior, never browser pixel values. Browser target resolution uses the browser's own rectangles and iframe coordinate offsets; a terminal adapter must use its own renderer.
5670

57-
#### Known Chromium disagreements
58-
59-
The following eight cases are allowed to fail when validating the suite in Chromium. They remain enabled, and the runner reports their failures and returns a nonzero exit code. Other failures require investigation.
71+
#### Browser results
6072

61-
| Feature and case | Chromium behavior | Retained expectation/reference |
62-
| --- | --- | --- |
63-
| [`document.xmlSerialization`](src/compatibility/document/xml-serialization.ts): omits a redundant empty default namespace declaration | Retains the child's `xmlns=""` when the inherited namespace is already empty. | [XML serialization](https://w3c.github.io/DOM-Parsing/#xml-serialization-algorithm) omits the redundant declaration; [pinned WPT](https://github.com/web-platform-tests/wpt/blob/b719612f963a05ece9c89a7dd7598c1c59618874/domparsing/XMLSerializer-serializeToString.html). |
64-
| [`document.xmlSerialization`](src/compatibility/document/xml-serialization.ts): omits a redundant nonempty default namespace declaration | Retains the child's declaration when it repeats the inherited namespace. | Same XML serialization rule and pinned WPT. |
65-
| [`document.xmlSerialization`](src/compatibility/document/xml-serialization.ts): emits attribute nodes as empty strings even when their values are nonempty | Serializes the attribute's escaped value. | The [Attr serialization branch](https://w3c.github.io/DOM-Parsing/#xml-serializing-a-node) returns an empty string. The local case extends WPT's empty-valued Attr with a nonempty value. |
66-
| [`focus.removal`](src/compatibility/focus/removal.ts): removing a focused node clears focus without firing blur | Fires `blur` during removal. | [HTML removing steps](https://html.spec.whatwg.org/multipage/infrastructure.html#html-element-removing-steps). |
67-
| [`elements.input.radioGroups`](src/compatibility/elements/input/radio-groups.ts): groups radios by tree and nonempty name | The previous group member stays checked after a checked detached radio changes name. | [Radio group updates](https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)); [WPT disconnected groups](https://github.com/web-platform-tests/wpt/blob/master/html/semantics/forms/the-input-element/radio-disconnected-group-owner.html). |
68-
| [`elements.input.labels`](src/compatibility/elements/input/labels.ts): keeps retained labels live when a detached control moves under a label | Retained labels stay empty. | [Live labels in the same tree](https://html.spec.whatwg.org/multipage/forms.html#dom-lfe-labels). |
69-
| [`elements.textarea.labels`](src/compatibility/elements/textarea/labels.ts): keeps retained labels live when a detached control moves under a label | Retained labels stay empty. | Same live-label rule. |
70-
| [`element.selectors`](src/compatibility/element/selectors/grammar.ts): WPT `querySelector-mixed-case.html`, mixed HTML/SVG/MathML tree with various mixed-case attributes | `[viewbox]` matches four elements where WPT expects two HTML elements. | The [pinned upstream case](https://github.com/web-platform-tests/wpt/blob/b719612f963a05ece9c89a7dd7598c1c59618874/dom/nodes/querySelector-mixed-case.html) produces the same failure in Chromium; its assertions remain unchanged. |
73+
Browser validation keeps upstream expectations intact. Failures remain enabled
74+
and produce a nonzero exit code. The [browser comparison notes](docs/browser-results.md)
75+
record disagreements reproduced with the original WPT sources.
7176

7277
### Coverage boundaries
7378

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b719612f963a05ece9c89a7dd7598c1c59618874
Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
# Standards references and licenses
1+
# Sources and licenses
22

3-
The compatibility suite tests behavior defined by the [DOM Standard](https://dom.spec.whatwg.org/), [HTML Standard](https://html.spec.whatwg.org/multipage/), [CSSOM](https://drafts.csswg.org/cssom/), and [CSS Cascade](https://drafts.csswg.org/css-cascade/). Each feature module links the relevant specification in its metadata; the [registry](../src/compatibility/registry.ts) maps features to those modules.
3+
The suite uses the WPT revision in [WPT_REVISION](../WPT_REVISION).
4+
Browse the [upstream tree](https://github.com/web-platform-tests/wpt/tree/b719612f963a05ece9c89a7dd7598c1c59618874)
5+
and follow the source paths at the top of each adapted file. Helpers and data
6+
that define test behavior are named there too. Test names and matrices identify
7+
the selected upstream cases; a source reference does not claim the whole file.
48

5-
Web Platform Tests provide additional coverage references for [DOM](https://github.com/web-platform-tests/wpt/tree/master/dom), [HTML](https://github.com/web-platform-tests/wpt/tree/master/html), [CSSOM](https://github.com/web-platform-tests/wpt/tree/master/css/cssom), and [shadow DOM](https://github.com/web-platform-tests/wpt/tree/master/shadow-dom). A reference to WPT does not mean the entire upstream test file or directory runs here.
9+
The [package instructions](../AGENTS.md) require faithful upstream setups,
10+
operations, inputs, and assertions. The consumer supplies a fresh document,
11+
constructors, matchers, cleanup, and host input. Shared upstream setup is repeated
12+
for each fresh fixture; separate documents and retained node identities remain
13+
separate. Callback assertions run through `fixture.step` so the runner observes
14+
failures. Input actions use the host driver, including WPT's viewport-relative
15+
mouse move.
616

7-
[Option selectedness cases](../src/compatibility/elements/option/selectedness.ts) adapt [option-selected.html](https://github.com/web-platform-tests/wpt/blob/b4b303c8dca22989c43e2d76fce199c36d4b77a7/html/semantics/forms/the-option-element/option-selected.html) at commit `b4b303c8dca22989c43e2d76fce199c36d4b77a7`. Copyright © web-platform-tests contributors; original author Corey Farwell. Attribution is retained in the module, with the BSD-3-Clause notice in [test/wpt/LICENSE](../test/wpt/LICENSE).
17+
Selection boundaries and exclusions are documented in:
818

9-
The suite and browser tooling use the repository's [MIT license](../LICENSE), copyright 2026-Present Bombshell contributors.
19+
- [DOM and events](wpt-dom.md)
20+
- [Selectors](wpt-selectors.md)
21+
- [State and style](wpt-state-styles.md)
22+
- [Forms and custom elements](wpt-css-forms.md)
23+
- [Shadow DOM and input](wpt-shadow-input.md)
24+
- [Range, selection, traversal, and parsing](wpt-ranges-parsing.md)
1025

11-
Additional WPT adaptations retain pinned sources, authors, license notices, and
12-
their exact scope in the [state and style](wpt-state-styles.md),
13-
[CSS and forms](wpt-css-forms.md), [shadow and input](wpt-shadow-input.md), and
14-
[range, selection, traversal, and parsing](wpt-ranges-parsing.md) inventories.
15-
The [selector adaptations](wpt-selectors.md) retain the complete shared selector
16-
matrix and identify the upstream files, harness adaptations, and explicit exclusions.
17-
18-
[WPT implicit submission](https://github.com/web-platform-tests/wpt/blob/master/html/semantics/forms/form-submission-0/implicit-submission.optional.html) is optional. The suite keeps this interaction policy independently selectable from input delivery and trusted-event assertions.
26+
Adapted WPT code is copyright web-platform-tests contributors and retains the
27+
[BSD-3-Clause license](../test/wpt/LICENSE). Individual upstream credits are in
28+
[AUTHORS.md](../test/wpt/AUTHORS.md). Original notices inside fixtures are retained.
29+
The harness and browser tooling use the package's [MIT license](../LICENSE).
30+
Specification links in feature modules describe the relevant standards; the
31+
file comments identify the tests being adapted.

0 commit comments

Comments
 (0)