You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8de8b8d
Browse filesBrowse the repository at this point in the historyBrowse files
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.
Copy file name to clipboardExpand all lines: packages/web-platform-tests/README.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,21 @@ Private workspace package containing reusable DOM compatibility assertions. It c
4
4
5
5
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.
6
6
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:
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.
@@ -28,7 +42,7 @@ Supply a runner with `describe`, `it`, and Vitest-compatible `expect` matchers,
28
42
### Harness
29
43
30
44
*`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.
32
46
*`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.
33
47
*`dispose(document)`: Optional cleanup for implementation-owned resources after each case, including failures.
To validate the test suite itself, run it against an actual browser runtime. Browser dependencies are development-only.
50
64
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.
52
66
53
67
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.
54
68
55
69
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.
56
70
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
60
72
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. |
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.
4
8
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
Selection boundaries and exclusions are documented in:
8
18
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)
10
25
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
0 commit comments