Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .changeset/wpt-framework-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@bomb.sh/web-platform-tests': patch
---

Adds framework profiles that map the DOM features React 19.3, Preact 11.2, Vue 3.5, Solid 1.9, and Svelte 5.57 use to the WPT cases covering them. `framework()` returns selectors for a framework and its optional modules, and `uncoveredByWPT()` lists required features without adapted WPT coverage.
Adds framework profiles that map the DOM features React 19.3, Preact 11.2, Vue 3.5, Solid 1.9, and Svelte 5.57 use to the WPT cases covering them. `framework()` returns selectors for a framework and its optional modules, and `uncoveredByWPT()` lists required features without mapped upstream WPT coverage.
4 changes: 1 addition & 3 deletions .changeset/wpt-suite-fidelity.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
'@bomb.sh/web-platform-tests': patch
---

Align the DOM compatibility suite with upstream WPT cases at a shared revision, mirror upstream source paths for tests and helpers, and remove locally authored scenarios and unused code. Keep local harness code in `src/shared`. 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.

Complete supported upstream matrices and record the concrete fixture limitations behind remaining omissions.
Run original upstream Web Platform Tests from a pinned submodule through a package CLI and Vitest transform. Consumers supply a document factory, global bindings, and source/case selection in `wpt.config.ts`. Execute whole files with their upstream helpers and shared state, then report selected subtests individually. Replace the adapted suite, generated registry, and browser adaptation tooling while preserving framework and feature selections.
5 changes: 2 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Preserve upstream WPT conventions. The shared harness files remain linted.
packages/web-platform-tests/src/compatibility/*/**/*.ts
packages/web-platform-tests/src/wpt/**/*.ts
# Preserve the original upstream WPT sources. The harness remains linted.
packages/web-platform-tests/wpt/**
7 changes: 1 addition & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: true
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
- run: pnpm install --frozen-lockfile
- run: pnpm test
Expand All @@ -51,9 +52,3 @@ jobs:
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @bomb.sh/web-platform-tests typecheck
- run: pnpm --filter @bomb.sh/web-platform-tests exec playwright install --with-deps chromium
- run: pnpm --filter @bomb.sh/web-platform-tests test:wpt-selectors
- name: Report Chromium input compatibility
# Browser conformance differences are informational, not UI build failures.
continue-on-error: true
run: pnpm --filter @bomb.sh/web-platform-tests test:browser:input
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "packages/web-platform-tests/wpt"]
path = packages/web-platform-tests/wpt
url = https://github.com/web-platform-tests/wpt.git
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/web-platform-tests/wpt/**
6 changes: 1 addition & 5 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ export default {
overrides: [
...(config.overrides ?? []),
{
files: [
'packages/web-platform-tests/src/**/*.ts',
'packages/web-platform-tests/test/browser/*.ts',
'packages/web-platform-tests/test/browser/*.mts',
],
files: ['packages/web-platform-tests/src/**/*.ts'],
rules: {
// Test registration and factories must return synchronously to the runner.
'bombshell-dev/exported-function-async': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"format": "bsh format",
"format:check": "bsh format --check",
"lint": "bsh lint .",
"test": "pnpm --filter @bomb.sh/web-platform-tests build && bsh test"
"test": "pnpm --filter @bomb.sh/web-platform-tests build && bsh test && pnpm --filter @clack/ui exec wpt"
},
"devDependencies": {
"@bomb.sh/tools": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build": "bsh build --dts",
"format": "bsh format",
"lint": "bsh lint",
"test": "pnpm --filter @bomb.sh/web-platform-tests build && bsh test"
"test": "pnpm --filter @bomb.sh/web-platform-tests build && bsh test && wpt"
},
"dependencies": {
"@bomb.sh/tty": "catalog:",
Expand Down
10 changes: 0 additions & 10 deletions packages/ui/src/dom.compatibility.test.ts

This file was deleted.

54 changes: 30 additions & 24 deletions packages/ui/test/README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
# UI tests

Tests live alongside the implementation in `src/`; this directory contains their shared fixtures and WPT configuration. Run the UI tests from the workspace root:
Tests live alongside the implementation in `src/`; this directory contains their
terminal fixtures. Run the UI tests from the workspace root:

```sh
pnpm --filter @clack/ui test
```

The test script builds the private `@bomb.sh/web-platform-tests` package before running Vitest. Use `pnpm test` from the workspace root to run the workspace tests.
The script builds the private WPT harness, runs local Vitest tests, and runs the
upstream cases selected by [`wpt.config.ts`](../wpt.config.ts). Use `pnpm test`
from the workspace root to run all workspace tests.

## Terminal fixtures

[`createTestUI`](ui.ts) starts the real UI with an in-process [Termless terminal](terminal.ts). It supplies application-facing input/output streams and exposes the document and terminal screen. Use `await using` to dispose the UI and terminal together, and `expect.poll` to wait for rendered output, as in [`ui.test.ts`](../src/ui.test.ts).
[`createTestUI`](ui.ts) starts the real UI with an in-process
[Termless terminal](terminal.ts). It supplies application-facing input/output
streams and exposes the document and terminal screen. Use `await using` to dispose
the UI and terminal together, and `expect.poll` to wait for rendered output, as in
[`ui.test.ts`](../src/ui.test.ts).

[`createTestTerminal`](terminal.ts) can also be used independently. Its `type` and `press` helpers write to the application's input stream, and terminal responses return through that same stream. It is an async disposable resource.
[`createTestTerminal`](terminal.ts) can also be used independently. Its `type` and
`press` helpers write to the application's input stream, and terminal responses
return through that same stream. It is an async disposable resource.

Rendering, scheduling, notifications, and lifecycle behavior belong in the UI tests. [`render.test.ts`](../src/render.test.ts) exercises render requests and cancellation; [`ui.lifecycle.test.ts`](../src/ui.lifecycle.test.ts) exercises terminal restoration, pending writes, and failure propagation.
Rendering, scheduling, notifications, and lifecycle behavior belong in the UI
tests. [`render.test.ts`](../src/render.test.ts) exercises render requests and
cancellation; [`ui.lifecycle.test.ts`](../src/ui.lifecycle.test.ts) exercises
terminal restoration, pending writes, and failure propagation.

## DOM compatibility
## DOM conformance

[`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.
[`wpt.config.ts`](../wpt.config.ts) supplies the document factory and global
bindings used by original Web Platform Test files. Add source paths and original
case names there while implementing DOM behavior. The
[WPT harness README](../../web-platform-tests/README.md) describes selection,
whole-file execution, and fixture capabilities.

[`dom.test.ts`](dom.test.ts) explicitly holds local DOM coverage missing from the enabled WPT cases. This is usually because getting the WPT test prequisites set up is too onerous a task. For example, testing node properties like nextSibling and previousSibling require things like `document.implementation.createDocumentType()`

[`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.

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.

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:
After building the harness once, run selected cases without rebuilding:

```sh
pnpm --filter @clack/ui test src/dom.compatibility.test.ts -t 'Document-createElement.html.*createElement\(foo\)'
pnpm --filter @clack/ui exec wpt Node-parentNode -t 'Root element'
```

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.

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.

## Host input

Host input cases require a [`DOMInputDriver`](../../web-platform-tests/src/shared/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.

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.
Read the upstream source and helpers under
[`packages/web-platform-tests/wpt`](../../web-platform-tests/wpt) when working
through failures. All subtests in selected files execute; only configured and
name-filtered results are reported. Implementation-specific rendering and
lifecycle checks remain in the local UI tests.
62 changes: 24 additions & 38 deletions packages/ui/test/wpt.config.ts → packages/ui/wpt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { WPTConfig } from '@bomb.sh/web-platform-tests';
import type { WPTConfig } from '@bomb.sh/web-platform-tests/config';
import {
createHTMLDocument,
Attr,
CharacterData,
Comment,
Expand All @@ -16,10 +17,11 @@ import {
Node,
Text,
XMLDocument,
} from '../src/dom.ts';
import { NamedNodeMap } from '../src/named-node-map.ts';
} from './src/dom.ts';
import { NamedNodeMap } from './src/named-node-map.ts';

const config: WPTConfig = {
createDocument: () => createHTMLDocument(() => {}),
globals: {
AbortController: globalThis.AbortController,
Attr,
Expand Down Expand Up @@ -60,30 +62,29 @@ const config: WPTConfig = {
// case remains excluded until that behavior is implemented.
],
'dom/nodes/Document-createTextNode.html': true,
'dom/nodes/Document-createElement.html': true,
'dom/nodes/Document-createElementNS.html': true,
'dom/nodes/Document-createElement.html': [/^createElement\(.*\) in HTML document$/],
'dom/nodes/Document-createElementNS.html': [
/^createElementNS test in HTML document:/,
/^(Lower|Upper)-case /,
'null namespace',
'undefined namespace',
'empty string namespace',
],
'dom/nodes/Document-createComment.html': true,
'dom/nodes/DOMImplementation-createDocument.html': [
'createDocument row 0', // null qualified name: no root.
'createDocument row 1', // undefined qualified name: an "undefined" root.
'createDocument row 2', // A root without a namespace.
'createDocument row 3', // Invalid qualified name.
'createDocument row 23', // A prefix requires a namespace.
'createDocument row 63', // A root with a namespace and prefix.
'createDocument row 182', // A non-DocumentType doctype argument.
'createDocument row 183', // Empty qualified name: no root.
'createDocument row 185', // Explicit undefined arguments.
'createDocument test: null,null,null,null',
'createDocument test: null,undefined,null,null',
'createDocument test: null,"foo",null,null',
'createDocument test: null,"1foo",null,"INVALID_CHARACTER_ERR"',
'createDocument test: null,"f:oo",null,"NAMESPACE_ERR"',
'createDocument test: "http://example.com/","f:oo",null,null',
'createDocument test: null,null,false,function "function TypeError() { [native code] }"',
'createDocument test: null,"",null,null',
'createDocument test: undefined,undefined,undefined,null',
'createDocument with missing arguments',
],
'dom/nodes/DOMImplementation-createHTMLDocument.html': [
'createHTMLDocument()',
'createHTMLDocument(null)',
'createHTMLDocument(undefined)',
'createHTMLDocument(foo bar baz)',
'createHTMLDocument(foo\t\tbar baz)',
'createHTMLDocument(foo\n\nbar baz)',
'createHTMLDocument(foo\f\fbar baz)',
'createHTMLDocument(foo\r\rbar baz)',
/^createHTMLDocument test [0-7]:/,
'Missing title argument',
],
// XML cases also require createAttribute() to preserve name casing.
Expand All @@ -97,12 +98,9 @@ const config: WPTConfig = {
'dom/nodes/Element-removeAttributeNS.html': true,
'dom/nodes/Element-setAttribute-crbug-1138487.html': true,
'dom/nodes/Element-hasAttribute.html': [
// The other case requires a parsed HTML fixture.
'hasAttribute should check for attribute presence, irrespective of namespace',
],
'dom/nodes/attributes-namednodemap.html': true,
// Excludes cases requiring XML documents, CSS style reflection, document
// fragments, parsed fixtures, or attachment to document.body.
'dom/nodes/attributes.html': [
'Attribute loses its owner when removed',
'Basic functionality of getAttributeNode/getAttributeNodeNS',
Expand Down Expand Up @@ -188,19 +186,7 @@ const config: WPTConfig = {
'Inserting a node before itself should not move the node',
],
},
exclude: {
'css/**': true,
'custom-elements/**': true,
'dom/**': true,
'domparsing/**': true,
'html/**': true,
'inert/**': true,
'input-events/**': true,
'selection/**': true,
'shadow-dom/**': true,
'uievents/**': true,
'xhr/**': true,
},
exclude: { '**': true },
};

export default config;
Loading
Loading