From 5435162169b432c04f73a43c0f8f6ee68871c5db Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 16 Nov 2026 22:37:42 -0600 Subject: [PATCH 1/3] Run upstream WPT sources through the package CLI --- .eslintignore | 1 + .gitmodules | 3 + .prettierignore | 1 + packages/ui/wpt.config.ts | 22 ++ packages/web-platform-tests/README.md | 33 +++ packages/web-platform-tests/bin/wpt.mjs | 2 + packages/web-platform-tests/knip.json | 10 +- packages/web-platform-tests/package.json | 36 ++- packages/web-platform-tests/src/cli.ts | 59 +++++ packages/web-platform-tests/src/config.ts | 13 + .../web-platform-tests/src/node/document.ts | 56 +++++ packages/web-platform-tests/src/node/run.ts | 225 ++++++++++++++++++ .../web-platform-tests/src/node/source.ts | 170 +++++++++++++ .../web-platform-tests/src/node/window.ts | 13 + packages/web-platform-tests/src/vitest.ts | 146 ++++++++++++ .../web-platform-tests/src/vitest/runner.ts | 81 +++++++ .../src/vitest/selection.ts | 65 +++++ .../test/compatibility-harness.test.ts | 5 +- packages/web-platform-tests/wpt | 1 + pnpm-lock.yaml | 40 +++- 20 files changed, 970 insertions(+), 12 deletions(-) create mode 100644 .gitmodules create mode 100644 .prettierignore create mode 100644 packages/ui/wpt.config.ts create mode 100755 packages/web-platform-tests/bin/wpt.mjs create mode 100644 packages/web-platform-tests/src/cli.ts create mode 100644 packages/web-platform-tests/src/config.ts create mode 100644 packages/web-platform-tests/src/node/document.ts create mode 100644 packages/web-platform-tests/src/node/run.ts create mode 100644 packages/web-platform-tests/src/node/source.ts create mode 100644 packages/web-platform-tests/src/node/window.ts create mode 100644 packages/web-platform-tests/src/vitest.ts create mode 100644 packages/web-platform-tests/src/vitest/runner.ts create mode 100644 packages/web-platform-tests/src/vitest/selection.ts create mode 160000 packages/web-platform-tests/wpt diff --git a/.eslintignore b/.eslintignore index 9cc1f8a..aa1b2c2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ # Preserve upstream WPT conventions. The shared harness files remain linted. packages/web-platform-tests/src/compatibility/*/**/*.ts packages/web-platform-tests/src/wpt/**/*.ts +packages/web-platform-tests/wpt/** diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..88bcb7d --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f7aa94a --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +packages/web-platform-tests/wpt/** diff --git a/packages/ui/wpt.config.ts b/packages/ui/wpt.config.ts new file mode 100644 index 0000000..bd96ee5 --- /dev/null +++ b/packages/ui/wpt.config.ts @@ -0,0 +1,22 @@ +import type { WPTConfig } from '@bomb.sh/web-platform-tests/config'; +import { createHTMLDocument } from './src/dom.ts'; +import adapted from './test/wpt.config.ts'; + +/** Initial raw-source checkpoint; the adapted suite remains the coverage baseline. */ +const config: WPTConfig = { + createDocument: () => createHTMLDocument(() => {}), + globals: { ...adapted.globals }, + include: { + 'dom/nodes/Node-parentNode.html': ['Document', 'Root element'], + 'dom/nodes/Document-createElementNS.html': [ + /^createElementNS test in HTML document:/, + /^(Lower|Upper)-case /, + 'null namespace', + 'undefined namespace', + 'empty string namespace', + ], + }, + exclude: { '**': true }, +}; + +export default config; diff --git a/packages/web-platform-tests/README.md b/packages/web-platform-tests/README.md index 68f1f8e..2b071d0 100644 --- a/packages/web-platform-tests/README.md +++ b/packages/web-platform-tests/README.md @@ -6,6 +6,39 @@ The suite includes adaptations of [Web Platform Tests (WPT)](https://github.com/ 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). Files under `src/wpt` mirror upstream paths with `.ts` appended; the revision applies to all files and cases. See [attribution and licenses](test/wpt/README.md). +### Direct upstream checkpoint + +The `wpt` CLI runs original sources from the pinned `wpt` submodule. The initial +[UI configuration](../ui/wpt.config.ts) selects 208 cases from +`Node-parentNode.html` and `Document-createElementNS.html`. The adapted suite +remains in place while coverage is migrated. + +From the workspace root: + +```sh +git submodule update --init packages/web-platform-tests/wpt +pnpm --filter @bomb.sh/web-platform-tests build +pnpm --filter @clack/ui exec wpt +# Subsequent runs need no rebuild unless the harness changes. +pnpm --filter @clack/ui exec wpt Node-parentNode -t 'Root element' +``` + +The CLI accepts `--config path/to/wpt.config.ts`, optional filename filters, and +`-t`/`--name` for subtest names. Configurations import `WPTConfig` from +`@bomb.sh/web-platform-tests/config` and supply `createDocument`, `globals`, and +source/case selectors. Each upstream file appears separately in Vitest. + +The harness populates fixtures with parse5 and executes unchanged scripts and +static helpers in one window context per file. It uses upstream `testharness.js` +in its shell environment, supplies the document and `defaultView`, then delivers +window `load`. Entire files execute; selection filters the reported results. +Source-loading, setup, and harness failures remain failures regardless of filters. + +The excluded `Removed iframe` case in `Node-parentNode.html` is explicitly forced +to time out after load and the selected cases finish. Selecting that case disables +the exception. Iframe loading, parser-driven script timing, and module/async/defer +scripts are outside this checkpoint. + ### Required WPT correspondence Each file under `src/wpt` corresponds to its upstream path with the final `.ts` removed. For example, `src/wpt/dom/nodes/Document-createElement.html.ts` adapts `dom/nodes/Document-createElement.html`. Keep upstream spelling and capitalization for tests, helpers, and data. Local harness code lives in `src/shared`; comments explain non-obvious adaptations. diff --git a/packages/web-platform-tests/bin/wpt.mjs b/packages/web-platform-tests/bin/wpt.mjs new file mode 100755 index 0000000..fadb052 --- /dev/null +++ b/packages/web-platform-tests/bin/wpt.mjs @@ -0,0 +1,2 @@ +#!/usr/bin/env node +await import('../dist/cli.mjs'); diff --git a/packages/web-platform-tests/knip.json b/packages/web-platform-tests/knip.json index ab35cd0..f6299f3 100644 --- a/packages/web-platform-tests/knip.json +++ b/packages/web-platform-tests/knip.json @@ -6,11 +6,17 @@ "test/browser/compatibility.mjs", "test/browser/run-compatibility.mjs", "test/browser/compatibility-types.mts", - "scripts/*.mjs" + "scripts/*.mjs", + "src/cli.ts", + "src/config.ts", + "src/vitest.ts", + "src/vitest/runner.ts", + "bin/wpt.mjs" ], "project": [ "src/**/*.ts", "test/**/*.{ts,mts,mjs}", - "scripts/*.mjs" + "scripts/*.mjs", + "bin/*.mjs" ] } diff --git a/packages/web-platform-tests/package.json b/packages/web-platform-tests/package.json index c3aec0c..2608622 100644 --- a/packages/web-platform-tests/package.json +++ b/packages/web-platform-tests/package.json @@ -10,11 +10,23 @@ "types": "./dist/index.d.mts", "import": "./dist/index.mjs" }, - "./package.json": "./package.json" + "./package.json": "./package.json", + "./config": { + "types": "./dist/config.d.mts", + "import": "./dist/config.mjs" + }, + "./vitest": { + "types": "./dist/vitest.d.mts", + "import": "./dist/vitest.mjs" + }, + "./vitest/runner": { + "types": "./dist/vitest/runner.d.mts", + "import": "./dist/vitest/runner.mjs" + } }, "scripts": { "generate": "node scripts/generate-registry.mjs", - "build": "pnpm generate && bsh build src/index.ts --dts", + "build": "pnpm generate && bsh build src/index.ts src/config.ts src/cli.ts src/vitest.ts src/vitest/runner.ts --dts", "test": "bsh test", "typecheck": "tsc -p tsconfig.json && tsc -p test/browser/tsconfig.json", "test:browser:build": "pnpm generate && vite build --config test/browser/vite.config.mjs", @@ -29,7 +41,21 @@ "@vitest/expect": "5.0.5", "chai": "^6.2.2", "playwright": "^1.64.1", - "typescript": "^6.0.2", - "vite": "^8.1.0" - } + "typescript": "^6.0.2" + }, + "bin": { + "wpt": "./bin/wpt.mjs" + }, + "dependencies": { + "@bomb.sh/router": "^0.8.0", + "parse5": "^8.1.1", + "vite": "^8.1.0", + "vitest": "5.0.5", + "zod": "^4.4.3" + }, + "files": [ + "dist", + "bin", + "WPT_REVISION" + ] } diff --git a/packages/web-platform-tests/src/cli.ts b/packages/web-platform-tests/src/cli.ts new file mode 100644 index 0000000..19faf3f --- /dev/null +++ b/packages/web-platform-tests/src/cli.ts @@ -0,0 +1,59 @@ +import { + argument, + cli, + command, + description, + multiple, + name, + option, + parse, + printErrors, + printHelp, + schema, +} from '@bomb.sh/router'; +import * as z from 'zod'; +import { runWPT } from './vitest.ts'; + +const app = command( + name('wpt'), + description('Run upstream Web Platform Tests against a configured DOM implementation.'), + option( + name('config'), + description('WPT configuration path, relative to the current directory.'), + schema(z.string().min(1).default('wpt.config.ts')), + ), + option( + name('name'), + cli(['--name', '-t']), + description( + 'Report only subtest names matching this regular expression; each file still executes completely.', + ), + schema(z.string().optional()), + ), + argument( + name('files'), + description('Optional upstream filename filters, using Vitest file selection.'), + multiple(), + schema(z.array(z.string()).default([])), + ), +); + +const result = parse(app, { argv: process.argv.slice(2) }); +if (!result.ok) { + console.error(printErrors(result)); + process.exitCode = 1; +} else if (result.method === 'help') { + process.stdout.write(`${printHelp(result)}\n`); +} else { + try { + const vitest = await runWPT({ + config: result.model.config, + files: [...result.model.files, ...Array.from(result.literals, (literal) => literal.text)], + namePattern: result.model.name, + }); + await vitest.close(); + } catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exitCode = 1; + } +} diff --git a/packages/web-platform-tests/src/config.ts b/packages/web-platform-tests/src/config.ts new file mode 100644 index 0000000..41755ef --- /dev/null +++ b/packages/web-platform-tests/src/config.ts @@ -0,0 +1,13 @@ +/** Source globs select files; arrays select original WPT names within each file. */ +export type WPTSelectors = Readonly>; + +export interface WPTConfig { + /** Create a fresh implementation document for each upstream source file. */ + createDocument(): unknown; + /** DOM constructors and other implementation bindings exposed to upstream scripts. */ + globals?: Record; + include?: WPTSelectors; + exclude?: WPTSelectors; + /** Maximum execution time per source file, in milliseconds. Defaults to 15 seconds. */ + timeout?: number; +} diff --git a/packages/web-platform-tests/src/node/document.ts b/packages/web-platform-tests/src/node/document.ts new file mode 100644 index 0000000..211aca1 --- /dev/null +++ b/packages/web-platform-tests/src/node/document.ts @@ -0,0 +1,56 @@ +import { parse, defaultTreeAdapter as tree, type DefaultTreeAdapterTypes } from 'parse5'; + +const HTML_NS = 'http://www.w3.org/1999/xhtml'; + +class UnsupportedFixtureError extends Error {} + +/** Materialize the parsed document through the consumer's DOM. Scripts remain inert. */ +export function populateDocument(subject: unknown, html: string): void { + const document = subject as Document; + const parsed = parse(html); + while (document.firstChild) { + document.removeChild(document.firstChild); + } + const pending: { source: DefaultTreeAdapterTypes.ParentNode; target: Node }[] = [ + { source: parsed, target: document }, + ]; + while (pending.length > 0) { + const { source, target } = pending.pop()!; + for (const child of source.childNodes) { + if (tree.isTextNode(child)) { + target.appendChild(document.createTextNode(child.value)); + } else if (tree.isCommentNode(child)) { + target.appendChild(document.createComment(child.data)); + } else if (tree.isDocumentTypeNode(child)) { + target.appendChild( + document.implementation.createDocumentType(child.name, child.publicId, child.systemId), + ); + } else if (tree.isElementNode(child)) { + if (child.namespaceURI === HTML_NS && child.tagName === 'frameset') { + throw new UnsupportedFixtureError('Frameset fixtures are not supported'); + } + if ('content' in child) { + throw new UnsupportedFixtureError('Template fixtures are not supported'); + } + const element = + child.namespaceURI === HTML_NS + ? document.createElement(child.tagName) + : document.createElementNS(child.namespaceURI, child.tagName); + copyAttributes(child, element); + target.appendChild(element); + pending.push({ source: child, target: element }); + } + } + } +} + +function copyAttributes(source: DefaultTreeAdapterTypes.Element, target: Element): void { + for (const attribute of source.attrs) { + const name = attribute.prefix ? `${attribute.prefix}:${attribute.name}` : attribute.name; + if (attribute.namespace) { + target.setAttributeNS(attribute.namespace, name, attribute.value); + } else { + target.setAttribute(name, attribute.value); + } + } +} diff --git a/packages/web-platform-tests/src/node/run.ts b/packages/web-platform-tests/src/node/run.ts new file mode 100644 index 0000000..aa8e9b6 --- /dev/null +++ b/packages/web-platform-tests/src/node/run.ts @@ -0,0 +1,225 @@ +import { readFile } from 'node:fs/promises'; +import { clearTimeout, setInterval, setTimeout } from 'node:timers'; +import { setImmediate } from 'node:timers/promises'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { createContext, Script } from 'node:vm'; +import type { WPTConfig } from '../config.ts'; +import { selectsTest } from '../vitest/selection.ts'; +import { populateDocument } from './document.ts'; +import { loadSource, type SourceScript } from './source.ts'; +import { Window } from './window.ts'; + +export interface WPTTestResult { + name: string; + status: number; + message: string | null; + stack?: string | null; +} + +export interface WPTHarnessStatus { + status: number; + message: string | null; + stack?: string | null; +} + +export interface WPTFileResult { + tests: WPTTestResult[]; + status: WPTHarnessStatus; +} + +interface WPTTest extends WPTTestResult { + force_timeout(): void; +} + +interface Harness { + setup(properties: object): void; + add_test_state_callback(callback: (test: WPTTest) => void): void; + add_result_callback(callback: (test: WPTTest) => void): void; + add_completion_callback(callback: (tests: WPTTest[], status: WPTHarnessStatus) => void): void; +} + +class WPTExecutionError extends Error {} + +/** Execute a whole upstream file in one window context before filtering its results. */ +export async function runWPTFile({ + file, + sourceRoot, + config, +}: { + file: string; + sourceRoot: string; + config: WPTConfig; +}): Promise { + const results: WPTTestResult[] = []; + const timers = new Set>(); + const completion = Promise.withResolvers(); + let watchdog: ReturnType | undefined; + let finished = false; + let failure: WPTHarnessStatus | undefined; + const fail = (error: unknown, status = 1): void => { + if (finished) { + return; + } + failure ??= { status, ...describeError(error) }; + completion.resolve({ tests: results, status: failure }); + }; + const onError = (error: unknown): void => fail(error); + try { + const timeout = config.timeout ?? 15_000; + if (!Number.isFinite(timeout) || timeout <= 0) { + throw new WPTExecutionError('The WPT timeout must be a positive number of milliseconds'); + } + const source = await loadSource(file, sourceRoot); + const rootURL = pathToFileURL(sourceRoot.endsWith('/') ? sourceRoot : `${sourceRoot}/`); + const sourcePath = decodeURIComponent(pathToFileURL(file).href.slice(rootURL.href.length)); + const harnessFile = fileURLToPath(new URL('resources/testharness.js', rootURL)); + const harnessCode = await readFile(harnessFile, 'utf8'); + const deadline = Date.now() + timeout; + const window = new Window(); + const context = createContext(window); + const scope = new Script('globalThis').runInContext(context) as Record; + const execute = (script: SourceScript): unknown => + new Script(script.code, { + filename: script.file, + lineOffset: script.lineOffset, + columnOffset: script.columnOffset, + }).runInContext(context, { timeout: Math.max(1, deadline - Date.now()) }); + const invoke = (callback: (...args: unknown[]) => void, args: unknown[]): void => { + if (!finished) { + try { + callback.apply(scope, args); + } catch (error) { + fail(error); + } + } + }; + Object.assign(window, config.globals, { + window: scope, + self: scope, + console, + // Bind bare global calls to the context's window, preserving listener receivers. + addEventListener: window.addEventListener.bind(scope), + removeEventListener: window.removeEventListener.bind(scope), + dispatchEvent: window.dispatchEvent.bind(scope), + setTimeout(callback: (...args: unknown[]) => void, delay = 0, ...args: unknown[]) { + const timer = setTimeout(() => { + timers.delete(timer); + invoke(callback, args); + }, delay); + timers.add(timer); + return timer; + }, + setInterval(callback: (...args: unknown[]) => void, delay = 0, ...args: unknown[]) { + const timer = setInterval(() => invoke(callback, args), delay); + timers.add(timer); + return timer; + }, + clearTimeout(timer: ReturnType) { + clearTimeout(timer); + timers.delete(timer); + }, + queueMicrotask(callback: () => void) { + queueMicrotask(() => invoke(callback, [])); + }, + }); + scope.clearInterval = scope.clearTimeout; + process.on('uncaughtException', onError); + process.on('unhandledRejection', onError); + + // Upstream supplies its shell environment, assertions, scheduling, and cleanup. + // Supplying the document afterward avoids its browser-only HTML reporting APIs. + execute({ file: harnessFile, code: harnessCode }); + const harness = scope as unknown as Harness; + harness.setup({ output: false }); + const registered = new Set(); + const completed = new Set(); + let loaded = false; + const finishUnsupportedIframe = (): void => { + if (!loaded || sourcePath !== 'dom/nodes/Node-parentNode.html') { + return; + } + const selected = (test: WPTTest): boolean => + selectsTest({ source: sourcePath, name: test.name }, config); + if ([...registered].some((test) => selected(test) && !completed.has(test))) { + return; + } + for (const test of registered) { + // This independent case waits on an iframe's own load event, which we cannot deliver. + if (test.name === 'Removed iframe' && !selected(test) && !completed.has(test)) { + test.force_timeout(); + } + } + }; + harness.add_test_state_callback((test) => registered.add(test)); + harness.add_result_callback((test) => { + completed.add(test); + results.push(copyTest(test)); + queueMicrotask(finishUnsupportedIframe); + }); + harness.add_completion_callback((tests, status) => { + completion.resolve({ + tests: Array.from(tests, copyTest), + status: { status: status.status, message: status.message, stack: status.stack }, + }); + }); + const document = config.createDocument() as Document; + Object.defineProperty(window, 'document', { value: document, enumerable: true }); + Object.defineProperty(document, 'defaultView', { + get: () => scope, + enumerable: true, + configurable: true, + }); + if (source.title !== undefined) { + scope.META_TITLE = source.title; + } + populateDocument(document, source.html); + watchdog = setTimeout( + () => { + fail(new WPTExecutionError(`WPT file did not complete within ${timeout}ms: ${file}`), 2); + }, + Math.max(1, deadline - Date.now()), + ); + for (const script of source.scripts) { + execute(script); + } + execute({ + file: 'wpt:load', + code: `{ + const event = new Event('load'); + Object.defineProperty(event, 'target', { value: document, configurable: true }); + window.dispatchEvent(event); + }`, + }); + loaded = true; + finishUnsupportedIframe(); + const result = await completion.promise; + // Native EventTarget reports listener exceptions after dispatch returns. + // Keep those errors associated with this file before releasing its context. + await setImmediate(); + return failure ? { ...result, status: failure } : result; + } catch (error) { + return { tests: results, status: { status: 1, ...describeError(error) } }; + } finally { + finished = true; + clearTimeout(watchdog); + for (const timer of timers) { + clearTimeout(timer); + } + process.off('uncaughtException', onError); + process.off('unhandledRejection', onError); + } +} + +function copyTest(test: WPTTestResult): WPTTestResult { + return { name: test.name, status: test.status, message: test.message, stack: test.stack }; +} + +function describeError(error: unknown): { message: string; stack?: string } { + if (error && typeof error === 'object' && 'message' in error) { + return { + message: String(error.message), + stack: 'stack' in error ? String(error.stack) : undefined, + }; + } + return { message: String(error) }; +} diff --git a/packages/web-platform-tests/src/node/source.ts b/packages/web-platform-tests/src/node/source.ts new file mode 100644 index 0000000..8fee5b3 --- /dev/null +++ b/packages/web-platform-tests/src/node/source.ts @@ -0,0 +1,170 @@ +import { readFile, realpath } from 'node:fs/promises'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { parse, defaultTreeAdapter as tree, type DefaultTreeAdapterTypes } from 'parse5'; + +export interface SourceScript { + file: string; + code: string; + lineOffset?: number; + columnOffset?: number; +} + +export interface SourceFile { + html: string; + scripts: SourceScript[]; + title?: string; +} + +class UnsupportedSourceError extends Error {} + +const origin = 'https://web-platform.test'; +const harnessPath = 'resources/testharness.js'; +const reporterPath = 'resources/testharnessreport.js'; +const javascriptTypes = new Set([ + 'application/ecmascript', + 'application/javascript', + 'application/x-ecmascript', + 'application/x-javascript', + 'text/ecmascript', + 'text/javascript', + 'text/javascript1.0', + 'text/javascript1.1', + 'text/javascript1.2', + 'text/javascript1.3', + 'text/javascript1.4', + 'text/javascript1.5', + 'text/jscript', + 'text/livescript', + 'text/x-ecmascript', + 'text/x-javascript', +]); + +/** Extract static scripts without rewriting upstream code or fixture markup. */ +export async function loadSource(file: string, sourceRoot: string): Promise { + const root = await realpath(sourceRoot); + const filename = await checkedPath(file, root); + const path = decodeURIComponent( + pathToFileURL(filename).href.slice(checkoutURL(root).href.length), + ); + if (/\.sub\.(?:html|js)$/.test(path)) { + throw new UnsupportedSourceError(`Server-substituted WPT sources are not supported: ${path}`); + } + const code = await readFile(filename, 'utf8'); + const source = { path, root }; + if (path.endsWith('.any.js') || path.endsWith('.window.js')) { + const scripts: SourceScript[] = []; + let title: string | undefined; + for (const [, key, value] of code.matchAll(/^\/\/\s*META:\s*(\w+)\s*=\s*(.*?)\s*$/gm)) { + if (key === 'script') { + const script = await loadHelper(value!, source); + if (script) { + scripts.push(script); + } + } else if (key === 'title') { + title = value; + } else if (key === 'variant') { + throw new UnsupportedSourceError(`WPT URL variants are not supported: ${path}`); + } else if (key === 'global' && !value!.split(',').some((name) => name.trim() === 'window')) { + throw new UnsupportedSourceError( + `Only the window variant of JavaScript WPT files is supported: ${path}`, + ); + } + } + scripts.push({ file: filename, code }); + return { html: '', scripts, title }; + } + if (!path.endsWith('.html')) { + throw new UnsupportedSourceError(`Unsupported WPT source type: ${path}`); + } + const document = parse(code, { sourceCodeLocationInfo: true }); + const elements: DefaultTreeAdapterTypes.Element[] = []; + const pending: DefaultTreeAdapterTypes.Node[] = [document]; + let title: string | undefined; + while (pending.length > 0) { + const node = pending.pop()!; + if (tree.isElementNode(node)) { + if (node.tagName === 'script') { + if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml') { + throw new UnsupportedSourceError(`Non-HTML script elements are not supported: ${path}`); + } + elements.push(node); + } else if (node.tagName === 'base' && node.attrs.some(({ name }) => name === 'href')) { + throw new UnsupportedSourceError(`WPT fixtures with a base URL are not supported: ${path}`); + } else if (node.tagName === 'title' && title === undefined) { + title = node.childNodes + .filter(tree.isTextNode) + .map((child) => child.value) + .join(''); + } + } + if ('childNodes' in node) { + for (let index = node.childNodes.length - 1; index >= 0; index--) { + pending.push(node.childNodes[index]!); + } + } + } + elements.sort((a, b) => a.sourceCodeLocation!.startOffset - b.sourceCodeLocation!.startOffset); + const scripts: SourceScript[] = []; + for (const element of elements) { + const attributes = new Map(element.attrs.map(({ name, value }) => [name, value])); + const type = attributes.get('type')?.trim().toLowerCase() ?? ''; + if (type === 'module' || attributes.has('async') || attributes.has('defer')) { + throw new UnsupportedSourceError( + `Module and asynchronous script loading are not supported: ${path}`, + ); + } + if (type && !javascriptTypes.has(type)) { + continue; + } + const src = attributes.get('src'); + if (src !== undefined) { + const script = await loadHelper(src, source); + if (script) { + scripts.push(script); + } + } else { + const location = element.sourceCodeLocation!; + const start = location.startTag!; + scripts.push({ + file: filename, + code: code.slice(start.endOffset, location.endTag?.startOffset ?? location.endOffset), + lineOffset: start.endLine - 1, + columnOffset: start.endCol - 1, + }); + } + } + return { html: code, scripts, title }; +} + +async function loadHelper( + src: string, + { path, root }: { path: string; root: string }, +): Promise { + const url = new URL(src, `${origin}/${path}`); + const helper = decodeURIComponent(url.pathname).slice(1); + if (url.origin !== origin || url.search || /\.(?:sub\.js|py)$/.test(helper)) { + throw new UnsupportedSourceError( + `Only static helpers from the WPT checkout are supported: ${src}`, + ); + } + if (helper === harnessPath || helper === reporterPath) { + return null; + } + const file = await checkedPath( + fileURLToPath(new URL(url.pathname.slice(1), checkoutURL(root))), + root, + ); + return { file, code: await readFile(file, 'utf8') }; +} + +async function checkedPath(file: string, root: string): Promise { + const filename = await realpath(file); + if (!pathToFileURL(filename).href.startsWith(checkoutURL(root).href)) { + throw new UnsupportedSourceError(`WPT sources must be inside the source checkout: ${file}`); + } + return filename; +} + +function checkoutURL(root: string): URL { + return pathToFileURL(root.endsWith('/') ? root : `${root}/`); +} diff --git a/packages/web-platform-tests/src/node/window.ts b/packages/web-platform-tests/src/node/window.ts new file mode 100644 index 0000000..34ee953 --- /dev/null +++ b/packages/web-platform-tests/src/node/window.ts @@ -0,0 +1,13 @@ +import { setMaxListeners } from 'node:events'; + +/** Fixture script global with an event target independent of its document. */ +export class Window extends EventTarget { + // Installed after initializing upstream testharness.js in its shell environment. + declare readonly document: Document; + + constructor() { + super(); + // Whole WPT files register hundreds of load listeners on the same window. + setMaxListeners(0, this); + } +} diff --git a/packages/web-platform-tests/src/vitest.ts b/packages/web-platform-tests/src/vitest.ts new file mode 100644 index 0000000..7245210 --- /dev/null +++ b/packages/web-platform-tests/src/vitest.ts @@ -0,0 +1,146 @@ +import { access, readdir } from 'node:fs/promises'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { loadConfigFromFile, normalizePath, type Plugin } from 'vite'; +import { startVitest, type Vitest } from 'vitest/node'; +import { defineConfig } from 'vitest/config'; +import type { WPTConfig, WPTSelectors } from './config.ts'; +import { matchesSource, selectsFile } from './vitest/selection.ts'; + +export interface RunWPTOptions { + config: string; + files?: string[]; + namePattern?: string; +} + +class WPTConfigurationError extends Error { + constructor(message: string) { + super(message); + this.name = 'WPTConfigurationError'; + } +} + +function validateSelectors( + selectors: WPTSelectors | undefined, + { files, kind }: { files: string[]; kind: string }, +): void { + if (selectors === undefined) { + return; + } + if (!selectors || typeof selectors !== 'object' || Array.isArray(selectors)) { + throw new WPTConfigurationError(`${kind} must map source paths to true or case selectors`); + } + for (const [pattern, cases] of Object.entries(selectors)) { + if (!pattern || (cases !== true && (!Array.isArray(cases) || cases.length === 0))) { + throw new WPTConfigurationError(`Invalid ${kind} selector for ${JSON.stringify(pattern)}`); + } + if (!files.some((file) => matchesSource(file, pattern))) { + throw new WPTConfigurationError( + `${kind} source ${JSON.stringify(pattern)} matched no WPT files`, + ); + } + if (cases !== true) { + for (const selector of cases) { + if ( + (typeof selector !== 'string' || selector.length === 0) && + !(selector instanceof RegExp) + ) { + throw new WPTConfigurationError(`Invalid ${kind} case selector for ${pattern}`); + } + } + } + } +} + +function wptTransform(options: { sourceRoot: string; files: string[] }): Plugin { + const files = new Set( + options.files.map((file) => normalizePath(`${options.sourceRoot}/${file}`)), + ); + const runner = normalizePath( + fileURLToPath(import.meta.resolve('@bomb.sh/web-platform-tests/vitest/runner')), + ); + return { + name: 'wpt-html-tests', + enforce: 'pre', + configureVitest({ defineCacheKeyGenerator }) { + // The upstream file's contents do not include this generated test module. + defineCacheKeyGenerator(({ id }) => (files.has(normalizePath(id)) ? false : undefined)); + }, + transform(_source, id) { + if (!files.has(normalizePath(id))) { + return; + } + return { + code: [ + `import { registerWPTFile } from ${JSON.stringify(runner)};`, + `await registerWPTFile(${JSON.stringify(id)});`, + ].join('\n'), + map: null, + }; + }, + }; +} + +/** Run selected upstream files with the package's Vitest configuration. */ +export async function runWPT(options: RunWPTOptions): Promise { + const configFile = fileURLToPath(pathToFileURL(options.config)); + const packageRoot = new URL( + './', + import.meta.resolve('@bomb.sh/web-platform-tests/package.json'), + ); + const sourceRoot = fileURLToPath(new URL('wpt', packageRoot)); + try { + await access(new URL('wpt/resources/testharness.js', packageRoot)); + } catch { + throw new WPTConfigurationError( + 'WPT checkout is missing. Run git submodule update --init --recursive.', + ); + } + if (options.namePattern !== undefined) { + RegExp(options.namePattern); + } + const loaded = await loadConfigFromFile({ command: 'serve', mode: 'test' }, configFile); + if (!loaded) { + throw new WPTConfigurationError(`Unable to load WPT configuration ${configFile}`); + } + const config = loaded.config as unknown as WPTConfig; + if (typeof config.createDocument !== 'function') { + throw new WPTConfigurationError('WPT configuration must provide createDocument().'); + } + if (config.timeout !== undefined && (!Number.isFinite(config.timeout) || config.timeout <= 0)) { + throw new WPTConfigurationError('WPT timeout must be a positive number of milliseconds.'); + } + const files = (await readdir(sourceRoot, { recursive: true })) + .map((file) => normalizePath(file)) + .filter((file) => /(?:\.html|\.any\.js|\.window\.js)$/.test(file)); + validateSelectors(config.include, { files, kind: 'include' }); + validateSelectors(config.exclude, { files, kind: 'exclude' }); + const included = files.filter((file) => selectsFile(file, config)); + if (included.length === 0) { + throw new WPTConfigurationError('WPT configuration selected no files.'); + } + const vitest = await startVitest( + options.files ?? [], + { config: false, run: true }, + defineConfig({ + root: sourceRoot, + cacheDir: fileURLToPath(new URL('node_modules/.vite/wpt', packageRoot)), + plugins: [wptTransform({ sourceRoot, files: included })], + test: { + include: included, + provide: { wpt: { configFile, sourceRoot, namePattern: options.namePattern } }, + environment: 'node', + // Each upstream file owns its script globals and top-level lexical bindings. + pool: 'forks', + isolate: true, + maxWorkers: 1, + passWithNoTests: true, + experimental: { viteModuleRunner: true }, + }, + }), + ); + if (vitest.state.getFiles().length === 0) { + await vitest.close(); + throw new WPTConfigurationError('No configured WPT files matched the filename filters.'); + } + return vitest; +} diff --git a/packages/web-platform-tests/src/vitest/runner.ts b/packages/web-platform-tests/src/vitest/runner.ts new file mode 100644 index 0000000..3e429c3 --- /dev/null +++ b/packages/web-platform-tests/src/vitest/runner.ts @@ -0,0 +1,81 @@ +import { pathToFileURL } from 'node:url'; +import { inject, test } from 'vitest'; +import type { WPTConfig } from '../config.ts'; +import { runWPTFile } from '../node/run.ts'; +import { matchesName, matchesSource, selectsTest } from './selection.ts'; + +declare module 'vitest' { + export interface ProvidedContext { + wpt: { + configFile: string; + sourceRoot: string; + namePattern?: string; + }; + } +} + +class WPTFailure extends Error { + constructor(message: string, stack?: string | null) { + super(message); + this.name = 'WPTFailure'; + if (stack) { + this.stack = `${this.name}: ${message}\n${stack}`; + } + } +} + +/** Execute upstream once during collection, then register only selected results. */ +export async function registerWPTFile(file: string): Promise { + const { configFile, sourceRoot, namePattern } = inject('wpt'); + const { default: config } = (await import(configFile)) as { default: WPTConfig }; + const source = decodeURIComponent( + pathToFileURL(file).href.slice(pathToFileURL(`${sourceRoot}/`).href.length), + ); + const result = await runWPTFile({ file, sourceRoot, config }); + const expression = namePattern === undefined ? undefined : new RegExp(namePattern); + + // Exact file selectors can be checked here without executing unrelated files. + for (const [kind, selectors] of Object.entries({ + include: config.include, + exclude: config.exclude, + })) { + for (const [pattern, cases] of Object.entries(selectors ?? {})) { + if ( + result.status.status !== 0 || + pattern.includes('*') || + !matchesSource(source, pattern) || + cases === true + ) { + continue; + } + for (const selector of cases) { + if (!result.tests.some((entry) => matchesName(entry.name, selector))) { + test(`WPT configuration: ${kind} case ${String(selector)}`, () => { + throw new WPTFailure( + `${kind} case ${String(selector)} in ${source} matched no WPT tests`, + ); + }); + } + } + } + } + + for (const entry of result.tests) { + if (!selectsTest({ source, name: entry.name }, config)) { + continue; + } + if (expression && !expression.test(entry.name)) { + continue; + } + test(entry.name, () => { + if (entry.status !== 0) { + throw new WPTFailure(entry.message || `WPT status ${entry.status}`, entry.stack); + } + }); + } + if (result.status.status !== 0) { + test('WPT harness completion', () => { + throw new WPTFailure(result.status.message || 'WPT harness failed', result.status.stack); + }); + } +} diff --git a/packages/web-platform-tests/src/vitest/selection.ts b/packages/web-platform-tests/src/vitest/selection.ts new file mode 100644 index 0000000..60ee2c2 --- /dev/null +++ b/packages/web-platform-tests/src/vitest/selection.ts @@ -0,0 +1,65 @@ +import type { WPTConfig, WPTSelectors } from '../config.ts'; + +const sourcePatterns = new Map(); + +/** Match the upstream-relative source globs accepted by WPT configuration. */ +export function matchesSource(source: string, pattern: string): boolean { + const cached = sourcePatterns.get(pattern); + if (cached) { + return cached.test(source); + } + let expression = '^'; + for (let index = 0; index < pattern.length; index++) { + const character = pattern[index]!; + if (character === '*') { + if (pattern[index + 1] === '*') { + index++; + if (pattern[index + 1] === '/') { + index++; + expression += '(?:.*/)?'; + } else { + expression += '.*'; + } + } else { + expression += '[^/]*'; + } + } else { + expression += character.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'); + } + } + const compiled = new RegExp(`${expression}$`); + sourcePatterns.set(pattern, compiled); + return compiled.test(source); +} + +export function matchesName(name: string, selector: string | RegExp): boolean { + if (typeof selector === 'string') { + return name === selector; + } + return new RegExp(selector.source, selector.flags).test(name); +} + +export function selectsFile( + source: string, + { include, exclude }: Pick, +): boolean { + if (Object.keys(include ?? {}).some((pattern) => matchesSource(source, pattern))) { + return true; + } + return !Object.entries(exclude ?? {}).some( + ([pattern, cases]) => cases === true && matchesSource(source, pattern), + ); +} + +export function selectsTest( + { source, name }: { source: string; name: string }, + { include, exclude }: Pick, +): boolean { + const matches = (selectors: WPTSelectors | undefined): boolean => + Object.entries(selectors ?? {}).some( + ([pattern, cases]) => + matchesSource(source, pattern) && + (cases === true || cases.some((selector) => matchesName(name, selector))), + ); + return matches(include) || !matches(exclude); +} diff --git a/packages/web-platform-tests/test/compatibility-harness.test.ts b/packages/web-platform-tests/test/compatibility-harness.test.ts index aad9a04..ea9bfbd 100644 --- a/packages/web-platform-tests/test/compatibility-harness.test.ts +++ b/packages/web-platform-tests/test/compatibility-harness.test.ts @@ -129,7 +129,8 @@ describe('compatibility catalogue', () => { } const knownFiles = new Set(allFiles); const reachable = new Set(); - const pending = ['index.ts', ...entrypoints]; + // The CLI and generated Vitest modules are separate package entrypoints. + const pending = ['index.ts', 'cli.ts', 'vitest/runner.ts', ...entrypoints]; while (pending.length) { const file = pending.pop()!; if (reachable.has(file)) continue; @@ -145,7 +146,7 @@ describe('compatibility catalogue', () => { for (const file of files) { expect( reachable.has(file), - `${file} must be reachable from the package API or a WPT test`, + `${file} must be reachable from a package entrypoint or a WPT test`, ).toBe(true); } }); diff --git a/packages/web-platform-tests/wpt b/packages/web-platform-tests/wpt new file mode 160000 index 0000000..b719612 --- /dev/null +++ b/packages/web-platform-tests/wpt @@ -0,0 +1 @@ +Subproject commit b719612f963a05ece9c89a7dd7598c1c59618874 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f3f7e5..1e6daee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,22 @@ importers: version: link:../web-platform-tests packages/web-platform-tests: + dependencies: + '@bomb.sh/router': + specifier: ^0.8.0 + version: 0.8.0 + parse5: + specifier: ^8.1.1 + version: 8.1.1 + vite: + specifier: ^8.1.0 + version: 8.3.5(@types/node@22.20.0)(jiti@2.7.0)(yaml@2.9.1) + vitest: + specifier: 5.0.5 + version: 5.0.5(@types/node@22.20.0)(vite@8.3.5(@types/node@22.20.0)(jiti@2.7.0)(yaml@2.9.1)) + zod: + specifier: ^4.4.3 + version: 4.4.3 devDependencies: '@vitest/expect': specifier: 5.0.5 @@ -66,15 +82,16 @@ importers: typescript: specifier: ^6.0.2 version: 6.0.3 - vite: - specifier: ^8.1.0 - version: 8.3.5(@types/node@22.20.0)(jiti@2.7.0)(yaml@2.9.1) packages: '@bomb.sh/args@0.3.1': resolution: {integrity: sha512-CwxKrfgcorUPP6KfYD59aRdBYWBTsfsxT+GmoLVnKo5Tmyoqbpo0UNcjngRMyU+6tiPbd18RuIYxhgAn44wU/Q==} + '@bomb.sh/router@0.8.0': + resolution: {integrity: sha512-9Y0fA76+dlFL8aRf8PVfgXrI0qHr4GQrLLv09E75tGRqCtCI5+E/ZzLnyTGJMo/j4CzYt44c4jdXDLv+m9/g9g==} + engines: {node: '>= 20'} + '@bomb.sh/tools@0.8.0': resolution: {integrity: sha512-iaWws8S5kMuS6zImKXPSguUoQYA5M8XlK4ObVJI5jvubNeSlCI6feGPwex9GHyO+eIsi6izv/swO1ceO2MWEvw==} hasBin: true @@ -1360,6 +1377,10 @@ packages: resolution: {integrity: sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==} engines: {node: '>=20.19.0'} + entities@9.0.0: + resolution: {integrity: sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==} + engines: {node: '>=20.19.0'} + es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -1666,6 +1687,9 @@ packages: pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} + parse5@8.1.1: + resolution: {integrity: sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -1994,6 +2018,10 @@ snapshots: '@bomb.sh/args@0.3.1': {} + '@bomb.sh/router@0.8.0': + dependencies: + '@standard-schema/spec': 1.1.0 + '@bomb.sh/tools@0.8.0(@types/node@22.20.0)(oxc-resolver@11.20.0)(unrun@0.2.39)(vite@8.3.5(@types/node@22.20.0)(jiti@2.7.0)(yaml@2.9.1))': dependencies: '@bomb.sh/args': 0.3.1 @@ -2953,6 +2981,8 @@ snapshots: entities@8.1.0: {} + entities@9.0.0: {} + es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -3280,6 +3310,10 @@ snapshots: pako@1.0.11: optional: true + parse5@8.1.1: + dependencies: + entities: 9.0.0 + picocolors@1.1.1: {} picomatch@4.0.7: {} From 37c811093b3ff10f7a143aad9459a522693df9b1 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 16 Nov 2026 22:56:33 -0600 Subject: [PATCH 2/3] Replace the adapted WPT suite with upstream execution --- .changeset/wpt-framework-profiles.md | 5 - .changeset/wpt-suite-fidelity.md | 4 +- .eslintignore | 4 +- .github/workflows/check.yml | 7 +- oxlint.config.ts | 6 +- package.json | 2 +- packages/ui/package.json | 2 +- packages/ui/src/dom.compatibility.test.ts | 10 - packages/ui/test/README.md | 54 +- packages/ui/test/wpt.config.ts | 206 - packages/ui/wpt.config.ts | 180 +- packages/web-platform-tests/AGENTS.md | 111 +- packages/web-platform-tests/README.md | 169 +- packages/web-platform-tests/docs/omissions.md | 45 - packages/web-platform-tests/knip.json | 33 +- packages/web-platform-tests/package.json | 16 +- .../scripts/check-wpt-selectors.mjs | 469 --- .../scripts/generate-registry.mjs | 63 - .../src/frameworks/features.ts | 234 -- .../src/frameworks/frameworks.ts | 231 -- packages/web-platform-tests/src/index.ts | 36 +- packages/web-platform-tests/src/node/run.ts | 58 +- .../web-platform-tests/src/shared/context.ts | 65 - .../web-platform-tests/src/shared/fixture.ts | 120 - .../web-platform-tests/src/shared/globals.ts | 128 - .../src/shared/input-driver.ts | 90 - .../web-platform-tests/src/shared/registry.ts | 834 ---- .../src/shared/restore-scripts.ts | 25 - .../src/shared/selection.ts | 98 - .../src/shared/selectors.ts | 49 - .../src/shared/test-dom-compatibility.ts | 58 - packages/web-platform-tests/src/vitest.ts | 2 + .../css/css-cascade/inherit-initial.html.ts | 75 - .../wpt/css/css-cascade/layer-basic.html.ts | 536 --- .../css/css-cascade/layer-important.html.ts | 119 - .../css-cascade/layer-vs-inline-style.html.ts | 73 - .../css-cascade/unset-value-storage.html.ts | 37 - .../css/css-variables/variable-cycles.html.ts | 144 - .../variable-reference-cssom.html.ts | 94 - ...ariable-reference-shorthands-cssom.html.ts | 54 - ...tyleDeclaration-indexed-properties.html.ts | 128 - ...leSheet-constructable-invalidation.html.ts | 89 - ...eet-constructable-replace-cssRules.html.ts | 53 - .../cssom/CSSStyleSheet-constructable.html.ts | 1107 ----- .../src/wpt/css/cssom/CSSStyleSheet.html.ts | 515 --- .../css/cssom/MutationObserver-style.html.ts | 43 - .../wpt/css/cssom/computed-style-001.html.ts | 116 - .../cssom/computed-style-set-property.html.ts | 107 - .../cssom/css-style-attr-decl-block.html.ts | 179 - .../css-style-attribute-modifications.html.ts | 22 - .../cssom/cssom-setProperty-shorthand.html.ts | 133 - .../css/selectors/focus-visible-001.html.ts | 85 - .../css/selectors/focus-visible-002.html.ts | 119 - .../css/selectors/focus-visible-003.html.ts | 127 - .../selectors/focus-within-focus-move.html.ts | 48 - .../selectors/focus-within-removal.html.ts | 53 - .../wpt/css/selectors/focus-within.html.ts | 83 - .../src/wpt/css/selectors/has-basic.html.ts | 437 -- .../input-pseudo-classes-in-has.html.ts | 325 -- .../user-action-pseudo-classes-in-has.html.ts | 145 - .../wpt/css/selectors/is-where-basic.html.ts | 403 -- .../CustomElementRegistry.html.ts | 1453 ------- .../HTMLElement-constructor.html.ts | 218 - .../custom-elements/adopted-callback.html.ts | 452 -- .../attribute-changed-callback.html.ts | 615 --- .../connected-callbacks.html.ts | 176 - ...lement-reentrant-construction.window.js.ts | 65 - ...ss-realm-callback-report-exception.html.ts | 232 -- .../custom-element-reaction-queue.html.ts | 310 -- .../disconnected-callbacks.html.ts | 181 - .../ElementInternals-form.html.ts | 103 - .../resources/custom-elements-helpers.js.ts | 251 -- .../src/wpt/custom-elements/upgrading.html.ts | 465 --- .../src/wpt/dom/common.js.ts | 1463 ------- .../AddEventListenerOptions-once.any.js.ts | 104 - .../AddEventListenerOptions-passive.any.js.ts | 173 - .../AddEventListenerOptions-signal.any.js.ts | 186 - .../dom/events/Event-constructors.any.js.ts | 152 - ...nt-defaultPrevented-after-dispatch.html.ts | 67 - .../Event-dispatch-bubbles-false.html.ts | 235 -- .../Event-dispatch-bubbles-true.html.ts | 274 -- .../Event-dispatch-handlers-changed.html.ts | 114 - ...ent-dispatch-multiple-cancelBubble.html.ts | 55 - ...-dispatch-multiple-stopPropagation.html.ts | 55 - ...Event-dispatch-propagation-stopped.html.ts | 71 - .../dom/events/Event-dispatch-reenter.html.ts | 111 - .../Event-dispatch-target-moved.html.ts | 103 - .../events/Event-dispatch-throwing.html.ts | 71 - .../Event-stopImmediatePropagation.html.ts | 32 - .../events/EventListener-handleEvent.html.ts | 61 - .../EventListenerOptions-capture.html.ts | 132 - .../EventTarget-add-remove-listener.any.js.ts | 24 - .../EventTarget-addEventListener.any.js.ts | 11 - ...ntTarget-dispatchEvent-returnvalue.html.ts | 94 - .../events/EventTarget-dispatchEvent.html.ts | 108 - .../EventTarget-removeEventListener.any.js.ts | 12 - .../EventTarget-this-of-listener.html.ts | 183 - .../dom/events/remove-all-listeners.html.ts | 95 - ...MTokenList-coverage-for-attributes.html.ts | 46 - .../nodes/CharacterData-appendData.html.ts | 60 - .../wpt/dom/nodes/CharacterData-data.html.ts | 135 - .../nodes/CharacterData-deleteData.html.ts | 114 - .../nodes/CharacterData-insertData.html.ts | 109 - .../dom/nodes/CharacterData-remove.html.ts | 24 - .../nodes/CharacterData-replaceData.html.ts | 172 - .../nodes/CharacterData-substringData.html.ts | 147 - .../src/wpt/dom/nodes/ChildNode-remove.js.ts | 48 - .../DOMImplementation-createDocument.html.ts | 217 - ...MImplementation-createHTMLDocument.html.ts | 236 -- .../wpt/dom/nodes/Document-adoptNode.html.ts | 104 - .../nodes/Document-createAttribute.html.ts | 83 - .../dom/nodes/Document-createComment.html.ts | 29 - .../dom/nodes/Document-createElement.html.ts | 105 - .../nodes/Document-createElementNS.html.ts | 235 -- .../dom/nodes/Document-createElementNS.js.ts | 193 - .../dom/nodes/Document-createTextNode.html.ts | 26 - .../dom/nodes/Document-getElementById.html.ts | 514 --- .../wpt/dom/nodes/Document-importNode.html.ts | 63 - .../DocumentFragment-constructor.html.ts | 19 - ...uerySelectorAll-after-modification.html.ts | 23 - .../wpt/dom/nodes/Element-classlist.html.ts | 649 --- .../Element-closest-null-selectors.html.ts | 22 - .../src/wpt/dom/nodes/Element-closest.html.ts | 82 - .../dom/nodes/Element-hasAttribute.html.ts | 33 - .../dom/nodes/Element-hasAttributes.html.ts | 68 - ...lement-matches-active-pseudo-class.html.ts | 36 - ...t-matches-complex-nth-last-of-type.html.ts | 15 - ...ment-matches-disabled-pseudo-class.html.ts | 128 - ...lement-matches-namespaced-elements.html.ts | 23 - .../src/wpt/dom/nodes/Element-matches.html.ts | 6 - .../src/wpt/dom/nodes/Element-matches.js.ts | 93 - ...t-querySelectorAll-context-element.html.ts | 34 - .../src/wpt/dom/nodes/Element-remove.html.ts | 13 - .../dom/nodes/Element-removeAttribute.html.ts | 55 - .../nodes/Element-removeAttributeNS.html.ts | 18 - ...Element-setAttribute-crbug-1138487.html.ts | 26 - .../dom/nodes/Element-setAttribute.html.ts | 36 - .../nodes/Element-setAttributeNodeNS.html.ts | 56 - .../nodes/MutationObserver-attributes.html.ts | 1499 ------- ...tationObserver-callback-order.window.js.ts | 82 - .../MutationObserver-callback-tricky.html.ts | 56 - .../MutationObserver-characterData.html.ts | 691 ---- .../nodes/MutationObserver-childList.html.ts | 1250 ------ ...Observer-overlapping-registrations.html.ts | 115 - .../dom/nodes/MutationObserver-sanity.html.ts | 245 -- .../MutationObserver-takeRecords.html.ts | 94 - ...ransient-registered-observers.window.js.ts | 429 -- .../src/wpt/dom/nodes/Node-childNodes.html.ts | 126 - .../src/wpt/dom/nodes/Node-cloneNode.html.ts | 409 -- .../Node-compareDocumentPosition.html.ts | 94 - .../src/wpt/dom/nodes/Node-contains.html.ts | 31 - .../wpt/dom/nodes/Node-insertBefore.html.ts | 525 --- .../nodes/Node-isConnected-shadow-dom.html.ts | 28 - .../wpt/dom/nodes/Node-isConnected.html.ts | 38 - .../wpt/dom/nodes/Node-isEqualNode.html.ts | 170 - .../src/wpt/dom/nodes/Node-isSameNode.html.ts | 92 - .../dom/nodes/Node-mutation-adoptNode.html.ts | 32 - .../src/wpt/dom/nodes/Node-nodeValue.html.ts | 39 - .../src/wpt/dom/nodes/Node-normalize.html.ts | 96 - .../wpt/dom/nodes/Node-parentElement.html.ts | 108 - .../src/wpt/dom/nodes/Node-parentNode.html.ts | 28 - .../wpt/dom/nodes/Node-removeChild.html.ts | 65 - .../wpt/dom/nodes/Node-replaceChild.html.ts | 552 --- .../wpt/dom/nodes/Node-textContent.html.ts | 349 -- .../wpt/dom/nodes/ParentNode-append.html.ts | 250 -- .../wpt/dom/nodes/ParentNode-children.html.ts | 30 - .../wpt/dom/nodes/ParentNode-prepend.html.ts | 88 - ...e-querySelector-All-comma-selector.html.ts | 38 - ...rentNode-querySelector-All-content.html.ts | 378 -- ...arentNode-querySelector-All-content.xht.ts | 373 -- ...ode-querySelector-All-multiple-not.html.ts | 44 - ...ParentNode-querySelector-All-scope.html.ts | 101 - .../ParentNode-querySelector-All-xht.xht.ts | 6 - .../ParentNode-querySelector-All.html.ts | 6 - .../nodes/ParentNode-querySelector-All.js.ts | 174 - ...ySelector-argument-stringification.html.ts | 48 - ...ode-querySelector-attribute-change.html.ts | 48 - ...ParentNode-querySelector-basic-has.html.ts | 44 - ...ode-querySelector-case-insensitive.html.ts | 22 - ...entNode-querySelector-class-change.html.ts | 44 - .../ParentNode-querySelector-dupe-id.html.ts | 41 - ...uerySelector-empty-attribute-value.html.ts | 57 - .../ParentNode-querySelector-escapes.html.ts | 114 - ...de-querySelector-host-pseudo-class.html.ts | 30 - ...ntNode-querySelector-hyphen-prefix.html.ts | 96 - ...ParentNode-querySelector-innerHTML.html.ts | 25 - ...querySelector-invalid-comment-like.html.ts | 87 - ...erySelector-is-nested-pseudo-class.html.ts | 72 - .../ParentNode-querySelector-is-not.html.ts | 50 - ...uerySelector-last-child-combinator.html.ts | 46 - .../ParentNode-querySelector-matches.html.ts | 83 - ...ySelector-multiple-attributes-xml.xhtml.ts | 43 - ...lector-namespace-tagname-attribute.html.ts | 74 - ...ode-querySelector-nested-nth-child.html.ts | 45 - .../ParentNode-querySelector-nested.html.ts | 46 - ...-querySelector-nth-of-type-complex.html.ts | 45 - ...entNode-querySelector-orphan-scope.html.ts | 37 - ...tNode-querySelector-parent-context.html.ts | 29 - ...entNode-querySelector-scope-in-not.html.ts | 40 - ...de-querySelector-scope-numeric-id.xhtml.ts | 30 - .../ParentNode-querySelector-scope.html.ts | 43 - ...querySelector-shadowroot-nth-child.html.ts | 34 - ...entNode-querySelector-svg-not-root.html.ts | 29 - .../ParentNode-querySelector-tag-case.html.ts | 92 - ...erySelector-underscore-local-name.xhtml.ts | 26 - ...rySelector-xml-capitalization.window.js.ts | 63 - ...ll-case-insensitive-attribute-flag.html.ts | 57 - ...entNode-querySelectorAll-namespace.html.ts | 47 - ...de-querySelectorAll-nested-not-has.html.ts | 64 - ...de-querySelectorAll-not-descendant.html.ts | 59 - ...-querySelectorAll-removed-elements.html.ts | 32 - ...Node-querySelectorAll-scope-change.html.ts | 31 - ...rySelectorAll-scope-colon-id-class.html.ts | 47 - ...ntNode-querySelectorAll-svg-append.html.ts | 35 - ...entNode-querySelectorAll-svg-class.html.ts | 20 - ...arentNode-querySelectors-exclusive.html.ts | 34 - ...rentNode-querySelectors-namespaces.html.ts | 22 - ...ors-space-and-dash-attribute-value.html.ts | 69 - .../src/wpt/dom/nodes/Text-splitText.html.ts | 53 - .../wpt/dom/nodes/append-on-Document.html.ts | 83 - .../dom/nodes/attributes-namednodemap.html.ts | 121 - .../src/wpt/dom/nodes/attributes.html.ts | 1176 ------ .../src/wpt/dom/nodes/attributes.js.ts | 41 - .../src/wpt/dom/nodes/mutationobservers.js.ts | 67 - .../src/wpt/dom/nodes/productions.js.ts | 17 - .../dom/nodes/querySelector-empty-id.html.ts | 45 - .../nodes/querySelector-id-nth-child.html.ts | 52 - .../nodes/querySelector-mixed-case.html.ts | 514 --- .../src/wpt/dom/nodes/selectors.js.ts | 3663 ----------------- .../nodes/svg-template-querySelector.html.ts | 43 - .../dom/ranges/Range-attribute-nodes.html.ts | 332 -- .../wpt/dom/ranges/Range-attributes.html.ts | 20 - .../Range-cloneContents-in-ShadowRoot.html.ts | 122 - .../dom/ranges/Range-cloneContents.html.ts | 542 --- .../dom/ranges/Range-comparePoint-2.html.ts | 30 - .../wpt/dom/ranges/Range-constructor.html.ts | 15 - ...Range-deleteContents-in-ShadowRoot.html.ts | 115 - .../dom/ranges/Range-deleteContents.html.ts | 402 -- ...ange-extractContents-in-ShadowRoot.html.ts | 148 - .../dom/ranges/Range-extractContents.html.ts | 323 -- .../wpt/dom/ranges/Range-insertNode.html.ts | 352 -- .../dom/ranges/Range-intersectsNode-2.html.ts | 44 - .../ranges/Range-mutations-normalize.html.ts | 107 - .../wpt/dom/ranges/Range-stringifier.html.ts | 105 - .../dom/ranges/Range-surroundContents.html.ts | 401 -- .../wpt/dom/ranges/Range-test-iframe.html.ts | 122 - .../traversal/NodeIterator-removal.html.ts | 424 -- .../wpt/dom/traversal/NodeIterator.html.ts | 591 --- .../TreeWalker-acceptNode-filter.html.ts | 451 -- .../dom/traversal/TreeWalker-basic.html.ts | 153 - .../TreeWalker-traversal-reject.html.ts | 310 -- .../TreeWalker-traversal-skip.html.ts | 312 -- .../dom/traversal/support/assert-node.js.ts | 20 - ...omment-serialization-double-hyphen.html.ts | 24 - .../DOMParser-parseFromString-html.html.ts | 138 - ...er-parseFromString-xml-parsererror.html.ts | 76 - .../DOMParser-parseFromString-xml.html.ts | 144 - .../XMLSerializer-serializeToString.html.ts | 487 --- .../createContextualFragment.html.ts | 255 -- .../src/wpt/domparsing/innerhtml-04.html.ts | 22 - .../src/wpt/domparsing/innerhtml-07.html.ts | 48 - .../src/wpt/domparsing/innerhtml-08.html.ts | 27 - .../innerhtml-li-autoclosing.html.ts | 60 - .../insert-adjacent-parent-errors.html.ts | 163 - .../wpt/domparsing/insert-adjacent.html.ts | 34 - .../src/wpt/domparsing/outerhtml-01.html.ts | 36 - .../src/wpt/domparsing/svg-template.html.ts | 28 - .../src/wpt/html/dom/elements-misc.js.ts | 73 - .../global-attributes/dataset-delete.html.ts | 78 - .../global-attributes/dataset-get.html.ts | 81 - .../global-attributes/dataset-set.html.ts | 91 - .../src/wpt/html/dom/original-harness.js.ts | 123 - .../src/wpt/html/dom/reflection-misc.html.ts | 106 - .../src/wpt/html/dom/reflection.js.ts | 436 -- .../focus/focus-management/focus-blur.html.ts | 37 - .../focus-on-all-elements.html.ts | 19 - .../focused-area-removal.html.ts | 39 - .../focusing-disconnected-noop.html.ts | 27 - .../focusing-focused-noop.html.ts | 72 - .../the-hidden-attribute/hidden-idl.html.ts | 56 - .../focus-management/focus-events.html.ts | 59 - .../focus-tabindex-order.html.ts | 77 - .../focus/tabindex-focus-flag.html.ts | 175 - .../src/wpt/html/resources/common.js.ts | 134 - .../form-validation-validate.html.ts | 426 -- ...ion-validity-textarea-defaultValue.html.ts | 176 - .../constraints/radio-valueMissing.html.ts | 108 - .../form_attribute.html.ts | 1576 ------- .../constructing-form-data-set.html.ts | 122 - .../implicit-submission.optional.html.ts | 86 - .../resetting-a-form/reset-form-2.html.ts | 55 - .../forms/resetting-a-form/reset-form.html.ts | 219 - .../defaultSelection.html.ts | 86 - .../textfieldselection/selection.html.ts | 298 -- .../textfieldselection-setRangeText.html.ts | 534 --- .../button-click-submits.html.ts | 292 -- ...-enumerated-ascii-case-insensitive.html.ts | 52 - .../the-button-element/button-type.html.ts | 41 - .../datalistoptions.html.ts | 57 - .../HTMLFieldSetElement.html.ts | 104 - .../the-fieldset-element/disabled-001.html.ts | 151 - .../form-elements-filter.html.ts | 212 - .../form-elements-form-owner.html.ts | 39 - .../form-elements-matches.html.ts | 53 - .../form-elements-nameditem-02.html.ts | 41 - .../form-elements-sameobject.html.ts | 22 - .../form-indexed-element.html.ts | 63 - .../the-form-element/form-nameditem.html.ts | 519 --- .../form-requestsubmit.html.ts | 237 -- .../checkbox-click-events.html.ts | 113 - .../the-input-element/cloning-steps.html.ts | 87 - .../forms/the-input-element/color.html.ts | 82 - .../forms/the-input-element/email.html.ts | 113 - .../input-checkvalidity.html.ts | 48 - .../input-setcustomvalidity.html.ts | 21 - .../input-validationmessage.html.ts | 48 - .../the-input-element/input-validity.html.ts | 48 - .../input-value-dirty-flag.html.ts | 109 - .../input-valueasdate-stepping.html.ts | 111 - .../input-valueasdate.html.ts | 121 - .../input-valueasnumber-stepping.html.ts | 121 - .../input-valueasnumber.html.ts | 171 - .../input-willvalidate.html.ts | 48 - .../forms/the-input-element/number.html.ts | 59 - .../radio-click-events.html.ts | 115 - .../radio-disconnected-group-owner.html.ts | 281 -- .../forms/the-input-element/text.html.ts | 148 - .../forms/the-input-element/url.html.ts | 86 - .../labelable-elements.html.ts | 250 -- .../labels-live-attribute-changes.html.ts | 44 - .../proxy-click-to-associated-element.html.ts | 78 - .../the-legend-element/legend-form.html.ts | 38 - .../forms/the-meter-element/meter.html.ts | 553 --- .../optgroup-removal.window.js.ts | 12 - .../the-option-element/option-label.html.ts | 77 - .../option-selected.html.ts | 38 - .../option-text-setter.html.ts | 46 - .../option-text-spaces.html.ts | 79 - .../the-option-element/option-value.html.ts | 77 - .../the-output-element/mutations.window.js.ts | 65 - .../forms/the-output-element/output.html.ts | 48 - .../the-progress-element/progress.html.ts | 118 - ...on-HTMLOptionsCollection-namedItem.html.ts | 89 - .../common-HTMLOptionsCollection.html.ts | 170 - .../selectedcontent.html.ts | 394 -- .../the-select-element/select-add.html.ts | 55 - .../select-named-getter.html.ts | 79 - .../the-select-element/select-remove.html.ts | 73 - .../select-selectedOptions.html.ts | 222 - .../select-validity.html.ts | 182 - .../the-select-element/select-value.html.ts | 77 - .../the-select-element/selected-index.html.ts | 221 - .../cloning-steps.html.ts | 25 - .../textarea-setcustomvalidity.html.ts | 20 - .../textarea-validity-clone.html.ts | 22 - .../value-defaultValue-textContent.html.ts | 205 - .../name-attribute.html.ts | 218 - .../the-details-element/toggleEvent.html.ts | 257 -- .../the-dialog-element/dialog-close.html.ts | 186 - ...dialog-focusing-steps-disconnected.html.ts | 53 - .../dialog-form-submission.html.ts | 221 - .../the-dialog-element/dialog-open-2.html.ts | 30 - .../the-dialog-element/dialog-open.html.ts | 76 - .../dialog-requestclose.html.ts | 297 -- .../dialog-return-value.html.ts | 59 - .../dialog-showModal.html.ts | 455 -- .../resources/submit.jpg.ts | 3 - .../activation-behavior.html.ts | 170 - .../template-clone-children.html.ts | 89 - .../definitions/template-contents.html.ts | 139 - .../innerhtml-on-templates/innerhtml.html.ts | 100 - .../selectors/pseudo-classes/checked.html.ts | 119 - .../selectors/pseudo-classes/disabled.html.ts | 327 -- .../pseudo-classes/valid-invalid.html.ts | 597 --- .../processing-instructions.html.ts | 27 - .../serializing.html.ts | 336 -- ...t-does-not-match-disabled-selector.html.ts | 40 - .../src/wpt/inert/inert-in-shadow-dom.html.ts | 62 - .../inert/inert-node-is-unfocusable.html.ts | 255 -- .../inert/nested-inert-unfocusable.html.ts | 62 - ...ey-on-number-input-prevent-default.html.ts | 43 - ...t-events-arrow-key-on-number-input.html.ts | 42 - .../input-events/input-events-typing.html.ts | 688 ---- .../src/wpt/resources/testharness.js.ts | 27 - .../wpt/selection/collapseToStartEnd.html.ts | 177 - .../src/wpt/selection/common.js.ts | 219 - .../document-selectionchange.html.ts | 177 - .../src/wpt/selection/getRangeAt.html.ts | 64 - ...ange-into-different-root.tentative.html.ts | 111 - .../src/wpt/selection/removeRange.html.ts | 72 - ...on-range-after-editinghost-removed.html.ts | 116 - .../wpt/selection/setBaseAndExtent.html.ts | 201 - .../Document-prototype-adoptNode.html.ts | 45 - .../Element-interface-attachShadow.html.ts | 394 -- ...ent-interface-shadowRoot-attribute.html.ts | 113 - .../HTMLSlotElement-interface.html.ts | 976 ----- .../Node-prototype-cloneNode.html.ts | 107 - .../shadow-dom/ShadowRoot-interface.html.ts | 55 - .../wpt/shadow-dom/Slottable-mixin.html.ts | 184 - .../attach-shadow-non-html-namespace.html.ts | 117 - .../declarative-shadow-dom-basic.html.ts | 610 --- .../shadow-dom/declarative/gethtml.html.ts | 197 - .../shadow-dom/event-composed-path.html.ts | 384 -- .../event-inside-shadow-tree.html.ts | 380 -- .../event-with-related-target.html.ts | 355 -- ...ion-slot-fallback-default-tabindex.html.ts | 217 - .../focus/ShadowRoot-delegatesFocus.html.ts | 50 - .../click-focus-delegatesFocus-click.html.ts | 233 -- .../focus-method-with-delegatesFocus.html.ts | 388 -- .../focus/resources/shadow-utils.js.ts | 15 - .../shadow-dom/imperative-slot-api.html.ts | 1049 ----- .../wpt/shadow-dom/resources/shadow-dom.js.ts | 59 - .../shadow-dom/shadow-root-clonable.html.ts | 147 - .../wpt/shadow-dom/slotchange-event.html.ts | 803 ---- .../src/wpt/shadow-dom/slotchange.html.ts | 860 ---- .../src/wpt/shadow-dom/slots-fallback.html.ts | 952 ----- .../event-getmodifierstate.html.ts | 156 - .../inputevent-constructor.html.ts | 32 - .../focusevents/blur-relatedTarget.html.ts | 118 - .../interface/keyboard-click-event.html.ts | 60 - .../keyboard/keyboardevent-composed.html.ts | 41 - .../keyboard/keydown-input-events.html.ts | 84 - .../modifier-keys-combinations.html.ts | 49 - .../uievents/keyboard/modifier-keys.html.ts | 44 - .../src/wpt/uievents/mouse/attributes.html.ts | 64 - .../mouse/mouseevent_move_button.html.ts | 136 - .../focus-automated-blink-webkit.html.ts | 471 --- .../focus-events/focus-contained.html.ts | 90 - .../mouse-events/click-cancel.html.ts | 55 - .../mouse-events/click-on-div.html.ts | 71 - .../mouse-events/mouseover-out.html.ts | 188 - .../formdata/constructor-formelement.html.ts | 166 - .../formdata/constructor-submitter.html.ts | 202 - .../test/browser/compatibility-types.mts | 17 - .../test/browser/compatibility.html | 8 - .../test/browser/compatibility.mjs | 281 -- .../test/browser/input-driver.mts | 65 - .../test/browser/run-compatibility.mjs | 162 - .../test/browser/tsconfig.json | 16 - .../test/browser/vite.config.mjs | 15 - .../test/browser/wpt.config.ts | 150 - .../test/compatibility-harness.test.ts | 868 ---- .../test/frameworks.test.ts | 77 - packages/web-platform-tests/test/wpt/LICENSE | 11 - .../web-platform-tests/test/wpt/README.md | 10 - packages/web-platform-tests/tsconfig.json | 6 +- pnpm-lock.yaml | 52 +- 447 files changed, 390 insertions(+), 75873 deletions(-) delete mode 100644 .changeset/wpt-framework-profiles.md delete mode 100644 packages/ui/src/dom.compatibility.test.ts delete mode 100644 packages/ui/test/wpt.config.ts delete mode 100644 packages/web-platform-tests/docs/omissions.md delete mode 100644 packages/web-platform-tests/scripts/check-wpt-selectors.mjs delete mode 100644 packages/web-platform-tests/scripts/generate-registry.mjs delete mode 100644 packages/web-platform-tests/src/frameworks/features.ts delete mode 100644 packages/web-platform-tests/src/frameworks/frameworks.ts delete mode 100644 packages/web-platform-tests/src/shared/context.ts delete mode 100644 packages/web-platform-tests/src/shared/fixture.ts delete mode 100644 packages/web-platform-tests/src/shared/globals.ts delete mode 100644 packages/web-platform-tests/src/shared/input-driver.ts delete mode 100644 packages/web-platform-tests/src/shared/registry.ts delete mode 100644 packages/web-platform-tests/src/shared/restore-scripts.ts delete mode 100644 packages/web-platform-tests/src/shared/selection.ts delete mode 100644 packages/web-platform-tests/src/shared/selectors.ts delete mode 100644 packages/web-platform-tests/src/shared/test-dom-compatibility.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-cascade/inherit-initial.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-cascade/layer-basic.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-cascade/layer-important.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-cascade/layer-vs-inline-style.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-cascade/unset-value-storage.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-variables/variable-cycles.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-cssom.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-shorthands-cssom.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/CSSStyleDeclaration-indexed-properties.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-invalidation.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-replace-cssRules.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/MutationObserver-style.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/computed-style-001.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/computed-style-set-property.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/css-style-attr-decl-block.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/css-style-attribute-modifications.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/cssom/cssom-setProperty-shorthand.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-visible-001.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-visible-002.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-visible-003.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-within-focus-move.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-within-removal.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/focus-within.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/has-basic.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/invalidation/input-pseudo-classes-in-has.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/invalidation/user-action-pseudo-classes-in-has.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/css/selectors/is-where-basic.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/CustomElementRegistry.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/HTMLElement-constructor.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/adopted-callback.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/attribute-changed-callback.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/connected-callbacks.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/createElement-reentrant-construction.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/cross-realm-callback-report-exception.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/custom-element-reaction-queue.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/disconnected-callbacks.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/form-associated/ElementInternals-form.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/resources/custom-elements-helpers.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/custom-elements/upgrading.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/common.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/AddEventListenerOptions-once.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/AddEventListenerOptions-passive.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/AddEventListenerOptions-signal.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-constructors.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-defaultPrevented-after-dispatch.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-bubbles-false.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-bubbles-true.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-handlers-changed.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-multiple-cancelBubble.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-multiple-stopPropagation.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-propagation-stopped.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-reenter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-target-moved.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-dispatch-throwing.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/Event-stopImmediatePropagation.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventListener-handleEvent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventListenerOptions-capture.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-add-remove-listener.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-addEventListener.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-dispatchEvent-returnvalue.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-dispatchEvent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-removeEventListener.any.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/EventTarget-this-of-listener.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/events/remove-all-listeners.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/lists/DOMTokenList-coverage-for-attributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-appendData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-data.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-deleteData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-insertData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-remove.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-replaceData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/CharacterData-substringData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ChildNode-remove.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/DOMImplementation-createDocument.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/DOMImplementation-createHTMLDocument.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-adoptNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createAttribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createComment.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createElement.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createElementNS.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createElementNS.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-createTextNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-getElementById.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Document-importNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/DocumentFragment-constructor.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/DocumentFragment-querySelectorAll-after-modification.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-classlist.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-closest-null-selectors.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-closest.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-hasAttribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-hasAttributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches-active-pseudo-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches-complex-nth-last-of-type.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches-disabled-pseudo-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches-namespaced-elements.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-matches.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-querySelectorAll-context-element.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-remove.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-removeAttribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-removeAttributeNS.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-setAttribute-crbug-1138487.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-setAttribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Element-setAttributeNodeNS.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-attributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-callback-order.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-callback-tricky.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-characterData.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-childList.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-overlapping-registrations.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-sanity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-takeRecords.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/MutationObserver-transient-registered-observers.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-childNodes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-cloneNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-compareDocumentPosition.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-contains.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-insertBefore.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-isConnected-shadow-dom.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-isConnected.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-isEqualNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-isSameNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-mutation-adoptNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-nodeValue.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-normalize.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-parentElement.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-parentNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-removeChild.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-replaceChild.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Node-textContent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-append.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-children.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-prepend.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-comma-selector.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-content.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-content.xht.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-multiple-not.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-scope.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All-xht.xht.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-All.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-argument-stringification.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-attribute-change.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-basic-has.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-case-insensitive.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-class-change.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-dupe-id.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-empty-attribute-value.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-escapes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-host-pseudo-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-hyphen-prefix.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-innerHTML.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-invalid-comment-like.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-is-nested-pseudo-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-is-not.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-last-child-combinator.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-matches.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-multiple-attributes-xml.xhtml.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-namespace-tagname-attribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-nested-nth-child.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-nested.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-nth-of-type-complex.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-orphan-scope.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-parent-context.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-scope-in-not.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-scope-numeric-id.xhtml.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-scope.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-shadowroot-nth-child.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-svg-not-root.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-tag-case.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-underscore-local-name.xhtml.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelector-xml-capitalization.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-case-insensitive-attribute-flag.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-namespace.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-nested-not-has.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-not-descendant.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-removed-elements.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-scope-change.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-scope-colon-id-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-svg-append.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectorAll-svg-class.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectors-exclusive.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectors-namespaces.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/ParentNode-querySelectors-space-and-dash-attribute-value.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/Text-splitText.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/append-on-Document.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/attributes-namednodemap.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/attributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/attributes.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/mutationobservers.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/productions.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/querySelector-empty-id.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/querySelector-id-nth-child.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/querySelector-mixed-case.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/selectors.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/nodes/svg-template-querySelector.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-attribute-nodes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-attributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-cloneContents-in-ShadowRoot.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-cloneContents.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-comparePoint-2.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-constructor.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-deleteContents-in-ShadowRoot.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-deleteContents.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-extractContents-in-ShadowRoot.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-extractContents.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-insertNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-intersectsNode-2.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-mutations-normalize.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-stringifier.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-surroundContents.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/ranges/Range-test-iframe.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/NodeIterator-removal.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/NodeIterator.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/TreeWalker-acceptNode-filter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/TreeWalker-basic.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/TreeWalker-traversal-reject.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/TreeWalker-traversal-skip.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/dom/traversal/support/assert-node.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/Comment-serialization-double-hyphen.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/DOMParser-parseFromString-html.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/DOMParser-parseFromString-xml-parsererror.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/DOMParser-parseFromString-xml.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/XMLSerializer-serializeToString.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/createContextualFragment.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/innerhtml-04.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/innerhtml-07.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/innerhtml-08.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/innerhtml-li-autoclosing.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/insert-adjacent-parent-errors.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/insert-adjacent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/outerhtml-01.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/domparsing/svg-template.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/elements-misc.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/elements/global-attributes/dataset-delete.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/elements/global-attributes/dataset-get.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/elements/global-attributes/dataset-set.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/original-harness.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/reflection-misc.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/dom/reflection.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/focus/focus-management/focus-blur.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/focus/focus-management/focus-on-all-elements.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/focus/focus-management/focused-area-removal.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/focus/focus-management/focusing-disconnected-noop.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/focus/focus-management/focusing-focused-noop.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/editing/the-hidden-attribute/hidden-idl.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/interaction/focus/focus-management/focus-events.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/interaction/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-order.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/interaction/focus/tabindex-focus-flag.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/resources/common.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/constraints/form-validation-validate.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/constraints/form-validation-validity-textarea-defaultValue.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/constraints/radio-valueMissing.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/form-control-infrastructure/form_attribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/form-submission-0/constructing-form-data-set.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/form-submission-0/implicit-submission.optional.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/resetting-a-form/reset-form-2.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/resetting-a-form/reset-form.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/textfieldselection/defaultSelection.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/textfieldselection/selection.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/textfieldselection/textfieldselection-setRangeText.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-button-element/button-click-submits.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-button-element/button-type-enumerated-ascii-case-insensitive.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-button-element/button-type.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-datalist-element/datalistoptions.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-fieldset-element/HTMLFieldSetElement.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-fieldset-element/disabled-001.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-elements-filter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-elements-form-owner.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-elements-matches.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-elements-nameditem-02.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-elements-sameobject.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-indexed-element.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-nameditem.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-form-element/form-requestsubmit.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/checkbox-click-events.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/cloning-steps.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/color.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/email.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-checkvalidity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-setcustomvalidity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-validationmessage.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-validity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-value-dirty-flag.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-valueasdate-stepping.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-valueasdate.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-valueasnumber-stepping.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-valueasnumber.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/input-willvalidate.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/number.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/radio-click-events.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/radio-disconnected-group-owner.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/text.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-input-element/url.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-label-element/labelable-elements.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-label-element/labels-live-attribute-changes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-label-element/proxy-click-to-associated-element.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-legend-element/legend-form.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-meter-element/meter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-optgroup-element/optgroup-removal.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-option-element/option-label.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-option-element/option-selected.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-option-element/option-text-setter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-option-element/option-text-spaces.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-option-element/option-value.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-output-element/mutations.window.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-output-element/output.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-progress-element/progress.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/customizable-select/selectedcontent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-add.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-named-getter.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-remove.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-selectedOptions.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-validity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/select-value.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-select-element/selected-index.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-textarea-element/cloning-steps.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-textarea-element/textarea-setcustomvalidity.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-textarea-element/textarea-validity-clone.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-details-element/name-attribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-close.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-disconnected.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-form-submission.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-open-2.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-open.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-requestclose.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-return-value.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-dialog-element/resources/submit.jpg.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/interactive-elements/the-summary-element/activation-behavior.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/scripting-1/the-template-element/additions-to-the-steps-to-clone-a-node/template-clone-children.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/scripting-1/the-template-element/definitions/template-contents.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/scripting-1/the-template-element/innerhtml-on-templates/innerhtml.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/selectors/pseudo-classes/checked.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/selectors/pseudo-classes/disabled.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/semantics/selectors/pseudo-classes/valid-invalid.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/syntax/serializing-html-fragments/processing-instructions.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/html/syntax/serializing-html-fragments/serializing.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/inert/inert-does-not-match-disabled-selector.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/inert/inert-in-shadow-dom.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/inert/inert-node-is-unfocusable.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/inert/nested-inert-unfocusable.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/input-events/input-events-arrow-key-on-number-input-prevent-default.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/input-events/input-events-arrow-key-on-number-input.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/input-events/input-events-typing.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/resources/testharness.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/collapseToStartEnd.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/common.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/document-selectionchange.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/getRangeAt.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/move-selection-range-into-different-root.tentative.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/removeRange.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/selection-range-after-editinghost-removed.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/selection/setBaseAndExtent.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/Document-prototype-adoptNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/Element-interface-attachShadow.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/Element-interface-shadowRoot-attribute.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/HTMLSlotElement-interface.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/Node-prototype-cloneNode.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/ShadowRoot-interface.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/Slottable-mixin.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/attach-shadow-non-html-namespace.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/declarative/declarative-shadow-dom-basic.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/declarative/gethtml.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/event-composed-path.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/event-inside-shadow-tree.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/event-with-related-target.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/focus-navigation/focus-navigation-slot-fallback-default-tabindex.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/focus/ShadowRoot-delegatesFocus.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/focus/click-focus-delegatesFocus-click.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/focus/focus-method-with-delegatesFocus.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/focus/resources/shadow-utils.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/imperative-slot-api.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/resources/shadow-dom.js.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/shadow-root-clonable.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/slotchange-event.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/slotchange.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/shadow-dom/slots-fallback.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/constructors/event-getmodifierstate.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/constructors/inputevent-constructor.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/focusevents/blur-relatedTarget.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/interface/keyboard-click-event.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/keyboard/keyboardevent-composed.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/keyboard/keydown-input-events.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/keyboard/modifier-keys-combinations.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/keyboard/modifier-keys.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/mouse/attributes.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/mouse/mouseevent_move_button.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/order-of-events/focus-events/focus-automated-blink-webkit.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/order-of-events/focus-events/focus-contained.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/order-of-events/mouse-events/click-cancel.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/order-of-events/mouse-events/click-on-div.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/uievents/order-of-events/mouse-events/mouseover-out.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/xhr/formdata/constructor-formelement.html.ts delete mode 100644 packages/web-platform-tests/src/wpt/xhr/formdata/constructor-submitter.html.ts delete mode 100644 packages/web-platform-tests/test/browser/compatibility-types.mts delete mode 100644 packages/web-platform-tests/test/browser/compatibility.html delete mode 100644 packages/web-platform-tests/test/browser/compatibility.mjs delete mode 100644 packages/web-platform-tests/test/browser/input-driver.mts delete mode 100644 packages/web-platform-tests/test/browser/run-compatibility.mjs delete mode 100644 packages/web-platform-tests/test/browser/tsconfig.json delete mode 100644 packages/web-platform-tests/test/browser/vite.config.mjs delete mode 100644 packages/web-platform-tests/test/browser/wpt.config.ts delete mode 100644 packages/web-platform-tests/test/compatibility-harness.test.ts delete mode 100644 packages/web-platform-tests/test/frameworks.test.ts delete mode 100644 packages/web-platform-tests/test/wpt/LICENSE delete mode 100644 packages/web-platform-tests/test/wpt/README.md diff --git a/.changeset/wpt-framework-profiles.md b/.changeset/wpt-framework-profiles.md deleted file mode 100644 index d486bbb..0000000 --- a/.changeset/wpt-framework-profiles.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@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. diff --git a/.changeset/wpt-suite-fidelity.md b/.changeset/wpt-suite-fidelity.md index a4b4356..a79a75f 100644 --- a/.changeset/wpt-suite-fidelity.md +++ b/.changeset/wpt-suite-fidelity.md @@ -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, framework profiles, and browser adaptation tooling. diff --git a/.eslintignore b/.eslintignore index aa1b2c2..0d8a923 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +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/** diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 04f3145..cacedc6 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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 @@ -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 diff --git a/oxlint.config.ts b/oxlint.config.ts index a3d2bca..913ce4b 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -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', diff --git a/package.json b/package.json index d364764..51ed10b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/ui/package.json b/packages/ui/package.json index af75cf0..dc2e2f0 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -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:", diff --git a/packages/ui/src/dom.compatibility.test.ts b/packages/ui/src/dom.compatibility.test.ts deleted file mode 100644 index c97e887..0000000 --- a/packages/ui/src/dom.compatibility.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { testDOMCompatibility } from '@bomb.sh/web-platform-tests'; -import { createHTMLDocument } from './dom.ts'; -import config from '../test/wpt.config.ts'; - -testDOMCompatibility({ - runner: { describe, it, expect }, - config, - create: () => createHTMLDocument(() => {}), -}); diff --git a/packages/ui/test/README.md b/packages/ui/test/README.md index 2e0750d..7566250 100644 --- a/packages/ui/test/README.md +++ b/packages/ui/test/README.md @@ -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. diff --git a/packages/ui/test/wpt.config.ts b/packages/ui/test/wpt.config.ts deleted file mode 100644 index 51fe144..0000000 --- a/packages/ui/test/wpt.config.ts +++ /dev/null @@ -1,206 +0,0 @@ -import type { WPTConfig } from '@bomb.sh/web-platform-tests'; -import { - Attr, - CharacterData, - Comment, - Document, - DocumentType, - Element, - HTMLBodyElement, - HTMLElement, - HTMLHeadElement, - HTMLHtmlElement, - HTMLSpanElement, - HTMLTitleElement, - HTMLUnknownElement, - Node, - Text, - XMLDocument, -} from '../src/dom.ts'; -import { NamedNodeMap } from '../src/named-node-map.ts'; - -const config: WPTConfig = { - globals: { - AbortController: globalThis.AbortController, - Attr, - CharacterData, - Comment, - CustomEvent: globalThis.CustomEvent, - Document, - DocumentType, - DOMException: globalThis.DOMException, - Element, - Event: globalThis.Event, - EventTarget: globalThis.EventTarget, - HTMLBodyElement, - HTMLElement, - HTMLHeadElement, - HTMLHtmlElement, - HTMLSpanElement, - HTMLTitleElement, - HTMLUnknownElement, - NamedNodeMap, - Node, - Text, - TypeError: globalThis.TypeError, - XMLDocument, - }, - include: { - 'dom/events/Event-constructors.any.js': true, - 'dom/events/EventTarget-addEventListener.any.js': true, - 'dom/events/EventTarget-add-remove-listener.any.js': true, - 'dom/events/AddEventListenerOptions-once.any.js': true, - 'dom/events/AddEventListenerOptions-signal.any.js': true, - 'dom/events/AddEventListenerOptions-passive.any.js': true, - 'dom/events/remove-all-listeners.html': true, - 'dom/events/EventListener-handleEvent.html': [ - 'calls `handleEvent` method of `EventListener`', - "doesn't call `handleEvent` method on callable `EventListener`", - // Native EventTarget reads handleEvent at registration; the getter-timing - // 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-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 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)', - 'Missing title argument', - ], - // XML cases also require createAttribute() to preserve name casing. - 'dom/nodes/Document-createAttribute.html': [/^HTML document\.createAttribute\(/], - 'dom/nodes/CharacterData-data.html': true, - 'dom/nodes/CharacterData-remove.html': true, - 'dom/nodes/Element-remove.html': true, - 'dom/nodes/Element-setAttribute.html': true, - 'dom/nodes/Element-setAttributeNodeNS.html': true, - 'dom/nodes/Element-removeAttribute.html': true, - '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', - 'Basic functionality of setAttributeNode', - 'setAttributeNode should distinguish attributes with same local name and different namespaces', - "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 1", - "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 2", - "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 3", - 'Basic functionality of setAttributeNodeNS', - 'If attr’s element is neither null nor element, throw an InUseAttributeError.', - 'Replacing an attr by itself', - 'Basic functionality of removeAttributeNode', - 'setAttributeNode on bound attribute should throw InUseAttributeError', - 'setAttributeNode called with an Attr that has the same name as an existing one should not change attribute order', - 'Own property correctness with basic attributes', - 'Own property correctness with non-namespaced attribute before same-name namespaced one', - 'Own property correctness with namespaced attribute before same-name non-namespaced one', - 'Own property correctness with two namespaced attributes with the same name-with-prefix', - 'Own property names should only include all-lowercase qualified names for an HTML element in an HTML document', - 'Own property names should include all qualified names for a non-HTML element in an HTML document', - 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (toggleAttribute)', - 'toggleAttribute should lowercase its name argument (upper case attribute)', - 'toggleAttribute should lowercase its name argument (mixed case attribute)', - "toggleAttribute should not throw even when qualifiedName starts with 'xmlns'", - 'Basic functionality should be intact. (toggleAttribute)', - 'toggleAttribute should not change the order of previously set attributes.', - 'toggleAttribute should set the first attribute with the given name', - 'toggleAttribute should set the attribute with the given qualified name', - 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (setAttribute)', - 'setAttribute should lowercase its name argument (upper case attribute)', - 'setAttribute should lowercase its name argument (mixed case attribute)', - "setAttribute should not throw even when qualifiedName starts with 'xmlns'", - 'Basic functionality should be intact.', - 'setAttribute should not change the order of previously set attributes.', - 'setAttribute should set the first attribute with the given name', - 'setAttribute should set the attribute with the given qualified name', - 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (setAttributeNS)', - 'When qualifiedName does not match the QName production, an INVALID_CHARACTER_ERR exception is to be thrown.', - 'null and the empty string should result in a null namespace.', - 'A namespace is required to use a prefix.', - 'The xml prefix should not be allowed for arbitrary namespaces', - "XML-namespaced attributes don't need an xml prefix", - 'The xmlns prefix should not be allowed for arbitrary namespaces', - 'The xmlns qualified name should not be allowed for arbitrary namespaces', - 'xmlns should be allowed as local name', - 'The XMLNS namespace should require xmlns as prefix or qualified name', - 'xmlns should be allowed as prefix in the XMLNS namespace', - 'xmlns should be allowed as qualified name in the XMLNS namespace', - 'Setting the same attribute with another prefix should not change the prefix', - 'setAttribute should not throw even if a load is not allowed', - 'Attribute values should not be parsed.', - 'Unset attributes return null', - 'First set attribute is returned by getAttribute', - 'Style attributes are not normalized', - 'Only lowercase attributes are returned on HTML elements (upper case attribute)', - 'Only lowercase attributes are returned on HTML elements (mixed case attribute)', - 'First set attribute is returned with mapped attribute set later', - 'Non-HTML element with upper-case attribute', - 'Attribute with prefix in local name', - 'getAttributeNames tests', - ], - 'dom/nodes/Node-nodeValue.html': ['Text.nodeValue', 'Comment.nodeValue'], - 'dom/nodes/Node-textContent.html': [ - 'For an empty Text, textContent should be the empty string', - 'For an empty Comment, textContent should be the empty string', - 'For a Text with data, textContent should be that data', - 'For a Comment with data, textContent should be that data', - 'For a Text, textContent should set the data', - 'For a Comment, textContent should set the data', - 'For DocumentType created by script, textContent should be null', - 'For DocumentType created by script, setting textContent should do nothing', - ], - 'dom/nodes/Node-parentNode.html': ['Document', 'Root element'], - 'dom/nodes/Node-parentElement.html': [ - 'When the parent is null, parentElement should be null', - 'When the parent is a document, parentElement should be null (element)', - 'When the parent is a document, parentElement should be null (comment)', - 'parentElement should work correctly in disconnected subtrees (element)', - 'parentElement should work correctly in disconnected subtrees (text)', - ], - 'dom/nodes/Node-insertBefore.html': [ - 'Calling insertBefore with a reference child whose parent is not the context node must throw a NotFoundError.', - '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, - }, -}; - -export default config; diff --git a/packages/ui/wpt.config.ts b/packages/ui/wpt.config.ts index bd96ee5..6503583 100644 --- a/packages/ui/wpt.config.ts +++ b/packages/ui/wpt.config.ts @@ -1,13 +1,68 @@ import type { WPTConfig } from '@bomb.sh/web-platform-tests/config'; -import { createHTMLDocument } from './src/dom.ts'; -import adapted from './test/wpt.config.ts'; +import { + createHTMLDocument, + Attr, + CharacterData, + Comment, + Document, + DocumentType, + Element, + HTMLBodyElement, + HTMLElement, + HTMLHeadElement, + HTMLHtmlElement, + HTMLSpanElement, + HTMLTitleElement, + HTMLUnknownElement, + Node, + Text, + XMLDocument, +} from './src/dom.ts'; +import { NamedNodeMap } from './src/named-node-map.ts'; -/** Initial raw-source checkpoint; the adapted suite remains the coverage baseline. */ const config: WPTConfig = { createDocument: () => createHTMLDocument(() => {}), - globals: { ...adapted.globals }, + globals: { + AbortController: globalThis.AbortController, + Attr, + CharacterData, + Comment, + CustomEvent: globalThis.CustomEvent, + Document, + DocumentType, + DOMException: globalThis.DOMException, + Element, + Event: globalThis.Event, + EventTarget: globalThis.EventTarget, + HTMLBodyElement, + HTMLElement, + HTMLHeadElement, + HTMLHtmlElement, + HTMLSpanElement, + HTMLTitleElement, + HTMLUnknownElement, + NamedNodeMap, + Node, + Text, + TypeError: globalThis.TypeError, + XMLDocument, + }, include: { - 'dom/nodes/Node-parentNode.html': ['Document', 'Root element'], + 'dom/events/Event-constructors.any.js': true, + 'dom/events/EventTarget-addEventListener.any.js': true, + 'dom/events/EventTarget-add-remove-listener.any.js': true, + 'dom/events/AddEventListenerOptions-once.any.js': true, + 'dom/events/AddEventListenerOptions-signal.any.js': true, + 'dom/events/AddEventListenerOptions-passive.any.js': true, + 'dom/events/remove-all-listeners.html': true, + 'dom/events/EventListener-handleEvent.html': [ + 'calls `handleEvent` method of `EventListener`', + "doesn't call `handleEvent` method on callable `EventListener`", + // Native EventTarget reads handleEvent at registration; the getter-timing + // case remains excluded until that behavior is implemented. + ], + 'dom/nodes/Document-createTextNode.html': true, + 'dom/nodes/Document-createElement.html': [/^createElement\(.*\) in HTML document$/], 'dom/nodes/Document-createElementNS.html': [ /^createElementNS test in HTML document:/, /^(Lower|Upper)-case /, @@ -15,6 +70,121 @@ const config: WPTConfig = { 'undefined namespace', 'empty string namespace', ], + 'dom/nodes/Document-createComment.html': true, + 'dom/nodes/DOMImplementation-createDocument.html': [ + '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 test [0-7]:/, + 'Missing title argument', + ], + // XML cases also require createAttribute() to preserve name casing. + 'dom/nodes/Document-createAttribute.html': [/^HTML document\.createAttribute\(/], + 'dom/nodes/CharacterData-data.html': true, + 'dom/nodes/CharacterData-remove.html': true, + 'dom/nodes/Element-remove.html': true, + 'dom/nodes/Element-setAttribute.html': true, + 'dom/nodes/Element-setAttributeNodeNS.html': true, + 'dom/nodes/Element-removeAttribute.html': true, + 'dom/nodes/Element-removeAttributeNS.html': true, + 'dom/nodes/Element-setAttribute-crbug-1138487.html': true, + 'dom/nodes/Element-hasAttribute.html': [ + 'hasAttribute should check for attribute presence, irrespective of namespace', + ], + 'dom/nodes/attributes-namednodemap.html': true, + 'dom/nodes/attributes.html': [ + 'Attribute loses its owner when removed', + 'Basic functionality of getAttributeNode/getAttributeNodeNS', + 'Basic functionality of setAttributeNode', + 'setAttributeNode should distinguish attributes with same local name and different namespaces', + "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 1", + "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 2", + "setAttributeNode doesn't have case-insensitivity even with an HTMLElement 3", + 'Basic functionality of setAttributeNodeNS', + 'If attr’s element is neither null nor element, throw an InUseAttributeError.', + 'Replacing an attr by itself', + 'Basic functionality of removeAttributeNode', + 'setAttributeNode on bound attribute should throw InUseAttributeError', + 'setAttributeNode called with an Attr that has the same name as an existing one should not change attribute order', + 'Own property correctness with basic attributes', + 'Own property correctness with non-namespaced attribute before same-name namespaced one', + 'Own property correctness with namespaced attribute before same-name non-namespaced one', + 'Own property correctness with two namespaced attributes with the same name-with-prefix', + 'Own property names should only include all-lowercase qualified names for an HTML element in an HTML document', + 'Own property names should include all qualified names for a non-HTML element in an HTML document', + 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (toggleAttribute)', + 'toggleAttribute should lowercase its name argument (upper case attribute)', + 'toggleAttribute should lowercase its name argument (mixed case attribute)', + "toggleAttribute should not throw even when qualifiedName starts with 'xmlns'", + 'Basic functionality should be intact. (toggleAttribute)', + 'toggleAttribute should not change the order of previously set attributes.', + 'toggleAttribute should set the first attribute with the given name', + 'toggleAttribute should set the attribute with the given qualified name', + 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (setAttribute)', + 'setAttribute should lowercase its name argument (upper case attribute)', + 'setAttribute should lowercase its name argument (mixed case attribute)', + "setAttribute should not throw even when qualifiedName starts with 'xmlns'", + 'Basic functionality should be intact.', + 'setAttribute should not change the order of previously set attributes.', + 'setAttribute should set the first attribute with the given name', + 'setAttribute should set the attribute with the given qualified name', + 'When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (setAttributeNS)', + 'When qualifiedName does not match the QName production, an INVALID_CHARACTER_ERR exception is to be thrown.', + 'null and the empty string should result in a null namespace.', + 'A namespace is required to use a prefix.', + 'The xml prefix should not be allowed for arbitrary namespaces', + "XML-namespaced attributes don't need an xml prefix", + 'The xmlns prefix should not be allowed for arbitrary namespaces', + 'The xmlns qualified name should not be allowed for arbitrary namespaces', + 'xmlns should be allowed as local name', + 'The XMLNS namespace should require xmlns as prefix or qualified name', + 'xmlns should be allowed as prefix in the XMLNS namespace', + 'xmlns should be allowed as qualified name in the XMLNS namespace', + 'Setting the same attribute with another prefix should not change the prefix', + 'setAttribute should not throw even if a load is not allowed', + 'Attribute values should not be parsed.', + 'Unset attributes return null', + 'First set attribute is returned by getAttribute', + 'Style attributes are not normalized', + 'Only lowercase attributes are returned on HTML elements (upper case attribute)', + 'Only lowercase attributes are returned on HTML elements (mixed case attribute)', + 'First set attribute is returned with mapped attribute set later', + 'Non-HTML element with upper-case attribute', + 'Attribute with prefix in local name', + 'getAttributeNames tests', + ], + 'dom/nodes/Node-nodeValue.html': ['Text.nodeValue', 'Comment.nodeValue'], + 'dom/nodes/Node-textContent.html': [ + 'For an empty Text, textContent should be the empty string', + 'For an empty Comment, textContent should be the empty string', + 'For a Text with data, textContent should be that data', + 'For a Comment with data, textContent should be that data', + 'For a Text, textContent should set the data', + 'For a Comment, textContent should set the data', + 'For DocumentType created by script, textContent should be null', + 'For DocumentType created by script, setting textContent should do nothing', + ], + 'dom/nodes/Node-parentNode.html': ['Document', 'Root element'], + 'dom/nodes/Node-parentElement.html': [ + 'When the parent is null, parentElement should be null', + 'When the parent is a document, parentElement should be null (element)', + 'When the parent is a document, parentElement should be null (comment)', + 'parentElement should work correctly in disconnected subtrees (element)', + 'parentElement should work correctly in disconnected subtrees (text)', + ], + 'dom/nodes/Node-insertBefore.html': [ + 'Calling insertBefore with a reference child whose parent is not the context node must throw a NotFoundError.', + 'Inserting a node before itself should not move the node', + ], }, exclude: { '**': true }, }; diff --git a/packages/web-platform-tests/AGENTS.md b/packages/web-platform-tests/AGENTS.md index 9c4afa9..c2e181e 100644 --- a/packages/web-platform-tests/AGENTS.md +++ b/packages/web-platform-tests/AGENTS.md @@ -1,71 +1,40 @@ -# WPT provenance and correspondence - -This package is the long-term source of upstream WPT coverage for the UI. - -Every shared DOM conformance case must faithfully reflect an existing, inspected -upstream Web Platform Test. Do not invent cases, add local assertions to upstream -cases, extend their inputs or matrices, or infer new tests from the specification. -Independent subtleties, regressions, and implementation-specific checks belong in -tests outside this package's WPT suite, even when they test standards behavior. -A citation to a related upstream test does not make a local addition a WPT case. - -This requirement applies to all adapted cases, including excluded cases. -Tests of the runner and fixtures are infrastructure tests, separate from WPT cases. - -The suite shares one upstream revision in `WPT_REVISION`. Use that revision -for source review; do not choose a separate revision for each case or file. - -Files under `src/wpt` mirror the exact upstream path, spelling, and capitalization -with `.ts` appended. For example, `src/wpt/dom/nodes/Document-createElement.html.ts` -corresponds to `dom/nodes/Document-createElement.html`. The registry derives source -identity from that convention; do not repeat it in runtime metadata or per-case -annotations. Keep each file's cases together. Upstream helpers and data also use -their natural paths under `src/wpt`. Only test entrypoints export `register`; -support files are imported by those tests. Local harness code belongs in -`src/shared`. Keep setup used by a single source in that source file. - -Keep ordinary `context.test` and `expect` calls with readable case names. Do not -introduce per-case registration wrappers. Destructure document and global bindings -from the typed fixture; their expected types are asserted once at the fixture -boundary. Wrap callback assertions with `fixture.step` so the runner observes -failures. Shared attribution and license information belong in `test/wpt`. - -When adding or migrating a case: - -1. Read the upstream source at the suite revision. Use its path for the adapted - filename and identify any helper/data sources in comments. Run `pnpm generate` - after adding, moving, or removing source files. -2. Preserve the upstream inputs, setup, operation order, assertions, exceptions, - node identities, document ownership, and matrix rows. Separate documents, - detached trees, and retained collections are meaningful test conditions. -3. Limit adaptations to integration with the consumer's runner, fixtures, and - input driver. Comment only on non-obvious adaptations, preserving the - tested behavior without adding or removing behavioral checks. Keep the code - close enough to upstream for a side-by-side review. -4. Record omitted upstream cases and their reasons in [docs/omissions.md](docs/omissions.md). - Selecting a subset of a file does not establish coverage of the entire file. - Do not merge several upstream cases into a smaller example or drop assertions - to accommodate an incomplete implementation. -5. Keep upstream authorship and license notices. A specification URL, a directory - link, or a reference to a merely similar test is insufficient provenance. - Do not claim that an existing local case was derived from WPT - without establishing that correspondence; replace it with a verified - adaptation when necessary. -6. Verify the source mapping and registered cases, review assertion correspondence, - and run browser validation and the affected consumer tests. Matching names or - passing against a browser alone does not establish correspondence. - -Fix missing implementation behavior or explicitly exclude its cases in the consumer configuration. -Never weaken a shared case, change its fixture semantics, or silently omit it -just to make the UI implementation pass. - -Test selection uses upstream source paths and original case names. All adapted -cases run by default; explicit includes override exclusions. Do not gate a case -on another test group's selection or silently omit cases based on API detection. -Supporting DOM behavior is exercised by the selected case itself. Document -creation options, global bindings, and input drivers remain fixture contracts, -checked when the selected case uses them. - -The selector omission check is an existing example of -traceability, not a waiver for other features. The entire suite must meet this -requirement before it can be described as a fully traceable WPT adaptation. +# WPT provenance and execution + +This package runs original upstream Web Platform Tests against consumer DOM +implementations. The sources live in the `wpt` git submodule; its revision must +match `WPT_REVISION`. Read that checkout when reviewing or enabling cases. + +Do not copy, rewrite, or adapt upstream tests into this package. Do not invent +cases, add assertions, change fixtures or input matrices, or infer tests from the +specification. Keep upstream sources, helpers, authorship, and license notices +unchanged. Implementation-specific tests belong with the consumer. + +The CLI transforms each selected upstream file into a Vitest test module. Execute +its scripts and static helpers in their original order, in one window context per +file. Execute all registered subtests, including unselected ones, so their shared +state and setup remain intact. Filter results only when reporting them. Never +hide source-loading, setup, or harness failures behind a subtest filter. + +Consumer `wpt.config.ts` files supply document factories, global bindings, and +source/case selectors. Explicit includes override exclusions. Use original WPT +case names. Selecting some cases from a file does not establish coverage of the +whole file. Unmatched selectors must remain visible configuration errors. + +When enabling coverage or changing the harness: + +1. Read the original source and any helpers at the pinned revision. +2. Preserve the complete upstream setup, operation order, assertions, exceptions, + node identities, document ownership, and shared state between subtests. +3. Supply missing fixture capabilities without changing the behavior tested. + Unsupported source features must fail explicitly rather than silently skip. +4. Keep genuine file errors observable even when every subtest is excluded. + Any exception for a pending unsupported subtest must be narrow, documented, + and disabled when that subtest is selected. +5. Verify the affected consumer cases, build, and typecheck. Format and lint the + harness. When migrating coverage, compare cases and assertions; matching + totals or passing against a browser alone does not establish correspondence. + +Fix missing DOM behavior in the consumer or explicitly exclude unsupported cases +in its configuration. Never weaken upstream assertions to make an implementation +pass. Local harness code belongs in `src/node` and `src/vitest`; the consumer +should need only its configuration to integrate with this package. diff --git a/packages/web-platform-tests/README.md b/packages/web-platform-tests/README.md index 2b071d0..3a15086 100644 --- a/packages/web-platform-tests/README.md +++ b/packages/web-platform-tests/README.md @@ -1,17 +1,16 @@ # @bomb.sh/web-platform-tests -Private workspace package containing reusable DOM compatibility assertions. It contains no DOM implementation. Only `@clack/ui` tests consume its package API; browser validation is development tooling. +Run original [Web Platform Tests (WPT)](https://github.com/web-platform-tests/wpt) +against a DOM implementation. This private workspace package supplies a CLI, +HTML fixtures, and a Vitest transform. Each upstream source appears as a separate +test file, with individually reported subtests. -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. +The [`wpt`](wpt) submodule pins the upstream sources at the revision recorded in +[WPT_REVISION](WPT_REVISION). Upstream authorship and licenses remain in the +checkout; see [WPT's license](wpt/LICENSE.md). The local harness uses the package's +[MIT license](LICENSE). -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). Files under `src/wpt` mirror upstream paths with `.ts` appended; the revision applies to all files and cases. See [attribution and licenses](test/wpt/README.md). - -### Direct upstream checkpoint - -The `wpt` CLI runs original sources from the pinned `wpt` submodule. The initial -[UI configuration](../ui/wpt.config.ts) selects 208 cases from -`Node-parentNode.html` and `Document-createElementNS.html`. The adapted suite -remains in place while coverage is migrated. +## Running tests From the workspace root: @@ -19,120 +18,84 @@ From the workspace root: git submodule update --init packages/web-platform-tests/wpt pnpm --filter @bomb.sh/web-platform-tests build pnpm --filter @clack/ui exec wpt -# Subsequent runs need no rebuild unless the harness changes. -pnpm --filter @clack/ui exec wpt Node-parentNode -t 'Root element' ``` -The CLI accepts `--config path/to/wpt.config.ts`, optional filename filters, and -`-t`/`--name` for subtest names. Configurations import `WPTConfig` from -`@bomb.sh/web-platform-tests/config` and supply `createDocument`, `globals`, and -source/case selectors. Each upstream file appears separately in Vitest. - -The harness populates fixtures with parse5 and executes unchanged scripts and -static helpers in one window context per file. It uses upstream `testharness.js` -in its shell environment, supplies the document and `defaultView`, then delivers -window `load`. Entire files execute; selection filters the reported results. -Source-loading, setup, and harness failures remain failures regardless of filters. - -The excluded `Removed iframe` case in `Node-parentNode.html` is explicitly forced -to time out after load and the selected cases finish. Selecting that case disables -the exception. Iframe loading, parser-driven script timing, and module/async/defer -scripts are outside this checkpoint. - -### Required WPT correspondence +Subsequent runs need no rebuild unless the harness changes. The CLI accepts +`--config path/to/wpt.config.ts`, optional filename filters, and `-t`/`--name` for +subtest names: -Each file under `src/wpt` corresponds to its upstream path with the final `.ts` removed. For example, `src/wpt/dom/nodes/Document-createElement.html.ts` adapts `dom/nodes/Document-createElement.html`. Keep upstream spelling and capitalization for tests, helpers, and data. Local harness code lives in `src/shared`; comments explain non-obvious adaptations. - -Keep ordinary `context.test` and `expect` calls and readable case names. Preserve upstream inputs, setup, operation order, assertions, exceptions, node identities, and relationships between documents. A file's presence identifies the selected adaptations, not coverage of every upstream case. [Omissions](docs/omissions.md) records skipped upstream cases and why. - -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. - -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. - -```ts -import { testDOMCompatibility } from '@bomb.sh/web-platform-tests'; -import { describe, it, expect } from 'vitest'; -import { createDocument, dispose } from './implementation-fixture.ts'; -import config from './wpt.config.ts'; - -testDOMCompatibility({ - runner: { describe, it, expect }, - config, - create: createDocument, - dispose, - // input: document => createHostInputSession(document), -}); +```sh +pnpm --filter @clack/ui exec wpt Node-parentNode -t 'Root element' +pnpm --filter @clack/ui exec wpt --config wpt.config.ts Document-createElementNS ``` -### Selecting tests +`pnpm test` and `pnpm --filter @clack/ui test` build the harness, run the local +implementation tests, and run the configured WPT cases. -The `config` option is optional; omitting it runs all adapted cases. A `WPTConfig` supplies source-path selectors in `include` and `exclude`; an explicit include always wins. Each value is `true` for the entire source file or an array of exact case names and regular expressions matching case names. +## Configuration -When selection excludes every case, the harness registers a todo through `runner.it.todo` to start implementing DOM features and enable their WPT cases. +A consumer needs only a `wpt.config.ts`. It supplies a document factory and the +implementation's global bindings, then selects upstream source paths and original +case names. See the [UI configuration](../ui/wpt.config.ts). ```ts -import type { WPTConfig } from '@bomb.sh/web-platform-tests'; -import { globals } from './implementation-fixture.ts'; +import type { WPTConfig } from '@bomb.sh/web-platform-tests/config'; +import { createHTMLDocument, Node, Document, Element } from './dom.ts'; export default { - globals, - exclude: { 'dom/nodes/Node-insertBefore.html': true }, - include: { 'dom/nodes/Node-insertBefore.html': [/reference child/] }, + createDocument: () => createHTMLDocument(), + globals: { Node, Document, Element }, + include: { + 'dom/nodes/Node-parentNode.html': ['Document', 'Root element'], + }, + exclude: { '**': true }, } satisfies WPTConfig; ``` -Source paths support `*` within a path segment and `**` across directories; `**/` also matches zero directories. Other characters are literal. Case-name strings match exactly. Empty, invalid, or unmatched selectors fail configuration before any cases register, so stale exclusions remain visible. +`createDocument()` returns a fresh document for each upstream file. The harness +populates it with that file's HTML and installs `document.defaultView`. +`globals` supplies the constructors and other bindings the tests use. `timeout` +sets the maximum execution time per file in milliseconds; the default is 15,000. -Cases have no test-to-test prerequisite gates. A selected case exercises its supporting DOM operations and reports failures normally. Globals and host input are resolved lazily when the case uses them. The runner can narrow selected cases further with its usual name filter. +Source keys support `*` within a path segment and `**` across directories. Values +are `true` for every subtest in a source or arrays of exact names and regular +expressions. Explicit includes override exclusions; otherwise cases are included +unless excluded. Use `exclude: { '**': true }` to enable cases incrementally. +Invalid or unmatched selectors fail configuration. -Run `pnpm generate` after adding, moving, or removing source files. The build also regenerates the registry from filenames. Only files exporting `register` are test entrypoints; upstream support files are imported by those tests. `node scripts/generate-registry.mjs --check` verifies that the checked-in registry is current. +## Execution and limitations -### Harness +The harness parses HTML with parse5, populates the implementation's document, +and executes the original inline scripts and static local helpers in source +order within one window context per file. It loads upstream `testharness.js` in +its shell environment and delivers window `load` after the scripts finish. +Script elements are fixture nodes; parsing them does not execute their contents. -* `create(options?)`: A synchronous or asynchronous factory for a fresh `Document`. Cases using the default HTML document expect its doctype, `html`, `head`, and `body` tree. When a case supplies `DOMDocumentOptions`, honor its markup, MIME type, and URL fragment; the selector matrix uses these to test HTML, XHTML, and `:target`. -* `config.globals`: An object containing the implementation's global bindings, or a function that returns them for each fresh document. Tests destructure typed bindings from the fixture, such as `({ document, Node, Text })`. Omitting globals supplies no bindings; accessing a missing binding throws. -* `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. -* `dispose(document)`: Optional cleanup for implementation-owned resources after each case, including failures. +Entire selected files execute, including their unselected subtests. Configuration +and CLI name filters select the results reported by Vitest. This preserves +upstream shared state and setup. Source-loading, setup, and harness errors remain +failures regardless of subtest selection. -### Development +The excluded `Removed iframe` case in `Node-parentNode.html` is explicitly forced +to time out after window load and the selected cases finish. Selecting that case +disables this exception. It depends on an iframe load the fixture cannot deliver. + +The runner supports HTML sources and window `.any.js`/`.window.js` sources with +static helpers. It does not implement iframe navigation, parser-driven script +timing, module/async/defer scripts, server substitutions, or remote helpers. +Unsupported source features fail explicitly. Selecting part of a file does not +claim coverage of its remaining subtests or complete standards conformance. + +## Development ```sh -pnpm build -pnpm test +pnpm --filter @bomb.sh/web-platform-tests build pnpm --filter @bomb.sh/web-platform-tests typecheck -pnpm --filter @bomb.sh/web-platform-tests exec playwright install chromium -pnpm --filter @bomb.sh/web-platform-tests test:browser:build -pnpm --filter @bomb.sh/web-platform-tests test:browser:input -pnpm --filter @bomb.sh/web-platform-tests test:browser:run -pnpm --filter @bomb.sh/web-platform-tests test:wpt-selectors -# Manual, without input: open /compatibility.html on the printed URL -pnpm --filter @bomb.sh/web-platform-tests test:browser +pnpm lint --warnings +pnpm format:check +pnpm --filter @clack/ui exec wpt ``` -To validate the test suite itself, run it against an actual browser runtime. Browser dependencies are development-only. - -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. - -The [selector audit](scripts/check-wpt-selectors.mjs), run by `test:wpt-selectors` and CI, checks registered case names, matrix data, API masks, and fixture bytes against the pinned upstream sources. It covers selector API files in `dom/nodes` plus `is-where-basic.html` and `has-basic.html`; the script records exclusions. Downloads are cached in ignored `node_modules/.cache`, and reports go to stdout. After changing selector adaptations or the suite revision, run this audit and browser validation, and review the assertions against upstream. - -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. - -#### Browser results - -Browser validation keeps upstream expectations intact. Failures remain enabled -and produce a nonzero exit code. - -### Coverage boundaries - -The [adapted sources](src/wpt) and generated [registry](src/shared/registry.ts) describe the executable coverage. Harness tests check source identity, case selection, and reachability of every source module. The [UI configuration](../ui/test/wpt.config.ts) records the cases enforced by that integration; the [UI test README](../ui/test/README.md) explains how to select additional cases while implementing them. Passing selected cases does not imply complete standards conformance. - -Remaining test gaps include: - -- DOM mutation validity and adoption permutations, Web IDL conversions and brands, collection descriptors and iteration mutations, complete selector grammar and HTML reflection, and XML namespace/entity/PI/CDATA cases. -- The full HTML tree-construction and contextual parsing corpora, malformed foreign markup, sanitization, and Trusted Types. -- Legacy event initialization and listener-option conversions; overlapping observer registrations and custom-element/slotchange/promise ordering; complete Range endpoint and mutation matrices, NodeIterator filtering/mutations, and text-control selectionchange scheduling. -- Complete control-type value/validity/stepping matrices, files and pickers, FormData and submission interleavings, network submission, and select UI policies. -- Customized built-ins, scoped custom-element registries, ElementInternals and form-state restoration, reaction ordering, nested-slot redistribution, focus navigation scopes, focus-visible preferences, and modal/inert exceptions. -- Full CSS property grammar and computed values, revert/revert-layer, layer/import interactions, stylesheet loading/CORS/grouping and cross-document adoption, media/container queries, and animation/transition timelines. -- IME/composition, clipboard, repeat timing, drag/drop, touch/pen/wheel, multi-click selection, editing history and input target ranges, further textarea/contenteditable editing, nested-shadow navigation, and platform command bindings. -Exact geometry, visual-line navigation, caret painting, scroll positioning, occlusion, hit-testing geometry matrices, and visual-output assertions require additional renderer integration. Shared input tests assert resulting behavior without assuming browser-equivalent pixels. Platform interaction policies and trusted-event support remain independently selectable. +Read the original source and its helpers before enabling a case. Keep upstream +inputs, assertions, and execution order intact. Extend the harness only to supply +fixture capabilities; implement missing DOM behavior in the consumer. diff --git a/packages/web-platform-tests/docs/omissions.md b/packages/web-platform-tests/docs/omissions.md deleted file mode 100644 index 770039e..0000000 --- a/packages/web-platform-tests/docs/omissions.md +++ /dev/null @@ -1,45 +0,0 @@ -# WPT omissions - -Known omissions at [WPT_REVISION](../WPT_REVISION). Source paths are relative to -the upstream WPT root. Consumer exclusions in `wpt.config.ts` are separate. - -## DOM and selectors - -| Upstream source | Omitted cases | Reason | -| --- | --- | --- | -| `dom/nodes/Element-webkitMatchesSelector.html` | Entire file. | Vendor-prefixed alias; coverage targets standard `matches`. | -| `dom/nodes/Element-matches-namespaced-elements.html` | The `webkitMatchesSelector` rows. | Vendor-prefixed alias. | -| `dom/nodes/ParentNode-querySelector-All.html`, `dom/nodes/ParentNode-querySelector-All-xht.xht`, `dom/nodes/Element-matches.html` | Unnamed iframe-loader cases. | The consumer's document factory replaces upstream fixture loading; behavioral subtests remain. | -| `dom/nodes/attributes.html` | `setAttributeNode, if it fires mutation events, should fire one with the new node when resetting an existing attribute`, and its ` (outer shell)` companion. | Legacy `DOMAttrModified` coverage is outside the current event scope; both the listener assertions and their outer-shell setup remain omitted. | -| `dom/events/EventListener-handleEvent.html` | `` rethrows errors when getting `handleEvent` ``, ``throws if `handleEvent` is falsy and not callable``, and ``throws if `handleEvent` is thruthy and not callable``. | Require asynchronous window error reporting and the upstream `EventWatcher` harness. | -| `domparsing/createContextualFragment.html` | ``) - .join(''); - body = `${dependencies}`; - } else if (path === 'resources/testharness.js') body += completionHook; - response.writeHead(200, { 'Content-Type': `${contentType}; charset=utf-8` }).end(body); - } catch (error) { - // The upstream fixture intentionally references nonexistent foo.jpg. A WPT - // server returns 404; missing test documents/scripts must still fail the audit. - if (error.details?.missing && request.headers['sec-fetch-dest'] === 'image') { - response.writeHead(404).end(); - return; - } - requestErrors.push(error.message); - response.writeHead(500).end(error.message); - } -}); - -let browser; -const results = []; -const exclusions = []; -const errors = []; -try { - await new Promise((resolve, reject) => { - server.once('error', reject); - server.listen(0, '127.0.0.1', resolve); - }); - browser = await chromium.launch({ - headless: true, - ...(process.env.CHROME_BIN ? { executablePath: process.env.CHROME_BIN } : {}), - }); - const origin = `http://127.0.0.1:${server.address().port}`; - for (const path of pages) { - const context = await browser.newContext(); - try { - await context.route('**/*', (route) => - new URL(route.request().url()).origin === origin ? route.continue() : route.abort(), - ); - const page = await context.newPage(); - await page.goto(`${origin}/${path}${path.endsWith('.window.js') ? '?audit-wrapper' : ''}`); - await page.waitForFunction(() => globalThis.__selectorAudit, undefined, { timeout: 30_000 }); - const result = await page.evaluate(() => globalThis.__selectorAudit); - if (result.status.status !== 0) - throw new SelectorAuditError( - `WPT harness status ${result.status.status}: ${result.status.message}`, - ); - let tests = result.tests; - if (sourceExclusions.has(path)) { - exclusions.push({ - source: path, - reason: sourceExclusions.get(path), - cases: tests.map((test) => test.name), - }); - continue; - } - if (caseExclusions.has(path)) { - const names = caseExclusions.get(path); - const excluded = tests.filter((test) => names.has(test.name)); - if (excluded.length !== names.size) - throw new SelectorAuditError( - 'Vendor alias exclusions do not match upstream registrations', - { source: path }, - ); - exclusions.push({ - source: path, - reason: - 'Vendor-prefixed alias cases; the same namespace assertions for unprefixed matches are adapted.', - cases: excluded.map((test) => test.name), - }); - tests = tests.filter((test) => !names.has(test.name)); - } - if (bootstrapSources.has(path)) { - const bootstrap = tests.filter((test) => test.name === result.title); - if (bootstrap.length !== 1) - throw new SelectorAuditError( - `Expected exactly one unnamed iframe-loader case, found ${bootstrap.length}`, - ); - exclusions.push({ - source: path, - reason: - 'WPT iframe-loader harness case; adapted cases receive their fixture from the document factory.', - cases: bootstrap.map((test) => test.name), - }); - tests = tests.filter((test) => test.name !== result.title); - } - if (!tests.length) throw new SelectorAuditError('No upstream behavioral cases registered'); - results.push({ - source: path, - cases: tests.map((test) => `WPT ${path.split('/').at(-1)}: ${test.name}`), - browserFailures: tests - .filter((test) => test.status !== 0) - .map(({ name, status, message }) => ({ name, status, message })), - }); - } catch (error) { - errors.push({ source: path, message: error.message }); - } finally { - await context.close(); - } - } -} finally { - await browser?.close(); - await new Promise((resolve) => server.close(resolve)); -} - -const expectedNames = results.flatMap((result) => result.cases); -const report = { - revision, - scope: - 'All dom/nodes querySelector/querySelectorAll, matches and closest testharness sources, plus css/selectors/is-where-basic.html and has-basic.html.', - upstreamSources: results.length, - upstreamCases: expectedNames.length, - adaptedCases: adaptedNames.length, - sources: results.map((result) => ({ source: result.source, cases: result.cases.length })), - missing: difference(expectedNames, adaptedNames), - extra: difference(adaptedNames, expectedNames), - undeclaredSources: results - .filter((result) => !declaredSources.has(result.source)) - .map((result) => result.source), - exclusions, - supportFiles, - preservationChecks, - errors: [...preservationErrors, ...errors, ...requestErrors.map((message) => ({ message }))], - // Assertion failures are retained for visibility but this tool checks case - // registration coverage, not browser conformance or assertion equivalence. - upstreamBrowserFailures: results - .filter((result) => result.browserFailures.length) - .map((result) => ({ source: result.source, cases: result.browserFailures })), -}; -if (options.json) console.info(JSON.stringify(report, null, 2)); -else { - console.info( - `Pinned WPT ${revision}: ${report.upstreamCases} upstream cases in ${report.upstreamSources} sources; ${report.adaptedCases} adapted cases.`, - ); - console.info(`Corpus and fixture preservation checks passed: ${preservationChecks.length}/8.`); - for (const exclusion of exclusions) - console.info( - `EXCLUDED ${exclusion.source}: ${exclusion.cases.length} case(s). ${exclusion.reason}`, - ); - for (const name of report.missing) console.info(`MISSING ${name}`); - for (const name of report.extra) console.info(`EXTRA ${name}`); - for (const path of report.undeclaredSources) console.info(`UNDECLARED SOURCE ${path}`); - for (const error of report.errors) - console.info(`ERROR ${error.source ?? 'resource'}: ${error.message}`); - for (const result of report.upstreamBrowserFailures) - console.info( - `UPSTREAM BROWSER FAILURES ${result.source}: ${result.cases.map((test) => `${test.name}: ${test.message}`).join('; ')}`, - ); - console.info( - `Missing: ${report.missing.length}; extra: ${report.extra.length}; undeclared sources: ${report.undeclaredSources.length}; extraction errors: ${report.errors.length}.`, - ); - console.info( - 'Case registration and matrix data preservation only: this audit does not establish complete assertion equivalence or selector conformance. Use --json for full source and exclusion details.', - ); -} -if ( - report.missing.length || - report.extra.length || - report.undeclaredSources.length || - report.errors.length -) - process.exitCode = 1; diff --git a/packages/web-platform-tests/scripts/generate-registry.mjs b/packages/web-platform-tests/scripts/generate-registry.mjs deleted file mode 100644 index b889599..0000000 --- a/packages/web-platform-tests/scripts/generate-registry.mjs +++ /dev/null @@ -1,63 +0,0 @@ -import { readdirSync, readFileSync, writeFileSync } from 'node:fs'; - -const root = new URL('../src/wpt/', import.meta.url); -const destination = new URL('../src/shared/registry.ts', import.meta.url); - -function files(directory, prefix = '') { - return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => { - const name = prefix + entry.name; - if (entry.isDirectory()) return files(new URL(`${entry.name}/`, directory), `${name}/`); - return entry.isFile() && /\.(?:html|xhtml|xht|js)\.ts$/.test(name) ? [name] : []; - }); -} - -const tests = files(root) - .toSorted() - .map((path) => ({ - path, - alias: path.slice(0, -3).replace(/[^A-Za-z0-9_$]/g, '_'), - content: readFileSync(new URL(path, root), 'utf8'), - })) - .filter(({ content }) => /^export function register\(/m.test(content)); - -const pathsByAlias = new Map(); -for (const { path, alias } of tests) { - if (pathsByAlias.has(alias)) { - process.stderr.write( - `WPT registry alias collision: "${pathsByAlias.get(alias)}" and "${path}" both map to "${alias}".\n`, - ); - process.exit(1); - } - pathsByAlias.set(alias, path); -} - -const output = [ - '// Generated from src/wpt filenames by scripts/generate-registry.mjs.', - "import type { CompatibilityModule } from './context.ts';", - ...tests.map(({ path, content, alias }) => { - const imports = [`register as register_${alias}`]; - if (/^export const input\b/m.test(content)) imports.push(`input as input_${alias}`); - return imports.length === 1 - ? `import { ${imports[0]} } from '../wpt/${path}';` - : `import {\n${imports.map((name) => `\t${name},`).join('\n')}\n} from '../wpt/${path}';`; - }), - '', - '// prettier-ignore', - 'export const registry = {', - ...tests.map(({ path, content, alias }) => { - const members = [`register: register_${alias}`]; - if (/^export const input\b/m.test(content)) members.push(`input: input_${alias}`); - return `\t'${path.slice(0, -3)}': { ${members.join(', ')} },`; - }), - '} satisfies Record;', - '', -].join('\n'); - -if (process.argv.includes('--check')) { - if (readFileSync(destination, 'utf8') !== output) { - process.stderr.write( - 'WPT registry is stale. Run pnpm --filter @bomb.sh/web-platform-tests generate.\n', - ); - process.exitCode = 1; - } -} else writeFileSync(destination, output); diff --git a/packages/web-platform-tests/src/frameworks/features.ts b/packages/web-platform-tests/src/frameworks/features.ts deleted file mode 100644 index 2dfedfb..0000000 --- a/packages/web-platform-tests/src/frameworks/features.ts +++ /dev/null @@ -1,234 +0,0 @@ -import type { WPTSelectors } from '../shared/selection.ts'; - -/** - * DOM members measured in framework runtimes, keyed by interface member, mapped to the adapted - * WPT cases that exercise them. An empty selector map means no adapted WPT source covers the - * member yet; it stays listed so profiles keep recording the requirement. - */ -export const features = { - // Document - 'Document#createElement': { 'dom/nodes/Document-createElement.html': true }, - 'Document#createElementNS': { 'dom/nodes/Document-createElementNS.html': true }, - 'Document#createTextNode': { 'dom/nodes/Document-createTextNode.html': true }, - 'Document#createComment': { 'dom/nodes/Document-createComment.html': true }, - 'Document#createDocumentFragment': {}, - 'Document#activeElement': { 'html/editing/focus/focus-management/focus-blur.html': true }, - 'Document#defaultView': {}, - 'Document#head': {}, - 'Document#documentElement': {}, - 'Document#contentType': {}, - 'Document#importNode': { - 'dom/nodes/Document-importNode.html': [/'deep' argument\.$/], - }, - 'Document#createTreeWalker': { - 'dom/traversal/TreeWalker-basic.html': true, - 'dom/traversal/TreeWalker-acceptNode-filter.html': true, - 'dom/traversal/TreeWalker-traversal-reject.html': true, - 'dom/traversal/TreeWalker-traversal-skip.html': true, - }, - 'Document#createRange': { - 'dom/ranges/Range-constructor.html': true, - 'dom/ranges/Range-attributes.html': true, - }, - - // Node - 'Node#nodeType': {}, - 'Node#ownerDocument': {}, - 'Node#parentNode': { - 'dom/nodes/Node-parentNode.html': ['sets the parent of an appended element', 'Root element'], - }, - 'Node#firstChild': {}, - 'Node#lastChild': {}, - 'Node#nextSibling': {}, - 'Node#childNodes': { 'dom/nodes/Node-childNodes.html': true }, - 'Node#insertBefore': { 'dom/nodes/Node-insertBefore.html': true }, - 'Node#appendChild': {}, - 'Node#removeChild': { 'dom/nodes/Node-removeChild.html': true }, - 'Node#replaceChild': { 'dom/nodes/Node-replaceChild.html': true }, - 'Node#cloneNode': { 'dom/nodes/Node-cloneNode.html': true }, - // Frameworks never create ProcessingInstruction or DocumentType nodes, nor set Document text. - 'Node#textContent': { - 'dom/nodes/Node-textContent.html': [/^(?!.*(ProcessingInstruction|DocumentType|Documents))/], - }, - 'Node#nodeValue': { 'dom/nodes/Node-nodeValue.html': ['Text.nodeValue', 'Comment.nodeValue'] }, - 'Node#contains': { 'dom/nodes/Node-contains.html': true }, - 'Node#getRootNode': {}, - 'Node#isConnected': { 'dom/nodes/Node-isConnected.html': true }, - 'Node#compareDocumentPosition': { 'dom/nodes/Node-compareDocumentPosition.html': true }, - - // ChildNode / ParentNode / CharacterData - 'ChildNode#remove': { - 'dom/nodes/Element-remove.html': true, - 'dom/nodes/CharacterData-remove.html': [ - /^(text|comment) should support remove\(\)$/, - /if (text|comment) /, - ], - }, - 'ChildNode#before': {}, - 'ParentNode#moveBefore': {}, - 'ChildNode#after': {}, - 'ParentNode#children': { 'dom/nodes/ParentNode-children.html': true }, - 'CharacterData#data': { 'dom/nodes/CharacterData-data.html': true }, - - // Element - 'Element#setAttribute': { - 'dom/nodes/Element-setAttribute.html': true, - 'dom/nodes/Element-setAttribute-crbug-1138487.html': true, - 'dom/nodes/attributes.html': [/\bsetAttribute\b/], - }, - 'Element#getAttribute': { - 'dom/nodes/attributes.html': [ - 'Unset attributes return null', - 'First set attribute is returned by getAttribute', - 'Only lowercase attributes are returned on HTML elements (upper case attribute)', - 'Only lowercase attributes are returned on HTML elements (mixed case attribute)', - ], - }, - 'Element#namespaceURI': { 'dom/nodes/Document-createElementNS.html': true }, - 'Element#localName': { - 'dom/nodes/Document-createElement.html': true, - 'dom/nodes/Document-createElementNS.html': true, - }, - 'Element#id': {}, - 'Element#tagName': {}, - 'Element#nodeName': {}, - 'Element#removeAttribute': { 'dom/nodes/Element-removeAttribute.html': true }, - 'Element#className': { 'html/dom/reflection-misc.html': [/^html\.className /] }, - 'Element#classList': { 'dom/nodes/Element-classlist.html': true }, - 'Element#innerHTML': { - 'domparsing/innerhtml-04.html': true, - 'domparsing/innerhtml-07.html': true, - 'domparsing/innerhtml-08.html': true, - 'domparsing/innerhtml-li-autoclosing.html': true, - 'html/syntax/serializing-html-fragments/serializing.html': [/^innerHTML /], - }, - // Svelte's select binding queries `:checked`, `[selected]`, and `option:not([disabled])` only. - 'Element#querySelector': { 'html/semantics/selectors/pseudo-classes/checked.html': true }, - 'DocumentFragment#querySelectorAll': { - 'dom/nodes/DocumentFragment-querySelectorAll-after-modification.html': true, - }, - 'Element#attachShadow': { 'shadow-dom/Element-interface-attachShadow.html': true }, - - // HTMLElement and CSSOM - 'HTMLElement#style': { - 'css/cssom/css-style-attr-decl-block.html': true, - 'css/cssom/css-style-attribute-modifications.html': true, - 'css/cssom/CSSStyleDeclaration-indexed-properties.html': true, - }, - 'CSSStyleDeclaration#setProperty': { 'css/cssom/cssom-setProperty-shorthand.html': true }, - getComputedStyle: { 'css/cssom/computed-style-001.html': true }, - 'HTMLElement#contentEditable': {}, - 'HTMLElement#focus': { - 'html/editing/focus/focus-management/focus-blur.html': true, - 'html/interaction/focus/focus-management/focus-events.html': true, - }, - 'HTMLTemplateElement#content': { - 'html/semantics/scripting-1/the-template-element/definitions/template-contents.html': true, - 'html/semantics/scripting-1/the-template-element/innerhtml-on-templates/innerhtml.html': true, - 'html/semantics/scripting-1/the-template-element/additions-to-the-steps-to-clone-a-node/template-clone-children.html': true, - }, - - // Form controls. Reflection must use prototype accessors (React's value tracker); no WPT covers that. - 'HTMLInputElement#value': { - 'html/semantics/forms/the-input-element/input-value-dirty-flag.html': true, - 'html/semantics/forms/the-input-element/text.html': [/^(Value returns|Setting value changes)/], - }, - 'HTMLInputElement#type': { - 'html/semantics/forms/the-input-element/input-value-dirty-flag.html': [ - "Input type defaults to 'text' on the property despite no attribute", - 'Setting input type property sets the attribute', - ], - }, - 'HTMLInputElement#name': {}, - 'HTMLInputElement#defaultValue': { - 'html/semantics/forms/the-input-element/input-value-dirty-flag.html': [ - 'Input value/defaultValue dirty value flag semantics', - ], - }, - 'HTMLInputElement#defaultChecked': { - 'html/semantics/forms/the-input-element/input-value-dirty-flag.html': [ - 'Input checked/defaultChecked dirty checkedness semantics', - ], - }, - 'HTMLInputElement#selectionStart': { - 'html/semantics/forms/textfieldselection/defaultSelection.html': true, - }, - 'HTMLInputElement#selectionEnd': { - 'html/semantics/forms/textfieldselection/defaultSelection.html': true, - }, - 'HTMLInputElement#disabled': { 'html/semantics/selectors/pseudo-classes/disabled.html': true }, - 'HTMLButtonElement#disabled': { 'html/semantics/selectors/pseudo-classes/disabled.html': true }, - 'HTMLTextAreaElement#disabled': { - 'html/semantics/selectors/pseudo-classes/disabled.html': true, - }, - 'HTMLOptionElement#disabled': { 'html/semantics/selectors/pseudo-classes/disabled.html': true }, - 'HTMLInputElement#checked': { - 'html/semantics/forms/the-input-element/input-value-dirty-flag.html': [ - 'Input checked/defaultChecked dirty checkedness semantics', - ], - 'html/semantics/forms/the-input-element/checkbox-click-events.html': true, - }, - 'HTMLInputElement#setSelectionRange': { - 'html/semantics/forms/textfieldselection/selection.html': true, - }, - 'HTMLTextAreaElement#value': { - 'html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html': true, - }, - 'HTMLTextAreaElement#defaultValue': { - 'html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html': true, - }, - 'HTMLOptionElement#value': { 'html/semantics/forms/the-option-element/option-value.html': true }, - 'HTMLOptionElement#selected': { - 'html/semantics/forms/the-option-element/option-selected.html': true, - }, - 'HTMLSelectElement#value': { - 'html/semantics/forms/the-select-element/select-value.html': true, - 'html/semantics/forms/the-select-element/selected-index.html': true, - }, - - // Events - 'EventTarget#addEventListener': { - 'dom/events/EventTarget-addEventListener.any.js': true, - 'dom/events/EventTarget-add-remove-listener.any.js': true, - 'dom/events/AddEventListenerOptions-once.any.js': true, - 'dom/events/AddEventListenerOptions-passive.any.js': true, - 'dom/events/AddEventListenerOptions-signal.any.js': true, - 'dom/events/EventListenerOptions-capture.html': true, - 'dom/events/EventListener-handleEvent.html': true, - 'dom/events/EventTarget-this-of-listener.html': true, - }, - 'EventTarget#removeEventListener': { - 'dom/events/EventTarget-removeEventListener.any.js': true, - 'dom/events/remove-all-listeners.html': true, - }, - // Capture/target/bubble over the ancestor path, with target/currentTarget maintenance. - 'EventTarget#dispatchEvent': { - 'dom/events/EventTarget-dispatchEvent.html': true, - 'dom/events/EventTarget-dispatchEvent-returnvalue.html': true, - 'dom/events/Event-dispatch-bubbles-false.html': true, - 'dom/events/Event-dispatch-bubbles-true.html': true, - 'dom/events/Event-dispatch-handlers-changed.html': true, - 'dom/events/Event-dispatch-multiple-cancelBubble.html': true, - 'dom/events/Event-dispatch-multiple-stopPropagation.html': true, - 'dom/events/Event-dispatch-propagation-stopped.html': true, - 'dom/events/Event-dispatch-reenter.html': true, - 'dom/events/Event-dispatch-target-moved.html': true, - 'dom/events/Event-dispatch-throwing.html': true, - 'dom/events/Event-stopImmediatePropagation.html': true, - 'dom/events/Event-defaultPrevented-after-dispatch.html': true, - }, - Event: { 'dom/events/Event-constructors.any.js': true }, - 'Event#composedPath': { - 'shadow-dom/event-composed-path.html': ['Event Path without ShadowRoots.'], - }, - // React feature-detects event support through handler IDL attributes. - 'GlobalEventHandlers#onclick': {}, - 'Event#isTrusted': {}, - 'MutationObserver#observe': { 'dom/nodes/MutationObserver-sanity.html': true }, - 'MutationObserver#disconnect': { 'dom/nodes/MutationObserver-takeRecords.html': true }, - 'MutationObserver#childList': { - 'dom/nodes/MutationObserver-childList.html': [/^childList (?!Range\.|Node\.normalize)/], - }, -} as const satisfies Record; - -export type DOMFeature = keyof typeof features; diff --git a/packages/web-platform-tests/src/frameworks/frameworks.ts b/packages/web-platform-tests/src/frameworks/frameworks.ts deleted file mode 100644 index d55614d..0000000 --- a/packages/web-platform-tests/src/frameworks/frameworks.ts +++ /dev/null @@ -1,231 +0,0 @@ -import { CompatibilityConfigurationError, type WPTSelectors } from '../shared/selection.ts'; -import { features, type DOMFeature } from './features.ts'; - -interface FrameworkProfile { - /** Non-hydrated mount, update, and unmount of a typical application. */ - required: readonly DOMFeature[]; - /** Opt-in renderer modules, each enabled only when the integration supports it. */ - optional: Readonly>; -} - -/** Shared by every measured framework. */ -const core = [ - 'Element#innerHTML', - 'Element#setAttribute', - 'EventTarget#addEventListener', - 'EventTarget#dispatchEvent', - 'Event', - 'HTMLElement#style', - 'CSSStyleDeclaration#setProperty', - 'Document#createTextNode', - 'Node#nodeType', - 'HTMLInputElement#value', - 'HTMLInputElement#checked', - 'HTMLInputElement#type', - 'HTMLTextAreaElement#value', -] as const satisfies readonly DOMFeature[]; - -/** - * Measured DOM baseline per framework, from the non-hydrated happy-dom recorder study. - * Recorded against React 19.3.1, Preact 11.2.0, Vue 3.5.45, Solid 1.9.19, and Svelte 5.57.3. - */ -export const frameworks = { - react: { - required: [ - ...core, - 'Document#createElement', - 'Document#createElementNS', - 'Node#insertBefore', - 'Node#firstChild', - 'Node#textContent', - 'Node#ownerDocument', - 'Element#removeAttribute', - 'Node#nodeValue', - 'Node#appendChild', - 'Node#removeChild', - 'HTMLOptionElement#value', - 'HTMLOptionElement#selected', - 'HTMLSelectElement#value', - 'Document#activeElement', - 'Document#defaultView', - 'Document#documentElement', - 'Node#lastChild', - 'Node#getRootNode', - 'Node#contains', - 'HTMLElement#contentEditable', - 'Event#composedPath', - 'Event#isTrusted', - 'Element#namespaceURI', - 'Element#tagName', - 'Element#nodeName', - 'GlobalEventHandlers#onclick', - 'HTMLInputElement#name', - 'HTMLInputElement#defaultValue', - 'HTMLInputElement#defaultChecked', - 'HTMLInputElement#selectionStart', - 'HTMLInputElement#selectionEnd', - 'HTMLTextAreaElement#defaultValue', - 'HTMLOptionElement#disabled', - ], - optional: { - // Resource hoisting inserts , - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - "z-index:inherit on root element should compute to 'auto'.", - ({ document, getComputedStyle }) => { - expect(getComputedStyle(document.documentElement).zIndex).toBe('auto'); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - "position:inherit on root element should compute to 'static'.", - ({ document, getComputedStyle }) => { - expect(getComputedStyle(document.documentElement).position).toBe('static'); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - "overflow:inherit on root element should compute to 'visible'.", - ({ document, getComputedStyle }) => { - expect(getComputedStyle(document.documentElement).overflow).toBe('visible'); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - "background-color:inherit on root element should compute to 'rgba(0, 0, 0, 0)'.", - ({ document, getComputedStyle }) => { - expect(getComputedStyle(document.documentElement).backgroundColor).toBe('rgba(0, 0, 0, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-basic.html.ts b/packages/web-platform-tests/src/wpt/css/css-cascade/layer-basic.html.ts deleted file mode 100644 index b9858cd..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-basic.html.ts +++ /dev/null @@ -1,536 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - { - const testCases = [ - { - title: 'A1 Anonymous layers', - style: ` - @layer { } - target { color: green; } - `, - }, - { - title: 'A2 Anonymous layers', - style: ` - target { color: green; } - @layer { - target { color: red; } - } - `, - }, - { - title: 'A3 Anonymous layers', - style: ` - @layer { - target { color: red; } - } - target { color: green; } - `, - }, - { - title: 'A4 Anonymous layers', - style: ` - @layer { - target { color: red; } - } - @layer { - target { color: green; } - } - `, - }, - { - title: 'A5 Anonymous layers', - style: ` - @layer { - target { color: green; } - @layer { - target { color: red; } - } - } - `, - }, - { - title: 'A6 Anonymous layers', - style: ` - @layer { - @layer { - target { color: red; } - } - target { color: green; } - } - `, - }, - { - title: 'A7 Anonymous layers', - style: ` - @layer { - @layer { - target { color: red; } - } - target { color: red; } - } - @layer { - @layer { - target { color: red; } - } - target { color: green; } - } - `, - }, - { - title: 'A8 Anonymous layers', - style: ` - @layer { - @layer { - @layer { - target { color: red; } - } - } - target { color: red; } - } - @layer { - @layer { - target { color: red; } - } - target { color: green; } - } - `, - }, - { - title: 'A9 Anonymous layers', - style: ` - @layer { - @layer { - target { color: red; } - } - target { color: red; } - } - @layer { - @layer { - @layer { - target { color: red; } - } - } - target { color: green; } - } - `, - }, - { - title: 'B1 Named layers', - style: ` - @layer A { - } - target { color: green; } - `, - }, - { - title: 'B2 Named layers', - style: ` - @layer A { - target { color: red; } - } - target { color: green; } - `, - }, - { - title: 'B3 Named layers', - style: ` - @layer A { - target { color: red; } - } - @layer A { - target { color: green; } - } - `, - }, - { - title: 'B4 Named layers', - style: ` - @layer A { - target { color: red; } - } - @layer B { - target { color: green; } - } - @layer A { - target { color: red; } - } - `, - }, - { - title: 'B5 Named layers', - style: ` - @layer A { - target { color: green; } - @layer A { - target { color: red; } - } - } - `, - }, - { - title: 'B6 Named layers', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer A { - @layer A { - target { color: green; } - } - } - `, - }, - { - title: 'B7 Named layers', - style: ` - @layer A { - target { color: red; } - @layer A { - target { color: red; } - } - } - @layer B { - target { color: green; } - } - @layer A { - @layer A { - target { color: red; } - } - } - `, - }, - { - title: 'B8 Named layers', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer B { - @layer A { - target { color: green; } - } - } - `, - }, - { - title: 'B9 Named layers', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer B { - @layer A { - target.first { color: green; } - } - } - @layer A { - @layer A { - target.first { color: red; } - target.second { color: green; } - } - } - `, - }, - { - title: 'B10 Named layers', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer B { - @layer A { - target.first { color: green; } - } - } - @layer A { - @layer B { - target.first { color: red; } - target.second { color: green; } - } - } - `, - }, - { - title: 'C1 Named layers shorthand', - style: ` - @layer A.A { - target { color: red; } - } - @layer B.A { - target { color: green; } - } - `, - }, - { - title: 'C2 Named layers shorthand', - style: ` - @layer A.A { - target { color: red; } - } - @layer B.A { - target.first { color: green; } - } - @layer A.A { - target.first { color: red; } - target.second { color: green; } - } - `, - }, - { - title: 'C3 Named layers shorthand', - style: ` - @layer A.A { - target { color: red; } - } - @layer B.A { - target.first { color: green; } - } - @layer A.B { - target.first { color: red; } - target.second { color: green; } - } - `, - }, - { - title: 'C4 Named layers shorthand', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer B.A { - target { color: green; } - } - @layer A.A - target { color: red; } - } - `, - }, - { - title: 'C5 Named layers shorthand', - style: ` - @layer A { - @layer A { - target { color: red; } - } - } - @layer B.A { - target { color: green; } - } - @layer A.B { - target { color: red; } - } - `, - }, - { - title: 'D1 Mixed named and anonymous layers', - style: ` - @layer A { - target { color: red; } - } - @layer { - target { color: green; } - } - `, - }, - { - title: 'D2 Mixed named and anonymous layers', - style: ` - @layer A { - @layer { - target { color: red; } - } - } - @layer A { - target { color: green; } - } - `, - }, - { - title: 'D3 Mixed named and anonymous layers', - style: ` - @layer A { - @layer { - target { color: red; } - } - } - @layer A { - @layer { - target { color: green; } - } - } - `, - }, - { - title: 'D4 Mixed named and anonymous layers', - style: ` - @layer A { - @layer { - target { color: red; } - } - } - @layer { - target { color: green; } - } - @layer A { - @layer { - target { color: red; } - } - } - `, - }, - { - title: 'D5 Mixed named and anonymous layers', - style: ` - @layer { - @layer A { - target { color: red; } - } - } - @layer { - target { color: green; } - } - `, - }, - { - title: 'E1 Statement syntax', - style: ` - @layer A, B, C; - @layer A { - target.first { color: red; } - target.second { color: red; } - } - @layer B { - target.first { color: red; } - } - @layer C { - target.first { color: green; } - target.second { color: green; } - } - `, - }, - { - title: 'E2 Statement syntax', - style: ` - @layer A, C, B; - @layer A { - target.first { color: red; } - target.second { color: red; } - } - @layer B { - target.first { color: green; } - } - @layer C { - target.first { color: red; } - target.second { color: green; } - } - `, - }, - { - title: 'E3 Statement syntax', - style: ` - @layer C, B, A; - @layer A { - target.first { color: green; } - target.second { color: green; } - } - @layer B { - target.first { color: red; } - } - @layer C { - target.first { color: red; } - target.second { color: red; } - } - `, - }, - { - title: 'E4 Statement syntax', - style: ` - @layer B, A.B, A.A; - @layer A { - @layer A { - target.first { color: green; } - } - @layer B { - target.first { color: red; } - target.second { color: green; } - } - } - @layer B { - target { color: red; } - } - `, - }, - { - title: 'E5 Statement syntax', - style: ` - @layer A.B, B, A.A; - @layer A { - @layer A { - target.first { color: red; } - } - @layer B { - target.first { color: red; } - target.second { color: red; } - } - } - @layer B { - target { color: green; } - } - `, - }, - ]; - for (const testCase of testCases) { - context.test( - testCase['title'], - ({ document, getComputedStyle }) => { - const styleElement = document.createElement('style'); - styleElement.textContent = testCase['style']; - document.head.append(styleElement); - - let targets = document.querySelectorAll('target'); - for (const target of targets) - expect( - getComputedStyle(target).color, - testCase['title'] + ", target '" + target.classList[0] + "'", - ).toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: ` - - -CSS Cascade Layers: Basic functionality - - - - - - - - - -
- - - -`, - }, - }, - ); - } - } -} diff --git a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-important.html.ts b/packages/web-platform-tests/src/wpt/css/css-cascade/layer-important.html.ts deleted file mode 100644 index d0d07b9..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-important.html.ts +++ /dev/null @@ -1,119 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - { - const testCases = [ - { - title: 'A1 Unlayered !important style', - style: ` - target { color: green !important; } - target { color: red; } - `, - }, - { - title: 'B1 Same specificity, layered !important first', - style: ` - @layer { target { color: green !important; } } - target { color: red; } - `, - }, - { - title: 'C1 Same specificity, layered !important second', - style: ` - target { color: red; } - @layer { target { color: green !important; } } - `, - }, - { - title: 'D1 Same specificity, all !important', - style: ` - @layer { target { color: green !important; } } - @layer { target { color: red !important; } } - target { color: red !important; } - `, - }, - { - title: 'D2 Same specificity, all !important', - style: ` - @layer { target { color: green !important; } } - target { color: red !important; } - @layer { target { color: red !important; } } - `, - }, - { - title: 'D3 Same specificity, all !important', - style: ` - target { color: red !important; } - @layer { target { color: green !important; } } - @layer { target { color: red !important; } } - `, - }, - { - title: 'D4 Same specificity, all !important', - style: ` - @layer A, B; - @layer B { target { color: red !important; } } - @layer A { target { color: green !important; } } - target { color: red !important; } - `, - }, - { - title: 'E1 Different specificity, all !important', - style: ` - @layer { target { color: green !important; } } - @layer { target { color: red !important; } } - target.first { color: red !important; } - `, - }, - { - title: 'E2 Different specificity, all !important', - style: ` - @layer { target { color: green !important; } } - @layer { target.first { color: red !important; } } - target { color: red !important; } - `, - }, - ]; - for (const testCase of testCases) { - context.test( - testCase['title'], - ({ document, getComputedStyle }) => { - const styleElement = document.createElement('style'); - styleElement.textContent = testCase['style']; - document.head.append(styleElement); - - let targets = document.querySelectorAll('target'); - for (const target of targets) - expect( - getComputedStyle(target).color, - testCase['title'] + ", target '" + target.classList[0] + "'", - ).toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: ` - - -CSS Cascade Layers: !important - - - - - - - - - -
- - - -`, - }, - }, - ); - } - } -} diff --git a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-vs-inline-style.html.ts b/packages/web-platform-tests/src/wpt/css/css-cascade/layer-vs-inline-style.html.ts deleted file mode 100644 index 5bbc96d..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-cascade/layer-vs-inline-style.html.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - { - const testCases = [ - { - title: 'Normal inline style > normal layered style', - style: '@layer { #target { background-color: red; }}', - inlineStyle: 'background-color: green', - }, - { - title: 'Normal inline style < important layered style', - style: '@layer { #target { background-color: green !important; }}', - inlineStyle: 'background-color: red', - }, - { - title: 'Important inline style > normal layered style', - style: '@layer { #target { background-color: red; }}', - inlineStyle: 'background-color: green !important', - }, - { - title: 'Important inline style > important layered style', - style: '@layer { #target { background-color: red !important; }}', - inlineStyle: 'background-color: green !important', - }, - ]; - for (const testCase of testCases) { - context.test( - testCase['title'], - ({ document, getComputedStyle }) => { - const target = document.getElementById('target')!, - reference = document.getElementById('reference')!; - var documentStyle = document.createElement('style'); - documentStyle.appendChild(document.createTextNode(testCase['style'])); - document.head.appendChild(documentStyle); - - (target as unknown as { style: string }).style = testCase['inlineStyle']; - - expect(getComputedStyle(target).backgroundColor).toBe( - getComputedStyle(reference).backgroundColor, - ); - }, - { - document: { - contentType: 'text/html', - content: ` - - - - - - -
-
- - -`, - }, - }, - ); - } - } -} diff --git a/packages/web-platform-tests/src/wpt/css/css-cascade/unset-value-storage.html.ts b/packages/web-platform-tests/src/wpt/css/css-cascade/unset-value-storage.html.ts deleted file mode 100644 index e77b66d..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-cascade/unset-value-storage.html.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Storage of "unset" value', - ({ document }) => { - let properties = ['color', 'border', 'border-left', 'border-color', 'border-right-style']; - let style = (document.styleSheets[0]!.cssRules[0] as CSSStyleRule).style; - for (let prop of properties) { - expect(style.getPropertyValue(prop), `${prop} is expected to be "unset"`).toBe('unset'); - } - }, - { - document: { - contentType: 'text/html', - content: ` - -Storage of "unset" value - - - - - - -
-\x20\x20 -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/css-variables/variable-cycles.html.ts b/packages/web-platform-tests/src/wpt/css/css-variables/variable-cycles.html.ts deleted file mode 100644 index 57ca7eb..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-variables/variable-cycles.html.ts +++ /dev/null @@ -1,144 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - for (const [declarations, expected_invalid, expected_valid, description] of [ - [['--a:var(--a)'], ['--a'], [], 'Self-cycle'], - [['--a:var(--b)', '--b:var(--a)'], ['--a', '--b'], [], 'Simple a/b cycle'], - [ - ['--a:var(--b, cycle)', '--b:var(--c, cycle)', '--c:var(--a, cycle)'], - ['--a', '--b', '--c'], - [], - 'Three-var cycle', - ], - [ - [ - '--x:var(--y, valid)', - '--y:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle)', - '--c:var(--a, cycle)', - ], - ['--a', '--b', '--c'], - ['--x', '--y'], - 'Cycle that starts in the middle of a chain', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle)', - '--c:var(--a, cycle) var(--y)', - '--y:valid', - ], - ['--a', '--b', '--c'], - ['--x', '--y'], - 'Cycle with extra edge', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle) var(--y)', - '--c:var(--a, cycle)', - '--y:valid', - ], - ['--a', '--b', '--c'], - ['--x', '--y'], - 'Cycle with extra edge (2)', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle)', - '--c:var(--a, cycle) var(--y)', - '--y:var(--z)', - '--z:valid', - ], - ['--a', '--b', '--c'], - ['--x', '--y', '--z'], - 'Cycle with extra edge (3)', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle) var(--a, cycle)', - '--c:var(--d, cycle)', - '--d:var(--b, cycle)', - ], - ['--a', '--b', '--c', '--d'], - ['--x'], - 'Cycle with secondary cycle', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle)', - '--b:var(--c, cycle)', - '--c:var(--d, cycle) var(--a, cycle)', - '--d:var(--b, cycle) var(--y)', - '--y:valid', - ], - ['--a', '--b', '--c', '--d'], - ['--x', '--y'], - 'Cycle with overlapping secondary cycle', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--b, cycle) var(--y, valid) var(--c, cycle)', - '--b:var(--a, cycle) ', - '--c:var(--d, cycle)', - '--d:var(--a, cycle)', - '--y:valid', - ], - ['--a', '--b', '--c', '--d'], - ['--x', '--y'], - 'Cycle with deeper secondary cycle', - ], - [ - [ - '--x:var(--a, valid)', - '--a:var(--y, var(--b, cycle))', - '--b:var(--y, var(--c, cycle))', - '--c:var(--y, var(--a, cycle))', - '--y:valid', - ], - [], - ['--a', '--b', '--c', '--x', '--y'], - 'Cycle in unused fallback', - ], - ] as [string[], string[], string[], string][]) { - context.test( - description, - ({ document, getComputedStyle }) => { - const main = document.getElementById('main')!; - - let element = document.createElement('div'); - - try { - declarations.push('--sanity:valid'); - (element as unknown as { style: string }).style = declarations.join(';'); - main.append(element); - let cs = getComputedStyle(element); - - for (let e of expected_invalid) expect(cs.getPropertyValue(e), `${e}`).toBe(''); - for (let e of expected_valid) expect(cs.getPropertyValue(e), `${e}`).not.toBe(''); - - expect(cs.getPropertyValue('--sanity'), '--sanity').toBe('valid'); - } finally { - element.remove(); - } - }, - { - document: { - contentType: 'text/html', - content: - '\n\nTest that custom property cycles behave correctly\n\n\n\n
\n\n', - }, - }, - ); - } -} diff --git a/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-cssom.html.ts b/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-cssom.html.ts deleted file mode 100644 index 2218ce1..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-cssom.html.ts +++ /dev/null @@ -1,94 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup1 = ` - - - CSS variable references - via CSSOM - - - -\x20\x20\x20\x20 - -\x20\x20\x20\x20 - -\x20\x20\x20\x20 -\x20\x20\x20\x20 - - - -
-
- - - - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Verify correct results using CSSOM', - ({ document }) => { - let target = document.getElementById('target1')!; - - target.style.setProperty('background-color', 'var(--prop)'); - expect( - target.style.backgroundColor, - 'background-color property value after calling setProperty', - ).toBe('var(--prop)'); - expect( - target.style.getPropertyValue('background-color'), - "getPropertyValue('background-color') after calling setProperty", - ).toBe('var(--prop)'); - - target.style.removeProperty('background-color'); - expect( - target.style.backgroundColor, - 'background-color property value after calling removeProperty', - ).toBe(''); - expect( - target.style.getPropertyValue('background-color'), - "getPropertyValue('background-color') after calling removeProperty", - ).toBe(''); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - 'Verify correct results with CSSOM overriding markup-set values', - ({ document }) => { - let target = document.getElementById('target1')!; - - target.style.setProperty('background-color', 'var(--prop)'); - expect( - target.style.backgroundColor, - 'background-color property value after calling setProperty', - ).toBe('var(--prop)'); - expect( - target.style.getPropertyValue('background-color'), - "getPropertyValue('background-color') after calling setProperty", - ).toBe('var(--prop)'); - - target.style.removeProperty('background-color'); - expect( - target.style.backgroundColor, - 'background-color property value after calling removeProperty', - ).toBe(''); - expect( - target.style.getPropertyValue('background-color'), - "getPropertyValue('background-color') after calling removeProperty", - ).toBe(''); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-shorthands-cssom.html.ts b/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-shorthands-cssom.html.ts deleted file mode 100644 index b6ad135..0000000 --- a/packages/web-platform-tests/src/wpt/css/css-variables/variable-reference-shorthands-cssom.html.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'CSS variable references - shorthand properties - via CSSOM', - ({ document }) => { - let target = document.getElementById('target')!; - - target.style.setProperty('margin', 'var(--prop)'); - expect(target.style.margin, 'margin property value after calling setProperty').toBe( - 'var(--prop)', - ); - expect( - target.style.getPropertyValue('margin'), - "getPropertyValue('margin') after calling setProperty", - ).toBe('var(--prop)'); - - target.style.removeProperty('margin'); - expect(target.style.margin, 'margin property value after calling removeProperty').toBe(''); - expect( - target.style.getPropertyValue('margin'), - "getPropertyValue('margin') after calling removeProperty", - ).toBe(''); - }, - { - document: { - contentType: 'text/html', - content: ` - - - CSS variable references - shorthand properties - via CSSOM - - - -\x20\x20\x20\x20 -\x20\x20\x20\x20 - -\x20\x20\x20\x20 -\x20\x20\x20\x20 - - - -
- - - - - -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleDeclaration-indexed-properties.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleDeclaration-indexed-properties.html.ts deleted file mode 100644 index d54286b..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleDeclaration-indexed-properties.html.ts +++ /dev/null @@ -1,128 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'indexed access returns property names in insertion order', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.setProperty('color', 'red'); - div.style.setProperty('background-color', 'blue'); - - expect(div.style[0]).toBe('color'); - expect(div.style[1]).toBe('background-color'); - expect(div.style[2]).toBe(undefined); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); - context.test( - 'indexed access works after setting cssText', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.cssText = 'margin-top: 5px; padding: 10px'; - - expect(div.style[0]).toBe('margin-top'); - expect(div.style[1]).toBe('padding-top'); - expect(div.style[2]).toBe('padding-right'); - expect(div.style[3]).toBe('padding-bottom'); - expect(div.style[4]).toBe('padding-left'); - expect(div.style[div.style.length]).toBe(undefined); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); - context.test( - 'indexed access updates after removeProperty', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.cssText = 'color: red; background-color: blue'; - div.style.removeProperty('color'); - - expect(div.style.length).toBe(1); - expect(div.style[0]).toBe('background-color'); - expect(div.style[1]).toBe(undefined); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); - context.test( - 'indexed access on empty style returns undefined', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.cssText = ''; - - expect(div.style.length).toBe(0); - expect(div.style[0]).toBe(undefined); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); - context.test( - 'in operator works for indexed properties', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.cssText = 'color: red'; - - expect('1' in div.style).toBe(false); - expect('0' in div.style).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); - context.test( - 'indexed properties are enumerable', - ({ document }) => { - const div = document.getElementById('div')!; - - div.style.cssText = 'color: red; background-color: blue'; - - const keys = []; - for (const key in div.style) { - if (key === '0' || key === '1') { - keys.push(key); - } - } - expect(keys.length).toBe(2); - expect(keys[0]).toBe('0'); - expect(keys[1]).toBe('1'); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleDeclaration indexed property access\n\n\n\n\n
\n\n', - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-invalidation.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-invalidation.html.ts deleted file mode 100644 index bee8fe2..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-invalidation.html.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup2 = ` - -CSSStyleSheet rule mutation invalidation - - - - -Should be green. -Should be green. - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'mutating constructed CSSStyleSheet applied to root invalidates styles', - async ({ document, CSSStyleSheet, getComputedStyle, cleanup }) => { - const span1 = document.getElementById('span1')!, - span2 = document.getElementById('span2')!; - - const sheet = new CSSStyleSheet(); - sheet.replaceSync('span {color:var(--color, red);}'); - document.adoptedStyleSheets = [sheet]; - cleanup(() => { - document.adoptedStyleSheets = []; - }); - expect(getComputedStyle(span1).color, 'Sheet should apply').toBe('rgb(255, 0, 0)'); - (sheet.rules[0] as CSSStyleRule).style.setProperty('--color', 'green'); - expect(getComputedStyle(span1).color, 'Sheet should invalidate style').toBe('rgb(0, 128, 0)'); - document.adoptedStyleSheets = []; - expect(getComputedStyle(span1).color, 'Removing sheet should apply').toBe('rgb(0, 0, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'mutating constructed CSSStyleSheet applied to shadowdom invalidates styles', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const span1 = document.getElementById('span1')!, - span2 = document.getElementById('span2')!; - - span1.attachShadow({ mode: 'open' }); - span1.shadowRoot!.append(document.createElement('slot')); - const sheet = new CSSStyleSheet(); - sheet.replaceSync(':host {color:var(--color, red);}'); - span1.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(span1).color, 'Sheet should apply').toBe('rgb(255, 0, 0)'); - (sheet.rules[0] as CSSStyleRule).style.setProperty('--color', 'green'); - expect(getComputedStyle(span1).color, 'Sheet should invalidate style').toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'mutating dependent constructed CSSStyleSheet applied to shadowdom invalidates styles', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const span1 = document.getElementById('span1')!, - span2 = document.getElementById('span2')!; - - span2.attachShadow({ mode: 'open' }); - span2.shadowRoot!.append(document.createElement('slot')); - const sheet1 = new CSSStyleSheet(); - const sheet2 = new CSSStyleSheet(); - sheet1.replaceSync(':host {color:var(--color, hotpink);}'); - sheet2.replaceSync(':host {--color: blue}'); - const style2 = (sheet2.rules[0] as CSSStyleRule).style; - span2.shadowRoot!.adoptedStyleSheets = [sheet1, sheet2]; - expect(getComputedStyle(span2).color, 'Sheet should apply').toBe('rgb(0, 0, 255)'); - style2.setProperty('--color', 'green'); - expect(getComputedStyle(span2).color, 'Sheet should invalidate style').toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-replace-cssRules.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-replace-cssRules.html.ts deleted file mode 100644 index adeddff..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable-replace-cssRules.html.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - for (const sync of [true, false]) { - context.test( - `cssRules tests (sync: ${sync})`, - async ({ document, CSSStyleSheet, getComputedStyle }) => { - let sheet = new CSSStyleSheet(); - let rules = sheet.cssRules; - function replace(text: string) { - return sync ? sheet.replaceSync(text) : sheet.replace(text); - } - function assert_color(color: string) { - expect(sheet.cssRules, 'StyleSheet.cssRules is [SameObject]').toBe(rules); - expect(rules.length, 'Should have one rule').toBe(1); - expect((rules[0] as CSSStyleRule).style.color, 'Should be the right css rule').toBe( - color, - ); - } - async function replace_and_test(color: string) { - await replace(`p { color: ${color} }`); - expect(sheet.cssRules, 'StyleSheet.cssRules is [SameObject]').toBe(rules); - expect(rules.length, 'Should have one rule').toBe(1); - expect((rules[0] as CSSStyleRule).style.color, 'Should be the right css rule').toBe( - color, - ); - } - - await replace_and_test('red'); - await replace_and_test('green'); - document.adoptedStyleSheets.push(sheet); - expect(getComputedStyle(document.querySelector('p')!).color, 'Sheet should apply').toBe( - 'rgb(0, 128, 0)', - ); - (document.adoptedStyleSheets.pop as (...args: unknown[]) => CSSStyleSheet | undefined)( - sheet, - ); - expect( - getComputedStyle(document.querySelector('p')!).color, - 'Sheet should stop applying', - ).not.toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: - '\n\nCSSStyleSheet.replace reflects the right cssRules.\n\n\n\n\n\n\n

\n\n', - }, - }, - ); - } -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable.html.ts deleted file mode 100644 index 2c3b296..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet-constructable.html.ts +++ /dev/null @@ -1,1107 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup1 = ` -CSSStyleSheet constructor and adoptedStyleSheets - - - - - -
-
- - - - - -
-
-
-
- - - -
-
- - -`; - -function prepare(document: Document, CSSStyleSheet: typeof globalThis.CSSStyleSheet) { - const greenStyleText = '.green { color: green; }'; - const redStyleTexts = ['.red { color: red; }', '.red + span + span { color: red; }']; - const blueStyleTexts = ['.blue { color: blue; }', '.blue + span + span { color: blue; }']; - const whiteStyleText = '* { color: white; }'; - const yellowStyleText = '.yellow { color: yellow; }'; - - const firstDiv = document.querySelector('#firstSection > div')! as HTMLElement; - const secondDiv = firstDiv.cloneNode(true) as HTMLElement as HTMLElement; - const shadowHost = document.querySelector('#shadowHost')!; - const shadowRoot = shadowHost.attachShadow({ mode: 'open' }); - shadowRoot.appendChild(secondDiv); - - const greenSpan = firstDiv.children[0]!; - const redSpan = firstDiv.children[1]!; - const blueSpan = firstDiv.children[2]!; - const whiteSpan = firstDiv.children[3]!; - const yellowSpan = firstDiv.children[4]!; - const greenShadowSpan = secondDiv.children[0]!; - const redShadowSpan = secondDiv.children[1]!; - const blueShadowSpan = secondDiv.children[2]!; - const whiteShadowSpan = secondDiv.children[3]!; - const yellowShadowSpan = secondDiv.children[4]!; - - const thirdSection = document.getElementById('thirdSection')!; - const divNonConstructed = document.getElementById('divNonConstructed')!; - const shadowRootNonConstructed = divNonConstructed.attachShadow({ mode: 'open' }); - const nonConstructedStyle = document.createElement('style'); - shadowRootNonConstructed.appendChild(nonConstructedStyle); - nonConstructedStyle.sheet!.insertRule('.nonConstructed { color: red; }', 0); - const nonConstructedStyleSheet = nonConstructedStyle.sheet!; - - function createAllSheetsPromise() { - const greenSheet = new CSSStyleSheet(); - const redSheet = new CSSStyleSheet({ media: 'screen, print' }); - const blueSheet = new CSSStyleSheet({ disabled: true }); - const whiteSheet = new CSSStyleSheet({ disabled: true }); - const yellowSheet = new CSSStyleSheet({ disabled: false }); - - const greenPromise = greenSheet.replace(greenStyleText); - const redPromise = redSheet.replace(redStyleTexts[0]! + redStyleTexts[1]!); - const bluePromise = blueSheet.replace(blueStyleTexts[0]! + blueStyleTexts[1]!); - const whitePromise = whiteSheet.replace(whiteStyleText); - const yellowPromise = yellowSheet.replace(yellowStyleText); - return [greenPromise, redPromise, bluePromise, whitePromise, yellowPromise] as const; - } - - function attachShadowDiv(host: HTMLElement) { - const shadowRoot = host.attachShadow({ mode: 'open' }); - const shadowDiv = document.createElement('div'); - shadowRoot.appendChild(shadowDiv); - return shadowDiv; - } - - const import_text = '@import url("support/constructable-import.css");'; - return { - greenStyleText, - redStyleTexts, - blueStyleTexts, - whiteStyleText, - yellowStyleText, - firstDiv, - secondDiv, - shadowHost, - shadowRoot, - greenSpan, - redSpan, - blueSpan, - whiteSpan, - yellowSpan, - greenShadowSpan, - redShadowSpan, - blueShadowSpan, - whiteShadowSpan, - yellowShadowSpan, - thirdSection, - divNonConstructed, - nonConstructedStyleSheet, - createAllSheetsPromise, - attachShadowDiv, - import_text, - }; -} - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'document.adoptedStyleSheets should initially have length 0.', - ({ document }) => { - const redStyleTexts = ['.red { color: red; }', '.red + span + span { color: red; }'] as const; - - expect(document.adoptedStyleSheets.length).toBe(0); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - 'new CSSStyleSheet produces empty CSSStyleSheet', - ({ CSSStyleSheet }) => { - const redStyleTexts = ['.red { color: red; }', '.red + span + span { color: red; }'] as const; - - const sheet = new CSSStyleSheet({ disabled: true, media: 'screen, print' }); - expect( - sheet.title, - 'The title attribute must return the title or null if title is the empty string', - ).toBe(null); - expect(sheet.ownerNode).toBe(null); - expect(sheet.ownerRule).toBe(null); - expect(sheet.media.length).toBe(2); - expect(sheet.media.item(0)).toBe('screen'); - expect(sheet.media.item(1)).toBe('print'); - expect(sheet.disabled).toBe(true); - expect(sheet.cssRules.length).toBe(0); - - sheet.insertRule(redStyleTexts[0]); - expect(sheet.cssRules.length).toBe(1); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[0]); - - sheet.insertRule(redStyleTexts[1]); - expect(sheet.cssRules.length).toBe(2); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[1]); - - const sheet2 = new CSSStyleSheet({}); - expect( - sheet2.title, - 'The title attribute must return the title or null if title is the empty string', - ).toBe(null); - expect(sheet2.ownerNode).toBe(null); - expect(sheet2.ownerRule).toBe(null); - expect(sheet2.media.length).toBe(0); - expect(sheet2.disabled).toBe(false); - expect(sheet2.cssRules.length).toBe(0); - - sheet2.insertRule(redStyleTexts[1]); - expect(sheet2.cssRules.length).toBe(1); - expect(sheet2.cssRules[0]!.cssText).toBe(redStyleTexts[1]); - - sheet2.deleteRule(0); - expect(sheet2.cssRules.length).toBe(0); - - const sheet3 = new CSSStyleSheet(); - expect( - sheet3.title, - 'The title attribute must return the title or null if title is the empty string', - ).toBe(null); - expect(sheet3.ownerNode).toBe(null); - expect(sheet3.ownerRule).toBe(null); - expect(sheet3.media.length).toBe(0); - expect(sheet3.disabled).toBe(false); - expect(sheet3.cssRules.length).toBe(0); - - sheet3.insertRule(redStyleTexts[1]); - expect(sheet3.cssRules.length).toBe(1); - expect(sheet3.cssRules[0]!.cssText).toBe(redStyleTexts[1]); - - sheet3.deleteRule(0); - expect(sheet3.cssRules.length).toBe(0); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - 'title can be set in the CSSStyleSheet constructor', - ({ CSSStyleSheet }) => { - const redStyleTexts = ['.red { color: red; }', '.red + span + span { color: red; }'] as const; - - const sheet = new CSSStyleSheet({ title: 'something' } as CSSStyleSheetInit); - expect( - sheet.title, - 'title and alternate are not supported by the constructor. https://github.com/WICG/construct-stylesheets/issues/105', - ).toBe(null); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - 'CSSStyleSheet.replace produces Promise', - async ({ CSSStyleSheet }) => { - const redStyleTexts = ['.red { color: red; }', '.red + span + span { color: red; }'] as const; - - const sheet = new CSSStyleSheet({ disabled: true, media: 'screen, print' }); - const promise_sheet = sheet.replace(redStyleTexts[0]); - return promise_sheet.then(function (sheet) { - expect( - sheet.title, - 'The title attribute must return the title or null if title is the empty string', - ).toBe(null); - expect(sheet.ownerNode).toBe(null); - expect(sheet.ownerRule).toBe(null); - expect(sheet.media.length).toBe(2); - expect(sheet.media.item(0)).toBe('screen'); - expect(sheet.media.item(1)).toBe('print'); - expect(sheet.disabled).toBe(true); - expect(sheet.cssRules.length).toBe(1); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[0]); - - sheet.insertRule(redStyleTexts[1]); - expect(sheet.cssRules.length).toBe(2); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[1]); - }); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - - context.test( - 'Constructed style sheets can be applied on document', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { greenSpan, redSpan, blueSpan, whiteSpan, yellowSpan, createAllSheetsPromise } = - prepare(document, CSSStyleSheet); - - return Promise.all(createAllSheetsPromise()).then((values) => { - const greenStyleSheet = values[0]!; - const redStyleSheet = values[1]!; - const blueStyleSheet = values[2]!; - const whiteStyleSheet = values[3]!; - const yellowStyleSheet = values[4]!; - - // Lists of style sheets can be created, assigned and read. - - // disabled stylesheets aren't applied - document.adoptedStyleSheets = [whiteStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - // disable dsheets don't block other styles from applying - document.adoptedStyleSheets = [greenStyleSheet, blueStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - document.adoptedStyleSheets = [redStyleSheet, yellowStyleSheet]; - - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(255, 255, 0)'); - - document.adoptedStyleSheets = [ - redStyleSheet, - yellowStyleSheet, - greenStyleSheet, - blueStyleSheet, - ]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(255, 255, 0)'); - document.adoptedStyleSheets = []; - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Constructed style sheets can be applied on shadow root', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { - shadowRoot, - greenShadowSpan, - redShadowSpan, - blueShadowSpan, - whiteShadowSpan, - yellowShadowSpan, - createAllSheetsPromise, - } = prepare(document, CSSStyleSheet); - - return Promise.all(createAllSheetsPromise()).then((values) => { - const greenStyleSheet = values[0]!; - const redStyleSheet = values[1]!; - const blueStyleSheet = values[2]!; - const whiteStyleSheet = values[3]!; - const yellowStyleSheet = values[4]!; - shadowRoot.adoptedStyleSheets = [whiteStyleSheet]; - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(0, 0, 0)'); - - shadowRoot.adoptedStyleSheets = [greenStyleSheet, blueStyleSheet]; - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(0, 0, 0)'); - - shadowRoot.adoptedStyleSheets = [redStyleSheet, yellowStyleSheet]; - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(255, 255, 0)'); - - shadowRoot.adoptedStyleSheets = [ - redStyleSheet, - yellowStyleSheet, - greenStyleSheet, - blueStyleSheet, - ]; - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(255, 255, 0)'); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Re-attaching shadow host with adopted stylesheets work', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowHost, shadowRoot, greenShadowSpan, redShadowSpan, createAllSheetsPromise } = - prepare(document, CSSStyleSheet); - - return Promise.all(createAllSheetsPromise()).then((values) => { - const greenStyleSheet = values[0]!; - const redStyleSheet = values[1]!; - shadowRoot.adoptedStyleSheets = [greenStyleSheet]; - expect(getComputedStyle(greenShadowSpan).color, 'Style applies connected').toBe( - 'rgb(0, 128, 0)', - ); - expect(getComputedStyle(redShadowSpan).color, 'Style applies when connected').toBe( - 'rgb(0, 0, 0)', - ); - let hostParent = shadowHost.parentNode!; - hostParent.removeChild(shadowHost); - expect(getComputedStyle(greenShadowSpan).color, "Style doesn't apply when detached").toBe( - '', - ); - expect(getComputedStyle(redShadowSpan).color, "Style doesn't apply when detached").toBe(''); - shadowRoot.adoptedStyleSheets = [redStyleSheet, greenStyleSheet]; - hostParent.appendChild(shadowHost); - expect(getComputedStyle(greenShadowSpan).color, 'Style applies after reattach').toBe( - 'rgb(0, 128, 0)', - ); - expect(getComputedStyle(redShadowSpan).color, 'Style applies after reattach').toBe( - 'rgb(255, 0, 0)', - ); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Attaching a shadow root that already has adopted stylesheets work', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const {} = prepare(document, CSSStyleSheet); - - const sheet = new CSSStyleSheet(); - sheet.replaceSync(':host { color: red; }'); - const host = document.createElement('div'); - let sr = host.attachShadow({ mode: 'open' }); - sr.adoptedStyleSheets = [sheet]; - document.body.appendChild(host); - expect(getComputedStyle(host).color, 'Style applies when connected').toBe('rgb(255, 0, 0)'); - sheet.replaceSync(':host { color: blue; }'); - expect(getComputedStyle(host).color, 'Style update applies when connected').toBe( - 'rgb(0, 0, 255)', - ); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Re-attaching shadow host and updating attributes work', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const {} = prepare(document, CSSStyleSheet); - - const sheet = new CSSStyleSheet(); - sheet.replaceSync(':host([red]) { color: red; } :host(.blue) { color: blue; }'); - const host = document.createElement('div'); - host.toggleAttribute('red'); - document.body.appendChild(host); - expect(getComputedStyle(host).color, 'No style applies yet').toBe('rgb(0, 0, 0)'); - - let sr = host.attachShadow({ mode: 'open' }); - sr.adoptedStyleSheets = [sheet]; - - expect(getComputedStyle(host).color, 'Style applies after adding style').toBe( - 'rgb(255, 0, 0)', - ); - document.body.removeChild(host); - document.body.appendChild(host); - expect(getComputedStyle(host).color, 'Style applies after reattachment').toBe( - 'rgb(255, 0, 0)', - ); - host.toggleAttribute('red'); - expect( - getComputedStyle(host).color, - 'Attribute updates to the element after reattachment apply', - ).toBe('rgb(0, 0, 0)'); - host.classList.toggle('blue'); - expect( - getComputedStyle(host).color, - 'Class updates to the element after reattachment apply', - ).toBe('rgb(0, 0, 255)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Changes to constructed stylesheets through CSSOM is reflected', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { redStyleTexts, greenSpan, redSpan, blueSpan, whiteSpan, yellowSpan } = prepare( - document, - CSSStyleSheet, - ); - - const plainSheet = new CSSStyleSheet(); - const redStyleSheetPromise = plainSheet.replace(redStyleTexts[0]!); - return redStyleSheetPromise.then(function (redStyleSheet) { - document.adoptedStyleSheets = [redStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - redStyleSheet.insertRule(redStyleTexts[1]!); - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - redStyleSheet.deleteRule(1); - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - (redStyleSheet.cssRules[0]! as CSSStyleRule).style.color = 'white'; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 255, 255)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Constructed stylesheet can be used and modified in multiple TreeScopes', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { - redStyleTexts, - shadowRoot, - greenSpan, - redSpan, - blueSpan, - whiteSpan, - yellowSpan, - greenShadowSpan, - redShadowSpan, - blueShadowSpan, - whiteShadowSpan, - yellowShadowSpan, - } = prepare(document, CSSStyleSheet); - - const plainSheet = new CSSStyleSheet(); - const redStyleSheetPromise = plainSheet.replace(redStyleTexts[0]!); - return redStyleSheetPromise.then(function (redStyleSheet) { - document.adoptedStyleSheets = [redStyleSheet]; - shadowRoot.adoptedStyleSheets = [redStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(0, 0, 0)'); - - shadowRoot.adoptedStyleSheets[0]!.insertRule(redStyleTexts[1]!); - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - expect(getComputedStyle(greenShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueShadowSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteShadowSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowShadowSpan).color).toBe('rgb(0, 0, 0)'); - document.adoptedStyleSheets = []; - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Stylesheets constructed on the main Document cannot be used in iframes', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { redStyleTexts, firstDiv, greenSpan, redSpan, blueSpan, whiteSpan, yellowSpan } = - prepare(document, CSSStyleSheet); - - const iframe = document.createElement('iframe'); - document.body.appendChild(iframe); - const thirdDiv = firstDiv.cloneNode(true) as HTMLElement; - iframe.contentDocument!.body.appendChild(thirdDiv); - const greenIframeSpan = thirdDiv.children[0]!; - const redIframeSpan = thirdDiv.children[1]!; - const blueIframeSpan = thirdDiv.children[2]!; - const whiteIframeSpan = thirdDiv.children[3]!; - const yellowIframeSpan = thirdDiv.children[4]!; - - const plainSheet = new CSSStyleSheet(); - const redStyleSheetPromise = plainSheet.replace(redStyleTexts[0]!); - return redStyleSheetPromise.then(function (redStyleSheet) { - expect(() => { - iframe.contentDocument!.adoptedStyleSheets = [redStyleSheet]; - }).toThrow( - expect.objectContaining({ - name: 'NotAllowedError', - code: 0, - constructor: (iframe.contentWindow as Window & typeof globalThis).DOMException, - }), - ); - expect(getComputedStyle(greenIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowIframeSpan).color).toBe('rgb(0, 0, 0)'); - - document.adoptedStyleSheets = [redStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - document.adoptedStyleSheets[0]!.insertRule(redStyleTexts[1]!); - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Stylesheet constructed on iframe cannot be used in the main Document', - async ({ document, CSSStyleSheet, getComputedStyle, DOMException }) => { - const { redStyleTexts, firstDiv, greenSpan, redSpan, blueSpan, whiteSpan, yellowSpan } = - prepare(document, CSSStyleSheet); - - const iframe = document.createElement('iframe'); - const iframeLoaded = new Promise((resolve) => iframe.addEventListener('load', resolve)); - document.body.appendChild(iframe); - await iframeLoaded; - const thirdDiv = firstDiv.cloneNode(true) as HTMLElement; - iframe.contentDocument!.body.appendChild(thirdDiv); - const greenIframeSpan = thirdDiv.children[0]!; - const redIframeSpan = thirdDiv.children[1]!; - const blueIframeSpan = thirdDiv.children[2]!; - const whiteIframeSpan = thirdDiv.children[3]!; - const yellowIframeSpan = thirdDiv.children[4]!; - - // Make sure both the main Document and the iframe are not styled - const emptyStyleSheet = new CSSStyleSheet(); - document.adoptedStyleSheets = [emptyStyleSheet]; - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - expect(getComputedStyle(greenIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowIframeSpan).color).toBe('rgb(0, 0, 0)'); - - const iframePlainSheet = new ( - iframe.contentWindow as Window & typeof globalThis - ).CSSStyleSheet(); - const iframeRedStyleSheetPromise = iframePlainSheet.replace(redStyleTexts[0]!); - return iframeRedStyleSheetPromise.then(function (iframeRedStyleSheet) { - expect(() => { - document.adoptedStyleSheets = [iframeRedStyleSheet]; - }).toThrow( - expect.objectContaining({ name: 'NotAllowedError', code: 0, constructor: DOMException }), - ); - expect(getComputedStyle(greenSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(blueSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowSpan).color).toBe('rgb(0, 0, 0)'); - - iframe.contentDocument!.adoptedStyleSheets = [iframeRedStyleSheet]; - expect(getComputedStyle(greenIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redIframeSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(yellowIframeSpan).color).toBe('rgb(0, 0, 0)'); - - iframe.contentDocument!.adoptedStyleSheets[0]!.insertRule(redStyleTexts[1]!); - expect(getComputedStyle(greenIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(redIframeSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(blueIframeSpan).color).toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(whiteIframeSpan).color).toBe('rgb(255, 0, 0)'); - expect(getComputedStyle(yellowIframeSpan).color).toBe('rgb(0, 0, 0)'); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Adding non-constructed stylesheet to AdoptedStyleSheets is not allowed when the owner document of the stylesheet is in the same document tree as the AdoptedStyleSheets', - ({ document, CSSStyleSheet, getComputedStyle, DOMException }) => { - const { divNonConstructed, nonConstructedStyleSheet } = prepare(document, CSSStyleSheet); - - expect(getComputedStyle(divNonConstructed).color).toBe('rgb(0, 0, 0)'); - expect(() => { - document.adoptedStyleSheets = [nonConstructedStyleSheet]; - }).toThrow( - expect.objectContaining({ name: 'NotAllowedError', code: 0, constructor: DOMException }), - ); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Adding non-constructed stylesheet to AdoptedStyleSheets is not allowed when the owner document of the stylesheet and the AdoptedStyleSheets are in different document trees', - ({ document, CSSStyleSheet, getComputedStyle, DOMException }) => { - const { divNonConstructed, nonConstructedStyleSheet } = prepare(document, CSSStyleSheet); - - const iframe = document.createElement('iframe'); - document.body.appendChild(iframe); - const iframeDiv = iframe.contentDocument!.createElement('div'); - iframeDiv.classList.add('nonConstructed'); - iframe.contentDocument!.body.appendChild(iframeDiv); - - expect(getComputedStyle(iframeDiv).color).toBe('rgb(0, 0, 0)'); - expect(() => { - iframe.contentDocument!.adoptedStyleSheets = [nonConstructedStyleSheet]; - }).toThrow( - expect.objectContaining({ - name: 'NotAllowedError', - code: 0, - constructor: (iframe.contentWindow as Window & typeof globalThis).DOMException, - }), - ); - expect(getComputedStyle(iframeDiv).color).toBe('rgb(0, 0, 0)'); - - const iframeStyle = iframe.contentDocument!.createElement('style'); - iframe.contentDocument!.body.appendChild(iframeStyle); - iframeStyle.sheet!.insertRule('.nonConstructedSpan { color: red; }'); - const iframeStyleSheet = iframeStyle.sheet!; - const nonConstructedSpan = document.createElement('span'); - nonConstructedSpan.classList.add('.nonConstructedSpan'); - divNonConstructed.appendChild(nonConstructedSpan); - - expect(getComputedStyle(iframeDiv).color).toBe('rgb(0, 0, 0)'); - expect(() => { - document.adoptedStyleSheets = [iframeStyleSheet]; - }).toThrow( - expect.objectContaining({ name: 'NotAllowedError', code: 0, constructor: DOMException }), - ); - expect(getComputedStyle(iframeDiv).color).toBe('rgb(0, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replaceSync replaces stylesheet text synchronously', - ({ document, CSSStyleSheet }) => { - const { redStyleTexts } = prepare(document, CSSStyleSheet); - - const sheet = new CSSStyleSheet(); - expect(sheet.cssRules.length).toBe(0); - - sheet.replaceSync(redStyleTexts[0]!); - expect(sheet.cssRules.length).toBe(1); - expect(redStyleTexts[0]!).toBe(sheet.cssRules[0]!.cssText); - - sheet.replaceSync(redStyleTexts[1]!); - expect(sheet.cssRules.length).toBe(1); - expect(redStyleTexts[1]!).toBe(sheet.cssRules[0]!.cssText); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replaceSync correctly updates the style of its adopters synchronously', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { redStyleTexts, shadowRoot, thirdSection, attachShadowDiv } = prepare( - document, - CSSStyleSheet, - ); - - // Attach a div inside a shadow root with the class ".red". - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - shadowDiv.classList.add('red'); - // Create empty stylesheet. - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - // Replace the stylesheet text that will color it red. - sheet.replaceSync(redStyleTexts[0]!); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(255, 0, 0)'); - expect(sheet.cssRules.length).toBe(1); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[0]!); - sheet.insertRule(redStyleTexts[1]!); - expect(sheet.cssRules.length).toBe(2); - expect(sheet.cssRules[0]!.cssText).toBe(redStyleTexts[1]!); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Adopted sheets are ordered after non-adopted sheets in the shadow root', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv } = prepare(document, CSSStyleSheet); - - // Attach a div inside a shadow root with the class ".red". - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - shadowDiv.classList.add('target'); - - // Create empty stylesheet. - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - - // Replace the stylesheet text that will color it red. - sheet.replaceSync('.target { color: red; }'); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(255, 0, 0)'); - - // Create a style element that will set colors to white. - const style = document.createElement('style'); - style.textContent = '.target { color: white; }'; - span.shadowRoot!.appendChild(style); - expect( - getComputedStyle(shadowDiv).color, - 'non-adopted styles should be ordered before adopted styles', - ).toBe('rgb(255, 0, 0)'); - - span.shadowRoot!.adoptedStyleSheets = []; - expect( - getComputedStyle(shadowDiv).color, - 'with no adopted styles in conflict, the non-adopted style should take effect', - ).toBe('rgb(255, 255, 255)'); - - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect( - getComputedStyle(shadowDiv).color, - 'the adopted style should be ordered after the non-adopted style', - ).toBe('rgb(255, 0, 0)'); - - sheet.disabled = true; - expect( - getComputedStyle(shadowDiv).color, - 'with the adopted sheet disabled, the non-adopted style should take effect', - ).toBe('rgb(255, 255, 255)'); - - sheet.disabled = false; - expect( - getComputedStyle(shadowDiv).color, - 'the adopted sheet re-enabled, it should take effect again', - ).toBe('rgb(255, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Adopted sheets are ordered after non-adopted sheets in the document', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { thirdSection } = prepare(document, CSSStyleSheet); - - // Attach a div inside a shadow root with the class ".red". - const span = document.createElement('span'); - thirdSection.appendChild(span); - span.classList.add('target'); - - // Create empty stylesheet. - const sheet = new CSSStyleSheet(); - document.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(span).color).toBe('rgb(0, 0, 0)'); - - // Replace the stylesheet text that will color it red. - sheet.replaceSync('.target { color: red; }'); - expect(getComputedStyle(span).color).toBe('rgb(255, 0, 0)'); - - // Create a style element that will set colors to white. - const style = document.createElement('style'); - style.textContent = '.target { color: white; }'; - span.appendChild(style); - expect( - getComputedStyle(span).color, - 'non-adopted styles should be ordered before adopted styles', - ).toBe('rgb(255, 0, 0)'); - - document.adoptedStyleSheets = []; - expect( - getComputedStyle(span).color, - 'with no adopted styles in conflict, the non-adopted style should take effect', - ).toBe('rgb(255, 255, 255)'); - - document.adoptedStyleSheets = [sheet]; - expect( - getComputedStyle(span).color, - 'the adopted style should be ordered after the non-adopted style', - ).toBe('rgb(255, 0, 0)'); - - sheet.disabled = true; - expect( - getComputedStyle(span).color, - 'with the adopted sheet disabled, the non-adopted style should take effect', - ).toBe('rgb(255, 255, 255)'); - - sheet.disabled = false; - expect( - getComputedStyle(span).color, - 'the adopted sheet re-enabled, it should take effect again', - ).toBe('rgb(255, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Inserting an @import rule through insertRule on a constructed stylesheet throws an exception', - ({ document, CSSStyleSheet, DOMException }) => { - const { import_text } = prepare(document, CSSStyleSheet); - - expect(() => { - new CSSStyleSheet().insertRule(import_text); - }).toThrow( - expect.objectContaining({ name: 'SyntaxError', code: 12, constructor: DOMException }), - ); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replace allows, but ignores, import rule inside', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv, import_text } = prepare( - document, - CSSStyleSheet, - ); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - // Replace and assert that the imported rule is NOT applied. - const sheet_promise = sheet.replace(import_text); - return sheet_promise - .then((sheet) => { - // replace() ignores @import rules: - expect(sheet.cssRules.length).toBe(0); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - }) - .catch((reason) => { - expect.unreachable(`Promise was rejected (${reason}) when it should have been resolved`); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replace ignores @import rule but still loads other rules', - async ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv, import_text } = prepare( - document, - CSSStyleSheet, - ); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const targetSpan = document.createElement('span'); - targetSpan.classList.add('target'); - shadowDiv.appendChild(targetSpan); - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - // Replace and assert that the imported rule is NOT applied, but regular rule does apply. - const sheet_promise = sheet.replace(import_text + '.target { color: blue; }'); - return sheet_promise - .then((sheet) => { - expect(sheet.cssRules.length).toBe(1); - // @import not applied: - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - // regular rule applied: - expect(getComputedStyle(targetSpan).color).toBe('rgb(0, 0, 255)'); - }) - .catch((reason) => { - expect.unreachable(`Promise was rejected (${reason}) when it should have been resolved`); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replaceSync allows, but ignores, import rule inside', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv, import_text } = prepare( - document, - CSSStyleSheet, - ); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - // Replace and assert that the imported rule is NOT applied. - try { - sheet.replaceSync(import_text); - // replaceSync() ignores @import rules: - expect(sheet.cssRules.length).toBe(0); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - } catch (reason) { - expect.unreachable(`replaceSync threw an exception (${reason}) when it shouldn't have`); - } - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'CSSStyleSheet.replace does not reject on failed imports', - async ({ document, CSSStyleSheet }) => { - const {} = prepare(document, CSSStyleSheet); - - const sheet = new CSSStyleSheet(); - const sheet_promise = sheet.replace("@import url('not-there.css');"); - - return sheet_promise - .then((sheet) => { - // No exception here - }) - .catch((reason) => { - expect.unreachable('Promise was rejected'); - }); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Cloning a shadow host will not clone shadow root, and also adoptedStyleSheets', - ({ document, CSSStyleSheet }) => { - const { shadowRoot, thirdSection, attachShadowDiv } = prepare(document, CSSStyleSheet); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - - const newSpan = span.cloneNode(true) as HTMLElement; - expect(newSpan.shadowRoot).toBe(null); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Importing a shadow host will not copy shadow root, and also adoptedStyleSheets', - ({ document, CSSStyleSheet }) => { - const { shadowRoot, thirdSection, attachShadowDiv } = prepare(document, CSSStyleSheet); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const sheet = new CSSStyleSheet(); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - - const iframe = document.createElement('iframe'); - document.body.appendChild(iframe); - const newSpan = iframe.contentDocument!.importNode(span, true); - iframe.contentDocument!.body.appendChild(newSpan); - expect(newSpan.shadowRoot).toBe(null); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Adopting a shadow host will empty adoptedStyleSheets if adopting to a different document', - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv } = prepare(document, CSSStyleSheet); - - const span = document.createElement('span'); - thirdSection.appendChild(span); - const shadowDiv = attachShadowDiv(span); - const sheet = new CSSStyleSheet(); - sheet.replaceSync('* { color: red; }'); - span.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(255, 0, 0)'); - - document.adoptNode(span); - expect(span.shadowRoot!.adoptedStyleSheets.length).toBe(1); - expect(span.shadowRoot!.adoptedStyleSheets[0]!).toBe(sheet); - - const iframe = document.createElement('iframe'); - document.body.appendChild(iframe); - iframe.contentDocument!.adoptNode(span); - iframe.contentDocument!.body.appendChild(span); - expect(span.shadowRoot).not.toBe(null); - expect(span.shadowRoot!.adoptedStyleSheets.length).toBe(0); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - `Adopting a shadow host's ancestor will empty adoptedStyleSheets if adopting to a different document`, - ({ document, CSSStyleSheet, getComputedStyle }) => { - const { shadowRoot, thirdSection, attachShadowDiv } = prepare(document, CSSStyleSheet); - - const span = document.createElement('span'); - const div = document.createElement('div'); - thirdSection.appendChild(span); - span.appendChild(div); - const shadowDiv = attachShadowDiv(div); - const sheet = new CSSStyleSheet(); - sheet.replaceSync('* { color: red; }'); - div.shadowRoot!.adoptedStyleSheets = [sheet]; - expect(getComputedStyle(shadowDiv).color).toBe('rgb(255, 0, 0)'); - - document.adoptNode(span); - expect(div.shadowRoot!.adoptedStyleSheets.length).toBe(1); - expect(div.shadowRoot!.adoptedStyleSheets[0]!).toBe(sheet); - - const iframe = document.createElement('iframe'); - document.body.appendChild(iframe); - iframe.contentDocument!.adoptNode(span); - iframe.contentDocument!.body.appendChild(span); - expect(div.shadowRoot).not.toBe(null); - expect(div.shadowRoot!.adoptedStyleSheets.length).toBe(0); - expect(getComputedStyle(shadowDiv).color).toBe('rgb(0, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Forcing a style update after adding an adopted stylesheet on a disconnected shadow root should not crash.', - ({ document, CSSStyleSheet }) => { - const {} = prepare(document, CSSStyleSheet); - - const host = document.createElement('div'); - const root = host.attachShadow({ mode: 'open' }); - root.adoptedStyleSheets = [new CSSStyleSheet()]; - document.body.offsetTop; - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'Modifying an adopted stylesheet on a disconnected shadow root should not crash.', - ({ document, CSSStyleSheet }) => { - const { thirdSection } = prepare(document, CSSStyleSheet); - - const host = document.createElement('div'); - thirdSection.appendChild(host); - const root = host.attachShadow({ mode: 'open' }); - const sheet = new CSSStyleSheet(); - root.adoptedStyleSheets = [sheet]; - host.remove(); - sheet.replaceSync(''); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet.html.ts deleted file mode 100644 index 2d0fe62..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/CSSStyleSheet.html.ts +++ /dev/null @@ -1,515 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup = ` - - - - CSSOM - CSSStyleSheet interface -\x20\x20\x20\x20 -\x20\x20\x20\x20 -\x20\x20\x20\x20 -\x20\x20\x20\x20 - - - -\x20\x20\x20\x20 - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'preconditions', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - - expect(styleSheet, "CSSStyleSheet and LinkStyle's sheet attribute").toBe( - (document.getElementById('my-stylesheet')! as HTMLStyleElement).sheet, - ); - expect(styleSheet.cssRules.length, 'CSSStyleSheet cssRules attribute').toBe(2); - expect(styleSheet.cssRules[0]!.cssText, 'CSSStyleSheet cssRules attribute').toBe( - 'body { width: 50%; }', - ); - expect(styleSheet.cssRules[1]!.cssText, 'CSSStyleSheet cssRules attribute').toBe( - '#foo { height: 100px; }', - ); - expect(styleSheet.cssRules[2], 'CSSStyleSheet cssRules attribute').toBe(undefined); - - expect(emptyStyleSheet, "CSSStyleSheet and LinkStyle's sheet attribute").toBe( - (document.getElementById('empty-stylesheet')! as HTMLStyleElement).sheet, - ); - expect(emptyStyleSheet.cssRules.length, 'CSSStyleSheet cssRules attribute').toBe(0); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'insertRule with #bar selector', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - - styleSheet.insertRule('#bar { margin: 10px; }', 1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after insertRule function', - ).toBe(3); - expect(styleSheet.cssRules[0]!.cssText, 'CSSStyleSheet cssRules attribute').toBe( - 'body { width: 50%; }', - ); - expect( - styleSheet.cssRules[1]!.cssText, - 'CSSStyleSheet cssRules attribute after insertRule function', - ).toBe('#bar { margin: 10px; }'); - expect( - styleSheet.cssRules[2]!.cssText, - 'CSSStyleSheet cssRules attribute after insertRule function', - ).toBe('#foo { height: 100px; }'); - expect( - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty, - '[SameObject] cssRules attribute after insertRule function', - ).toBe(1); - expect( - (styleSheet.cssRules[2] as CSSRule & { randomProperty: number }).randomProperty, - '[SameObject] cssRules attribute after insertRule function', - ).toBe(2); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'insertRule with no argument throws', - (fixture) => { - const { document } = fixture; - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - const TypeError = fixture.TypeError; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - expect(function () { - (styleSheet.insertRule as () => number)(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'insertRule with index greater than length throws', - ({ document, DOMException }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - expect(function () { - styleSheet.insertRule('#bar { margin: 10px; }', styleSheet.cssRules.length + 1); - }).toThrow( - expect.objectContaining({ - name: 'IndexSizeError', - code: 1, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'deleteRule(1)', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after deleteRule function', - ).toBe(2); - expect( - styleSheet.cssRules[0]!.cssText, - 'CSSStyleSheet cssRules attribute after deleteRule function', - ).toBe('body { width: 50%; }'); - expect( - styleSheet.cssRules[1]!.cssText, - 'CSSStyleSheet cssRules attribute after deleteRule function', - ).toBe('#foo { height: 100px; }'); - expect( - styleSheet.cssRules[2], - 'CSSStyleSheet cssRules attribute after deleteRule function', - ).toBe(undefined); - expect( - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty, - '[SameObject] cssRules attribute after deleteRule function', - ).toBe(1); - expect( - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty, - '[SameObject] cssRules attribute after deleteRule function', - ).toBe(2); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'deleteRule with no argument throws', - (fixture) => { - const { document } = fixture; - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - const TypeError = fixture.TypeError; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - expect(function () { - (styleSheet.deleteRule as () => void)(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'deleteRule on empty style sheet throws', - ({ document, DOMException }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - expect(function () { - emptyStyleSheet.deleteRule(0); - }).toThrow( - expect.objectContaining({ - name: 'IndexSizeError', - code: 1, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'removeRule with no argument removes first rule', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after removeRule function', - ).toBe(1); - expect( - styleSheet.cssRules[0]!.cssText, - 'CSSStyleSheet cssRules attribute after removeRule function', - ).toBe('#foo { height: 100px; }'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'removeRule on empty style sheet throws', - ({ document, DOMException }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - expect(function () { - emptyStyleSheet.removeRule(0); - }).toThrow( - expect.objectContaining({ - name: 'IndexSizeError', - code: 1, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'addRule with @media rule', - (fixture) => { - const { document } = fixture; - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - const CSSMediaRule = fixture.CSSMediaRule; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - expect(styleSheet.addRule('@media all', '#foo { color: red }')).toBe(-1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after addRule function', - ).toBe(2); - expect( - styleSheet.cssRules[1] instanceof CSSMediaRule, - 'CSSStyleSheet addRule does some silly string concatenation', - ).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'removeRule(1)', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after removeRule function with index', - ).toBe(1); - expect( - styleSheet.cssRules[0]!.cssText, - 'CSSStyleSheet cssRules attribute after deleteRule function with index', - ).toBe('#foo { height: 100px; }'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'addRule with #foo selectors', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - expect(styleSheet.addRule('#foo', 'color: red')).toBe(-1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after addRule function with simple selector', - ).toBe(2); - expect( - styleSheet.cssRules[1]!.cssText, - 'CSSStyleSheet cssRules attribute after addRule function without index appends to the end', - ).toBe('#foo { color: red; }'); - - expect(styleSheet.addRule('#foo', 'color: blue', 0)).toBe(-1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after addRule function with simple selector with index', - ).toBe(3); - expect( - styleSheet.cssRules[0]!.cssText, - 'addRule function with index performs an insertion', - ).toBe('#foo { color: blue; }'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'addRule with no argument adds "undefined" selector', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - styleSheet.addRule('#foo', 'color: red'); - styleSheet.addRule('#foo', 'color: blue', 0); - expect(styleSheet.addRule()).toBe(-1); - expect( - styleSheet.cssRules.length, - 'CSSStyleSheet cssRules attribute after addRule function without arguments', - ).toBe(4); - expect(styleSheet.cssRules[3]!.cssText, 'addRule arguments default to undefined').toBe( - 'undefined { }', - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'addRule with index greater than length throws', - ({ document, DOMException }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - styleSheet.addRule('#foo', 'color: red'); - styleSheet.addRule('#foo', 'color: blue', 0); - styleSheet.addRule(); - expect(function () { - styleSheet.addRule('#foo', 'color: red', styleSheet.cssRules.length + 1); - }).toThrow( - expect.objectContaining({ - name: 'IndexSizeError', - code: 1, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'cssRules and rules are the same object', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - styleSheet.addRule('#foo', 'color: red'); - styleSheet.addRule('#foo', 'color: blue', 0); - styleSheet.addRule(); - expect(styleSheet.cssRules).toBe(styleSheet.rules); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'cssRules returns the same object twice', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - styleSheet.addRule('#foo', 'color: red'); - styleSheet.addRule('#foo', 'color: blue', 0); - styleSheet.addRule(); - expect(styleSheet.cssRules).toBe(styleSheet.cssRules); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'rules returns the same object twice', - ({ document }) => { - const styleSheet = document.styleSheets[0]!, - emptyStyleSheet = document.styleSheets[1]!; - (styleSheet.cssRules[0] as CSSRule & { randomProperty: number }).randomProperty = 1; - (styleSheet.cssRules[1] as CSSRule & { randomProperty: number }).randomProperty = 2; - styleSheet.insertRule('#bar { margin: 10px; }', 1); - styleSheet.deleteRule(1); - styleSheet.removeRule(); - styleSheet.addRule('@media all', '#foo { color: red }'); - styleSheet.removeRule(1); - styleSheet.addRule('#foo', 'color: red'); - styleSheet.addRule('#foo', 'color: blue', 0); - styleSheet.addRule(); - expect(styleSheet.rules).toBe(styleSheet.rules); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/MutationObserver-style.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/MutationObserver-style.html.ts deleted file mode 100644 index 2874619..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/MutationObserver-style.html.ts +++ /dev/null @@ -1,43 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Updating style property with the same value does not trigger an observation callback', - async ({ document, MutationObserver, cleanup }) => { - let called = 0; - const el = document.createElement('div'); - document.body.appendChild(el); - const m = new MutationObserver(() => { - called++; - }); - cleanup(() => m.disconnect()); - m.observe(el, { attributes: true }); - el.style.height = '100px'; - await Promise.resolve(); - expect(called, 'times callback called').toBe(1); - el.style.height = '100px'; - await Promise.resolve(); - expect(called, 'times callback called').toBe(1); - }, - ); - context.test( - 'Updating cssText triggers an observation callback even if the value is the same', - async ({ document, MutationObserver, cleanup }) => { - let called = 0; - const el = document.createElement('div'); - document.body.appendChild(el); - const m = new MutationObserver(() => { - called++; - }); - cleanup(() => m.disconnect()); - m.observe(el, { attributes: true }); - el.style.cssText = 'height:100px'; - await Promise.resolve(); - expect(called, 'times callback called').toBe(1); - el.style.cssText = 'height:100px'; - await Promise.resolve(); - expect(called, 'times callback called').toBe(2); - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/computed-style-001.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/computed-style-001.html.ts deleted file mode 100644 index e1c9774..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/computed-style-001.html.ts +++ /dev/null @@ -1,116 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup1 = ` - - - CSS Test: getComputedStyle -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 - - -\x20\x20 -\x20\x20 - - - - -
-
-\x20 - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'read_only', - ({ document, getComputedStyle, DOMException, window }) => { - const inner = document.getElementById('inside')!; - let innerStyle = getComputedStyle(inner); - - innerStyle = getComputedStyle(inner); - expect(function () { - innerStyle.cssText = 'color: blue;'; - }, 'do not allow setting cssText on a readonly CSSStyleDeclaration').toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: DOMException, - }), - ); - expect(function () { - innerStyle.setProperty('color', 'blue'); - }, 'do not allow calling setProperty on a readonly CSSStyleDeclaration').toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: DOMException, - }), - ); - expect(function () { - innerStyle.color = 'blue'; - }, 'do not allow setting a property on a readonly CSSStyleDeclaration').toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: window.DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - 'inherited_property_values', - ({ document, getComputedStyle }) => { - const inner = document.getElementById('inside')!; - let innerStyle = getComputedStyle(inner); - - expect(innerStyle.getPropertyValue('font-size')).toBe('100px'); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - - context.test( - 'property_values', - ({ document, getComputedStyle }) => { - const inner = document.getElementById('inside')!; - const innerStyle = getComputedStyle(inner); - expect(innerStyle.getPropertyValue('height')).toBe('100px'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); - context.test( - 'relative_property_values', - ({ document, getComputedStyle }) => { - const inner = document.getElementById('inside')!; - const innerStyle = getComputedStyle(inner); - expect(innerStyle.getPropertyValue('width')).toBe('100px'); - }, - { document: { contentType: 'text/html', content: markup1 } }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/computed-style-set-property.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/computed-style-set-property.html.ts deleted file mode 100644 index fb4873e..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/computed-style-set-property.html.ts +++ /dev/null @@ -1,107 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup2 = ` -NoModificationAllowedError when mutating read only properties - - - - - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Computed style parent (should be null)', - ({ document, getComputedStyle }) => { - expect(getComputedStyle(document.body, null).parentRule).toBe(null); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'Exception thrown when trying to change a computed style declaration via property', - ({ document, getComputedStyle, window }) => { - expect(function () { - getComputedStyle(document.body, null).color = 'blue'; - }).toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: window.DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'Exception thrown when trying to change a computed style declaration via setProperty', - ({ document, getComputedStyle, DOMException }) => { - expect(function () { - getComputedStyle(document.body, null).setProperty('color', 'blue'); - }).toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'Exception thrown when trying to change a computed style alias via property', - ({ document, getComputedStyle, window }) => { - expect(function () { - getComputedStyle(document.body, null).webkitTransition = ''; - }).toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: window.DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); - context.test( - 'Exception thrown when trying to change a computed style alias via setProperty', - ({ document, getComputedStyle, DOMException }) => { - expect(function () { - getComputedStyle(document.body, null).setProperty('webkitTransition', ''); - }).toThrow( - expect.objectContaining({ - name: 'NoModificationAllowedError', - code: 7, - constructor: DOMException, - }), - ); - }, - { - document: { - contentType: 'text/html', - content: markup2, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/css-style-attr-decl-block.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/css-style-attr-decl-block.html.ts deleted file mode 100644 index 44e0f7c..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/css-style-attr-decl-block.html.ts +++ /dev/null @@ -1,179 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - function createTestElement(document: Document, style: string) { - let wrapper = document.createElement('div'); - wrapper.innerHTML = `
`; - return wrapper.querySelector('#test')!; - } - context.test( - 'Style attribute should create CSS declaration block based on its content', - ({ document }) => { - let elem = createTestElement(document, 'z-index: 10;'); - expect(elem.style.cssText).toBe('z-index: 10;'); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); - context.test( - 'Changes to style attribute should reflect on CSS declaration block', - ({ document }) => { - let elem = createTestElement(document, 'z-index: 20;'); - let style = elem.style; - expect(style.cssText).toBe('z-index: 20;'); - function assert_css_text(value: string, action: string) { - expect(style.cssText, 'CSS declaration block after ' + action).toBe(value); - } - elem.setAttribute('style', 'z-index: 21;'); - assert_css_text('z-index: 21;', 'changing the style attribute'); - elem.removeAttribute('style'); - assert_css_text('', 'removing the style attribute'); - elem.setAttribute('style', 'position: absolute;'); - assert_css_text('position: absolute;', 'adding style attribute again'); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); - context.test( - 'Changes to CSS declaration block should reflect on style attribute', - ({ document }) => { - let elem = createTestElement(document, 'z-index: 30;'); - let style = elem.style; - expect(style.cssText).toBe('z-index: 30;'); - function assert_attr(value: string, action: string) { - expect(elem.getAttribute('style'), 'style attribute after ' + action).toBe(value); - } - style.setProperty('z-index', '31'); - assert_attr('z-index: 31;', 'changing property in CSS declaration block'); - style.removeProperty('z-index'); - assert_attr('', 'removing property from CSS declaration block'); - style.setProperty('position', 'absolute'); - assert_attr('position: absolute;', 'adding property to CSS declaration block'); - style.cssText = 'z-index: 32;'; - assert_attr('z-index: 32;', 'changing cssText'); - style.cssText = 'z-index: 33; invalid'; - assert_attr('z-index: 33;', 'changing cssText to a partial invalid value'); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); - context.test( - 'Changes to CSS declaration block should queue mutation record for style attribute', - ({ document, MutationObserver }) => { - let elem = createTestElement(document, 'z-index: 40;'); - let style = elem.style; - expect(style.cssText).toBe('z-index: 40;'); - // Create an observer for the element. - let observer = new MutationObserver(function () {}); - observer.observe(elem, { attributes: true, attributeOldValue: true }); - function assert_record_with_old_value(oldValue: string, action: string) { - let records = observer.takeRecords(); - expect(records.length, 'number of mutation records after ' + action).toBe(1); - let record = records[0]!; - expect(record.type, 'mutation type after ' + action).toBe('attributes'); - expect(record.attributeName, 'mutated attribute after ' + action).toBe('style'); - expect(record.oldValue, 'old value after ' + action).toBe(oldValue); - } - style.setProperty('z-index', '41'); - assert_record_with_old_value('z-index: 40;', 'changing property in CSS declaration block'); - style.cssText = 'z-index: 42;'; - assert_record_with_old_value('z-index: 41;', 'changing cssText'); - style.cssText = 'z-index: 42;'; - assert_record_with_old_value('z-index: 42;', 'changing cssText with the same content'); - style.removeProperty('z-index'); - assert_record_with_old_value('z-index: 42;', 'removing property from CSS declaration block'); - // Mutation to shorthand properties should also trigger only one mutation record. - style.setProperty('margin', '1px'); - assert_record_with_old_value('', 'adding shorthand property to CSS declaration block'); - style.removeProperty('margin'); - assert_record_with_old_value( - 'margin: 1px;', - 'removing shorthand property from CSS declaration block', - ); - // Final sanity check. - expect(elem.getAttribute('style')).toBe(''); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); - context.test( - "Removing non-existing property or setting invalid value on CSS declaration block shouldn't queue mutation record", - ({ document, MutationObserver }) => { - let elem = createTestElement(document, 'z-index: 50; invalid'); - let style = elem.style; - expect(style.cssText).toBe('z-index: 50;'); - // Create an observer for the element. - let observer = new MutationObserver(function () {}); - observer.observe(elem, { attributes: true }); - function assert_no_record(action: string) { - let records = observer.takeRecords(); - expect(records.length, 'expect no record after ' + action).toBe(0); - } - style.setProperty('z-index', 'invalid'); - assert_no_record('setting invalid value to property'); - // Longhand property. - style.removeProperty('position'); - assert_no_record('removing non-existing longhand property'); - style.setProperty('position', ''); - assert_no_record('setting empty string to non-existing longhand property'); - // Shorthand property. - style.removeProperty('margin'); - assert_no_record('removing non-existing shorthand property'); - style.setProperty('margin', ''); - assert_no_record('setting empty string to non-existing shorthand property'); - // Check that the value really isn't changed. - expect( - elem.getAttribute('style'), - 'style attribute after removing non-existing properties', - ).toBe('z-index: 50; invalid'); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); - context.test( - 'Expansion of all:unset and all:revert treated identically', - ({ document, cleanup }) => { - let e1 = document.createElement('div'); - let e2 = document.createElement('div'); - document.body.append(e1, e2); - cleanup(() => { - e1.remove(); - e2.remove(); - }); - e1.style.cssText = 'all:revert;border-bottom-left-radius:1px;'; - e2.style.cssText = 'all:unset;border-bottom-left-radius:1px;'; - let processed = e1.style.cssText - .split(';') - .map((x) => x.replace(/revert$/, 'unset')) - .join(';'); - expect(processed).toBe(e2.style.cssText); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n\n\n\n', - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/css-style-attribute-modifications.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/css-style-attribute-modifications.html.ts deleted file mode 100644 index 3e6305a..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/css-style-attribute-modifications.html.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - "Mutating the style declaration doesn't remove the style attribute", - ({ document }) => { - let el = document.getElementById('test')!; - el.style.color = ''; - expect(el.hasAttribute('style')).toBe(true); - - el.removeAttribute('style'); - expect(el.hasAttribute('style')).toBe(false); - }, - { - document: { - contentType: 'text/html', - content: '\n\n\n\n\n
\n\n', - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/cssom/cssom-setProperty-shorthand.html.ts b/packages/web-platform-tests/src/wpt/css/cssom/cssom-setProperty-shorthand.html.ts deleted file mode 100644 index 550ed59..0000000 --- a/packages/web-platform-tests/src/wpt/css/cssom/cssom-setProperty-shorthand.html.ts +++ /dev/null @@ -1,133 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup = ` - - - CSSOM: CSSStyleDeclaration (set|remove)PropertyValue sets/removes shorthand properties -\x20\x20\x20\x20\x20\x20\x20\x20 -\x20\x20\x20\x20\x20\x20\x20\x20 - -\x20\x20\x20\x20\x20\x20\x20\x20 - - -\x20\x20\x20\x20\x20\x20\x20\x20 -\x20\x20\x20\x20\x20\x20\x20\x20 - - - -
- -
- -\x20\x20\x20\x20\x20\x20\x20\x20 - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - function canSetProperty(element: HTMLElement, propertyName: string, priority: string) { - element.style.setProperty(propertyName, 'initial', priority); - return element.style.getPropertyValue(propertyName) == 'initial'; - } - function canRemoveProperty(element: HTMLElement, propertyName: string) { - element.style.removeProperty(propertyName); - return element.style.getPropertyValue(propertyName) != 'initial'; - } - for (const propertyName of [ - 'font', - 'border-top', - 'border-right', - 'border-bottom', - 'border-left', - 'border', - 'border-color', - 'border-style', - 'border-width', - 'background-position', - 'background-repeat', - 'border-spacing', - 'list-style', - 'margin', - 'outline', - 'padding', - 'background', - 'overflow', - 'border-radius', - ]) { - context.test( - 'shorthand ' + propertyName + ' can be set with setProperty', - ({ document }) => { - const element = document.createElement('span'); - - expect( - canSetProperty(element, propertyName, ''), - 'can setPropertyValue with shorthand', - ).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'shorthand ' + propertyName + ' can be removed with removeProperty', - ({ document }) => { - const element = document.createElement('span'); - - canSetProperty(element, propertyName, ''); - - expect( - canRemoveProperty(element, propertyName), - 'can setPropertyValue with shorthand', - ).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'shorthand ' + propertyName + ' can be set with setProperty and priority !important', - ({ document }) => { - const element = document.createElement('span'); - - expect( - canSetProperty(element, propertyName, 'important'), - 'can setPropertyValue with shorthand', - ).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - 'shorthand ' + - propertyName + - ' can be removed with removeProperty even when set with !important', - ({ document }) => { - const element = document.createElement('span'); - - canSetProperty(element, propertyName, 'important'); - - expect( - canRemoveProperty(element, propertyName), - 'can setPropertyValue with shorthand', - ).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - } -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-001.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-001.html.ts deleted file mode 100644 index df8a01c..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-001.html.ts +++ /dev/null @@ -1,85 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export const input = ['keyboard'] as const; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Keyboard focus should match :focus-visible', - async ({ document, getComputedStyle, step, input }) => { - const el = document.getElementById('el')! as HTMLElement; - const focused = new Promise((resolve) => - el.addEventListener( - 'focus', - step(() => { - expect( - getComputedStyle(el).outlineColor, - `outlineColor for ${el.tagName}#${el.id} should be green`, - ).toBe('rgb(0, 128, 0)'); - expect( - getComputedStyle(el).backgroundColor, - `backgroundColor for ${el.tagName}#${el.id} should NOT be red`, - ).not.toBe('rgb(255, 0, 0)'); - - let focusVisiblePseudoAll = document.querySelectorAll(':focus-visible'); - expect(focusVisiblePseudoAll.length, "Only 1 element matches ':focus-visible'").toBe(1); - let focusVisiblePseudo = document.querySelector(':focus-visible'); - expect(el, "${el.tagName}#${el.id} matches ':focus-visible'").toBe(focusVisiblePseudo); - resolve(); - }), - ), - ); - el.focus(); - await input.press('Tab'); - await focused; - }, - { - document: { - contentType: 'text/html', - content: ` - - - - CSS Test (Selectors): Keyboard focus enables :focus-visible - - -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 - - - - This test checks that using the Tab key to navigate focus to an element triggers :focus-visible matching. -
    -
  1. If the user-agent does not claim to support the :focus-visible pseudo-class then SKIP this test.
  2. -
  3. Use the TAB key on the keyboard to focus the element below that says "Focus me."
  4. -
  5. If the element has a red background, then the test result is FAILURE. If the element has a green outline, then the test result is SUCCESS.
  6. -
-
-
Focus me.
-\x20\x20 - - -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-002.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-002.html.ts deleted file mode 100644 index 4a711d6..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-002.html.ts +++ /dev/null @@ -1,119 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export const input = ['mouse'] as const; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - for (let i = 0; i < 14; i++) - context.test( - `Focus element ${i === 13 ? 'TEXTAREA' : 'INPUT'}#input${i + 1} via mouse should match :focus-visible as it supports keyboard input`, - async (fixture) => { - const { document } = fixture; - const target = document.getElementById('input' + (i + 1))!; - const getComputedStyle = fixture.getComputedStyle; - const focused = new Promise((resolve) => - target.addEventListener('focus', () => resolve()), - ); - await fixture.input.click(target); - await focused; - expect( - getComputedStyle(target).outlineColor, - `outlineColor for ${target.tagName}#${target.id} should be green`, - ).toBe('rgb(0, 128, 0)'); - expect( - getComputedStyle(target).backgroundColor, - `backgroundColor for ${target.tagName}#${target.id} should NOT be red`, - ).not.toBe('rgb(255, 0, 0)'); - }, - { - document: { - contentType: 'text/html', - content: ` - - - - CSS Test (Selectors): :focus-visible always matches on texty input elements - - - -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 - - - - This test checks that :focus-visible always matches on <input> elements which take text input, regardless of focus mechanism. -
    -
  1. If the user-agent does not claim to support the :focus-visible pseudo-class then SKIP this test.
  2. -
  3. Click each form element below to focus it.
  4. -
  5. If the element has a red background, then the test result is FAILURE. If the element has a green outline, then the test result is SUCCESS.
  6. -
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-\x20\x20 - - -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-003.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-003.html.ts deleted file mode 100644 index 85a2be6..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-visible-003.html.ts +++ /dev/null @@ -1,127 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export const input = ['mouse'] as const; - -const markup = ` - - - - CSS Test (Selectors): :focus-visible does not match on non-texty inputs - - -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 -\x20\x20 - - - - This test checks that :focus-visible is not triggered by mouse focus on <input> elements which do not take text input. -
    -
  1. If the user-agent does not claim to support the :focus-visible pseudo-class then SKIP this test.
  2. -
  3. Click each element element below to focus it.
  4. -
  5. If the element has a red outline, then the test result is FAILURE. If the element has a green background, then the test result is SUCCESS.
  6. -
-
-
- Focus me -
-
- Focus me -
-
- Focus me -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- - -
-
- -
-
- - -
-\x20\x20 - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - const elements = [ - ['SPAN', 'el-1'], - ['SPAN', 'el-2'], - ['SPAN', 'el-3'], - ['BUTTON', 'el-4'], - ['INPUT', 'el-5'], - ['INPUT', 'el-6'], - ['INPUT', 'el-7'], - ['INPUT', 'el-8'], - ['INPUT', 'el-9'], - ['INPUT', 'el-10'], - ['INPUT', 'el-12'], - ['INPUT', 'el-13'], - ]; - for (const [tagName, id] of elements) { - context.test( - `Focus element ${tagName}#${id} via mouse should NOT match :focus-visible as it does NOT support keyboard input`, - async ({ document, input, getComputedStyle }) => { - const target = document.getElementById(id!)!; - const focused = new Promise((resolve) => - target.addEventListener('focus', () => resolve()), - ); - await input.click(target); - await focused; - expect( - getComputedStyle(target).backgroundColor, - `backgroundColor for ${target.tagName}#${target.id} should be lime`, - ).toBe('rgb(0, 255, 0)'); - expect( - getComputedStyle(target).outlineColor, - `outlineColor for ${target.tagName}#${target.id} should NOT be red`, - ).not.toBe('rgb(255, 0, 0)'); - }, - { document: { contentType: 'text/html', content: markup } }, - ); - } -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-within-focus-move.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-within-focus-move.html.ts deleted file mode 100644 index 210805d..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-within-focus-move.html.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - "Moving focus from its own focus() call doesn't leave stale :focus-within state", - ({ document }) => { - let wrapper = document.getElementById('wrapper')!; - let outer = document.getElementById('outer')!; - let tab = document.getElementById('tab')!; - let input = document.getElementById('input')!; - let outside = document.getElementById('outside')!; - - input.focus(); - expect(document.activeElement, 'activeElement after focus').toBe(input); - expect(outer.matches(':focus-within'), 'outer matches :focus-within').toBe(true); - expect(wrapper.matches(':focus-within'), 'wrapper matches :focus-within').toBe(true); - // This ends up shifting to `outside` rather than `tab`. - tab.focus(); - expect(document.activeElement, 'activeElement after trying to focus sibling').toBe(outside); - expect(wrapper.matches(':focus-within'), 'wrapper still matches :focus-within').toBe(true); - expect(outer.matches(':focus-within'), 'outer no longer matches :focus-within').toBe(false); - }, - { - document: { - contentType: 'text/html', - content: ` - -Moving focus from its own focus() call doesn't leave stale :focus-within state - - - - - - -
-
- - -
- -
- -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-within-removal.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-within-removal.html.ts deleted file mode 100644 index 729df2a..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-within-removal.html.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - "Removing an element from its own focus() call doesn't leave stale :focus-within state", - ({ document }) => { - let root = document.getElementById('root')!; - let container = document.getElementById('container')!; - let input = document.querySelector('input')!; - - input.focus(); - expect(document.activeElement, 'activeElement after focus').toBe(input); - expect(container.matches(':focus-within'), 'container matches :focus-within').toBe(true); - expect(root.matches(':focus-within'), 'root also matches :focus-within').toBe(true); - // This fires from within the next focus() call - input.addEventListener('focusout', () => { - root.innerHTML = ''; - }); - // container is focusable, but gets removed before we get a chance at focusing it. - container.focus(); - expect(document.activeElement, 'activeElement after trying to focus sibling').toBe( - document.body, - ); - expect(container.parentNode, 'container should get removed').toBe(null); - expect(container.matches(':focus-within'), 'container no longer matches :focus-within').toBe( - false, - ); - expect(root.matches(':focus-within'), 'root no longer matches :focus-within').toBe(false); - }, - { - document: { - contentType: 'text/html', - content: ` - -Removing an element from its own focus() call doesn't leave stale :focus-within state - - - - - - -
-
- -
-
- -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/focus-within.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/focus-within.html.ts deleted file mode 100644 index 016ebf5..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/focus-within.html.ts +++ /dev/null @@ -1,83 +0,0 @@ -import type { CompatibilityContext } from '../../../shared/context.ts'; - -const markup1 = ` - - -:focus-within pseudo - - - - - -
- Focus here: - -
- - - -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - ':focus-within applies to focused element', - async ({ document, cleanup }) => { - const container = document.getElementById('container')!; - const button = document.getElementById('button')!; - async function waitForWindowFocus() { - // Wait for the test window to gain focus before testing synchronous focus changes. - const sentinel = document.createElement('button'); - document.body.append(sentinel); - cleanup(() => sentinel.remove()); - await new Promise((resolve) => { - sentinel.addEventListener('focus', resolve, { once: true }); - sentinel.focus(); - }); - sentinel.blur(); - } - - await waitForWindowFocus(); - cleanup(() => button.blur()); - button.focus(); - expect(button.matches(':focus')).toBe(true); - expect(button.matches(':focus-within')).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); - context.test( - ':focus-within applies to ancestor', - async ({ document, cleanup }) => { - const container = document.getElementById('container')!; - const button = document.getElementById('button')!; - async function waitForWindowFocus() { - // Wait for the test window to gain focus before testing synchronous focus changes. - const sentinel = document.createElement('button'); - document.body.append(sentinel); - cleanup(() => sentinel.remove()); - await new Promise((resolve) => { - sentinel.addEventListener('focus', resolve, { once: true }); - sentinel.focus(); - }); - sentinel.blur(); - } - - await waitForWindowFocus(); - cleanup(() => button.blur()); - button.focus(); - expect(container.matches(':focus')).toBe(false); - expect(container.matches(':focus-within')).toBe(true); - }, - { - document: { - contentType: 'text/html', - content: markup1, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/has-basic.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/has-basic.html.ts deleted file mode 100644 index 9a570b5..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/has-basic.html.ts +++ /dev/null @@ -1,437 +0,0 @@ -import type { CompatibilityContext, DOMFixture } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - function prepare({ document, connect }: DOMFixture, markup: string): Document { - const root = document.createElement('div'); - root.innerHTML = markup; - connect(root); - return document; - } - - const { expect } = context.runner; - - // 4.3.7 from https://drafts.csswg.org/css-syntax/#consume-escaped-code-point - - // - escape hex digit - - // - hex digit special replacement - // 1. zero points - - // 2. surrogate points - - // 3. out of range points - - // - escape EOF - - // - escape anythong else - - // non edge cases - - // ident tests case from CSS tests of chromium source: https://goo.gl/3Cxdov - - context.test('WPT has-basic.html: :has(#a) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const actual = Array.from(main.querySelectorAll(':has(#a)')); - const expected: Element[] = []; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: :has(.ancestor) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const actual = Array.from(main.querySelectorAll(':has(.ancestor)')); - const expected: Element[] = [a]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: :has(.target) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const b = document.getElementById('b')!; - const f = document.getElementById('f')!; - const h = document.getElementById('h')!; - const actual = Array.from(main.querySelectorAll(':has(.target)')); - const expected: Element[] = [a, b, f, h]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: :has(.descendant) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const b = document.getElementById('b')!; - const c = document.getElementById('c')!; - const f = document.getElementById('f')!; - const h = document.getElementById('h')!; - const j = document.getElementById('j')!; - const actual = Array.from(main.querySelectorAll(':has(.descendant)')); - const expected: Element[] = [a, b, c, f, h, j]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: .parent:has(.target) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const b = document.getElementById('b')!; - const f = document.getElementById('f')!; - const h = document.getElementById('h')!; - const actual = Array.from(main.querySelectorAll('.parent:has(.target)')); - const expected: Element[] = [b, f, h]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT has-basic.html: :has(.sibling ~ .target) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const b = document.getElementById('b')!; - const actual = Array.from(main.querySelectorAll(':has(.sibling ~ .target)')); - const expected: Element[] = [a, b]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT has-basic.html: .parent:has(.sibling ~ .target) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const b = document.getElementById('b')!; - const actual = Array.from(main.querySelectorAll('.parent:has(.sibling ~ .target)')); - const expected: Element[] = [b]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT has-basic.html: :has(:is(.target ~ .sibling .descendant)) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const h = document.getElementById('h')!; - const j = document.getElementById('j')!; - const actual = Array.from(main.querySelectorAll(':has(:is(.target ~ .sibling .descendant))')); - const expected: Element[] = [a, h, j]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT has-basic.html: .parent:has(:is(.target ~ .sibling .descendant)) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const h = document.getElementById('h')!; - const actual = Array.from( - main.querySelectorAll('.parent:has(:is(.target ~ .sibling .descendant))'), - ); - const expected: Element[] = [h]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT has-basic.html: .sibling:has(.descendant) ~ .target matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const e = document.getElementById('e')!; - const actual = Array.from(main.querySelectorAll('.sibling:has(.descendant) ~ .target')); - const expected: Element[] = [e]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test('WPT has-basic.html: :has(> .parent) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const actual = Array.from(main.querySelectorAll(':has(> .parent)')); - const expected: Element[] = [a]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: :has(> .target) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const b = document.getElementById('b')!; - const f = document.getElementById('f')!; - const h = document.getElementById('h')!; - const actual = Array.from(main.querySelectorAll(':has(> .target)')); - const expected: Element[] = [b, f, h]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT has-basic.html: :has(> .parent, > .target) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const b = document.getElementById('b')!; - const f = document.getElementById('f')!; - const h = document.getElementById('h')!; - const actual = Array.from(main.querySelectorAll(':has(> .parent, > .target)')); - const expected: Element[] = [a, b, f, h]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test('WPT has-basic.html: :has(+ #h) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':has(+ #h)')); - const expected: Element[] = [f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT has-basic.html: .parent:has(~ #h) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const b = document.getElementById('b')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll('.parent:has(~ #h)')); - const expected: Element[] = [b, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT has-basic.html: .sibling:has(.descendant) matches expected element', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const c = document.getElementById('c')!; - expect(main.querySelector('.sibling:has(.descendant)')).toBe(c); - }, - ); - - context.test( - 'WPT has-basic.html: closest(.ancestor:has(.descendant)) returns expected element', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const h = document.getElementById('h')!; - const k = document.getElementById('k')!; - expect(k.closest('.ancestor:has(.descendant)')).toBe(h); - }, - ); - - context.test( - 'WPT has-basic.html: :has(.target ~ .sibling .descendant) matches expectedly', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
', - ); - const h = document.getElementById('h')!; - expect(h.matches(':has(.target ~ .sibling .descendant)')).toBe(true); - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/invalidation/input-pseudo-classes-in-has.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/invalidation/input-pseudo-classes-in-has.html.ts deleted file mode 100644 index e6abf80..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/invalidation/input-pseudo-classes-in-has.html.ts +++ /dev/null @@ -1,325 +0,0 @@ -import type { CompatibilityContext } from '../../../../shared/context.ts'; - -const markup = ` - -CSS Selectors Invalidation: input pseudo classes in :has() argument - - - - - -
- - - - - - - -
- -`; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - ':checked & :indeterminate invalidation on ', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - let input: HTMLInputElement | null = null; - cleanup(() => { - if (input) { - // Need to put the input back for the rest of the tests. - subject.prepend(input); - } - checkme.checked = false; - }); - checkme.checked = false; - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - checkme.checked = true; - expect(getComputedStyle(subject).color, 'ancestor should be green').toBe('rgb(0, 128, 0)'); - checkme.indeterminate = true; - expect(getComputedStyle(subject).color, 'ancestor should be yellowgreen').toBe( - 'rgb(154, 205, 50)', - ); - input = checkme; - checkme.remove(); - input.indeterminate = false; - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - - subject.prepend(input); - input = null; - checkme.checked = true; - expect(getComputedStyle(subject).color, 'ancestor should be green').toBe('rgb(0, 128, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':indeterminate invalidation on ', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - progress.setAttribute('value', '50'); - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - progress.removeAttribute('value'); - expect(getComputedStyle(subject).color, 'ancestor should be orange').toBe('rgb(255, 165, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':disabled invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - checkme.disabled = false; - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - checkme.disabled = true; - expect(getComputedStyle(subject).color, 'ancestor should be blue').toBe('rgb(0, 0, 255)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':read-only invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - textinput.readOnly = false; - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - textinput.readOnly = true; - expect(getComputedStyle(subject).color, 'ancestor should be skyblue').toBe( - 'rgb(135, 206, 235)', - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':valid invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - textinput.value = ''; - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - textinput.value = 'text input'; - expect(getComputedStyle(subject).color, 'ancestor should be lightgreen').toBe( - 'rgb(144, 238, 144)', - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':default invalidation with input[type=radio]', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - radioinput.removeAttribute('type'); - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - radioinput.type = 'radio'; - expect(getComputedStyle(subject).color, 'ancestor should be lightblue').toBe( - 'rgb(173, 216, 230)', - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':required invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - numberinput.required = false; - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - numberinput.required = true; - expect(getComputedStyle(subject).color, 'ancestor should be pink').toBe('rgb(255, 192, 203)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':out-of-range invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - numberinput.value = 5 as unknown as string; - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - numberinput.value = 12 as unknown as string; - expect(getComputedStyle(subject).color, 'ancestor should be darkgreen').toBe( - 'rgb(0, 100, 0)', - ); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':placeholder-shown invalidation', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - textinput.removeAttribute('placeholder'); - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - textinput.placeholder = 'placeholder text'; - expect(getComputedStyle(subject).color, 'ancestor should be navy').toBe('rgb(0, 0, 128)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); - context.test( - ':default invalidation with input[type=checkbox] and assignment to .checked', - ({ document, getComputedStyle, cleanup }) => { - const subject = document.getElementById('subject') as HTMLElement; - const checkme = document.getElementById('checkme') as HTMLInputElement; - const textinput = document.getElementById('textinput') as HTMLInputElement; - const radioinput = document.getElementById('radioinput') as HTMLInputElement; - const numberinput = document.getElementById('numberinput') as HTMLInputElement; - const progress = document.getElementById('progress') as HTMLProgressElement; - const checkboxinput = document.getElementById('checkboxinput') as HTMLInputElement; - - cleanup(() => { - checkboxinput.checked = false; - checkboxinput.removeAttribute('checked'); - }); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - checkboxinput.checked = true; - expect(getComputedStyle(subject).color, 'ancestor should still be black').toBe( - 'rgb(0, 0, 0)', - ); - checkboxinput.setAttribute('checked', ''); - expect(getComputedStyle(subject).color, 'ancestor should be purple').toBe('rgb(128, 0, 128)'); - checkboxinput.checked = false; - expect(getComputedStyle(subject).color, 'ancestor should still be purple').toBe( - 'rgb(128, 0, 128)', - ); - checkboxinput.removeAttribute('checked'); - expect(getComputedStyle(subject).color, 'ancestor should be black').toBe('rgb(0, 0, 0)'); - }, - { - document: { - contentType: 'text/html', - content: markup, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/invalidation/user-action-pseudo-classes-in-has.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/invalidation/user-action-pseudo-classes-in-has.html.ts deleted file mode 100644 index f8919c5..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/invalidation/user-action-pseudo-classes-in-has.html.ts +++ /dev/null @@ -1,145 +0,0 @@ -import type { CompatibilityContext } from '../../../../shared/context.ts'; - -export const input = ['keyboard', 'mouse'] as const; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'user-action pseudo classes in :has() argument', - async ({ document, getComputedStyle, input }) => { - const subject1 = document.getElementById('subject1')!; - const subject2 = document.getElementById('subject2')!; - const subject3 = document.getElementById('subject3')!; - const subject4 = document.getElementById('subject4')!; - const hoverme = document.getElementById('hoverme')!; - const unhoverme = document.getElementById('unhoverme')!; - const focusme1 = document.getElementById('focusme1')!; - const focusme2 = document.getElementById('focusme2')!; - const focusme3 = document.getElementById('focusme3')!; - const focusme4 = document.getElementById('focusme4')!; - - expect(getComputedStyle(subject1).color, 'subject1 initially black').toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(subject2).color, 'subject3 initially black').toBe('rgb(0, 0, 0)'); - - await input.move(hoverme); - expect(getComputedStyle(subject1).color, 'subject1 should be blue').toBe('rgb(0, 0, 255)'); - expect(getComputedStyle(subject3).color, 'subject3 should be navy').toBe('rgb(0, 0, 128)'); - - await input.move(unhoverme); - expect(getComputedStyle(subject1).color, 'subject1 should be back to black').toBe( - 'rgb(0, 0, 0)', - ); - expect(getComputedStyle(subject3).color, 'subject3 should be back to black').toBe( - 'rgb(0, 0, 0)', - ); - - await input.move(hoverme); - await input.down(); - expect(getComputedStyle(subject1).color, 'subject1 should be skyblue').toBe( - 'rgb(135, 206, 235)', - ); - expect(getComputedStyle(subject3).color, 'subject3 should be lightblue').toBe( - 'rgb(173, 216, 230)', - ); - - // Clean up `pointerDown` from above. We want to test invalidation from - // `:hover:active` to `:hover`, but there's no guarantee that pointer - // state will stay the same between actions. - await input.up(); - await input.move(unhoverme); - - // Perform the entire activation chain again, then perform `pointerUp`. - await input.move(hoverme); - await input.down(); - await input.up(); - expect(getComputedStyle(subject1).color, 'subject1 should be blue').toBe('rgb(0, 0, 255)'); - expect(getComputedStyle(subject3).color, 'subject3 should be navy').toBe('rgb(0, 0, 128)'); - - await input.move(focusme1); - await input.down(); - await input.up(); - expect(getComputedStyle(subject1).color, 'subject1 should be green').toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(subject3).color, 'subject3 should be darkgreen').toBe( - 'rgb(0, 100, 0)', - ); - - document.body.focus(); - await input.press('Tab'); - expect(getComputedStyle(subject1).color, 'subject1 should be yellowgreen').toBe( - 'rgb(154, 205, 50)', - ); - expect(getComputedStyle(subject3).color, 'subject3 should be greenyellow').toBe( - 'rgb(173, 255, 47)', - ); - - document.body.focus(); - await input.press('Tab'); - expect(getComputedStyle(subject1).color, 'subject1 should be lightgreen').toBe( - 'rgb(144, 238, 144)', - ); - expect(getComputedStyle(subject3).color, 'subject3 should be violet').toBe( - 'rgb(238, 130, 238)', - ); - - focusme3.remove(); - expect(getComputedStyle(subject1).color, 'subject1 should be black').toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(subject3).color, 'subject3 should be black').toBe('rgb(0, 0, 0)'); - - document.body.focus(); - await input.press('Tab'); - expect(getComputedStyle(subject2).color, 'subject2 should be green').toBe('rgb(0, 128, 0)'); - expect(getComputedStyle(subject4).color, 'subject4 should be darkgreen').toBe( - 'rgb(0, 100, 0)', - ); - - focusme4.remove(); - expect(getComputedStyle(subject2).color, 'subject2 should be black').toBe('rgb(0, 0, 0)'); - expect(getComputedStyle(subject4).color, 'subject4 should be black').toBe('rgb(0, 0, 0)'); - }, - { - document: { - contentType: 'text/html', - content: ` - -CSS Selectors Invalidation: user-action pseudo classes in :has() argument - - - - - - - - -
-
-
No :hover
-
Hover and click me
-
Focus me
-
Focus me
-
-
Focus me
-
-
-
subject
-
-
-
Focus me
-
subject
-
- -`, - }, - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/css/selectors/is-where-basic.html.ts b/packages/web-platform-tests/src/wpt/css/selectors/is-where-basic.html.ts deleted file mode 100644 index b82cb2e..0000000 --- a/packages/web-platform-tests/src/wpt/css/selectors/is-where-basic.html.ts +++ /dev/null @@ -1,403 +0,0 @@ -import type { CompatibilityContext, DOMFixture } from '../../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - function prepare({ document, connect }: DOMFixture, markup: string): Document { - const root = document.createElement('div'); - root.innerHTML = markup; - connect(root); - return document; - } - - const { expect } = context.runner; - - // 4.3.7 from https://drafts.csswg.org/css-syntax/#consume-escaped-code-point - - // - escape hex digit - - // - hex digit special replacement - // 1. zero points - - // 2. surrogate points - - // 3. out of range points - - // - escape EOF - - // - escape anythong else - - // non edge cases - - // ident tests case from CSS tests of chromium source: https://goo.gl/3Cxdov - - context.test('WPT is-where-basic.html: :is() matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const actual = Array.from(main.querySelectorAll(':is()')); - const expected: Element[] = []; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT is-where-basic.html: :is(#a) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const actual = Array.from(main.querySelectorAll(':is(#a)')); - const expected: Element[] = [a]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT is-where-basic.html: :is(#a, #f) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(#a, #f)')); - const expected: Element[] = [a, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT is-where-basic.html: :is(#a, #c) :where(#a #d, #c #f) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const d = document.getElementById('d')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(#a, #c) :where(#a #d, #c #f)')); - const expected: Element[] = [d, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT is-where-basic.html: #c > :is(#c > #f) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll('#c > :is(#c > #f)')); - const expected: Element[] = [f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT is-where-basic.html: #c > :is(#b > #f) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const actual = Array.from(main.querySelectorAll('#c > :is(#b > #f)')); - const expected: Element[] = []; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test('WPT is-where-basic.html: #a div:is(#d) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const d = document.getElementById('d')!; - const actual = Array.from(main.querySelectorAll('#a div:is(#d)')); - const expected: Element[] = [d]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT is-where-basic.html: :is(div) > div matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const d = document.getElementById('d')!; - const e = document.getElementById('e')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(div) > div')); - const expected: Element[] = [d, e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT is-where-basic.html: :is(*) > div matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const d = document.getElementById('d')!; - const b = document.getElementById('b')!; - const e = document.getElementById('e')!; - const c = document.getElementById('c')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(*) > div')); - const expected: Element[] = [a, b, c, d, e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test('WPT is-where-basic.html: :is(*) div matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const d = document.getElementById('d')!; - const b = document.getElementById('b')!; - const e = document.getElementById('e')!; - const c = document.getElementById('c')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(*) div')); - const expected: Element[] = [a, b, c, d, e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT is-where-basic.html: div > :where(#e, #f) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const e = document.getElementById('e')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll('div > :where(#e, #f)')); - const expected: Element[] = [e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test('WPT is-where-basic.html: div > :where(*) matches expected elements', (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const d = document.getElementById('d')!; - const e = document.getElementById('e')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll('div > :where(*)')); - const expected: Element[] = [d, e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }); - - context.test( - 'WPT is-where-basic.html: :is(*) > :where(*) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const a = document.getElementById('a')!; - const d = document.getElementById('d')!; - const b = document.getElementById('b')!; - const e = document.getElementById('e')!; - const c = document.getElementById('c')!; - const f = document.getElementById('f')!; - const actual = Array.from(main.querySelectorAll(':is(*) > :where(*)')); - const expected: Element[] = [a, b, c, d, e, f]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT is-where-basic.html: :is(#a + #b) + :is(#c) matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const c = document.getElementById('c')!; - const actual = Array.from(main.querySelectorAll(':is(#a + #b) + :is(#c)')); - const expected: Element[] = [c]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); - - context.test( - 'WPT is-where-basic.html: :is(#a, #b) + div matches expected elements', - (fixture) => { - const document = prepare( - fixture, - '
\n
\n
\n
\n
', - ); - const main = document.getElementById('main')!; - const b = document.getElementById('b')!; - const c = document.getElementById('c')!; - const actual = Array.from(main.querySelectorAll(':is(#a, #b) + div')); - const expected: Element[] = [b, c]; - expect( - actual - .map((element) => element.id) - .toSorted() - .join(), - ).toBe( - expected - .map((element) => element.id) - .toSorted() - .join(), - ); - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/custom-elements/CustomElementRegistry.html.ts b/packages/web-platform-tests/src/wpt/custom-elements/CustomElementRegistry.html.ts deleted file mode 100644 index d85c9ed..0000000 --- a/packages/web-platform-tests/src/wpt/custom-elements/CustomElementRegistry.html.ts +++ /dev/null @@ -1,1453 +0,0 @@ -import type { CompatibilityContext } from '../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - { - const { expect } = context.runner; - context.test( - 'CustomElementRegistry interface must have define as a method', - ({ customElements, CustomElementRegistry }) => { - expect( - 'define' in CustomElementRegistry.prototype, - '"define" exists on CustomElementRegistry.prototype', - ).toBe(true); - expect('define' in customElements, '"define" exists on window.customElements').toBe(true); - }, - ); - context.test( - 'customElements.define must throw when the element interface is not a constructor', - ({ customElements, TypeError }) => { - expect(function () { - customElements.define('badname', 1 as unknown as CustomElementConstructor); - }, 'customElements.define must throw a TypeError when the element interface is a number').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - expect(function () { - customElements.define('badname', '123' as unknown as CustomElementConstructor); - }, 'customElements.define must throw a TypeError when the element interface is a string').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - expect(function () { - customElements.define('badname', {} as unknown as CustomElementConstructor); - }, 'customElements.define must throw a TypeError when the element interface is an object').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - expect(function () { - customElements.define('badname', [] as unknown as CustomElementConstructor); - }, 'customElements.define must throw a TypeError when the element interface is an array').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - }, - ); - context.test( - 'customElements.define must not throw the constructor is HTMLElement', - ({ HTMLElement, customElements }) => { - customElements.define('custom-html-element', HTMLElement); - }, - ); - context.test( - 'customElements.define must throw with an invalid name', - ({ HTMLElement, customElements, DOMException }) => { - class MyCustomElement extends HTMLElement {} - - expect(function () { - customElements.define(null as unknown as string, MyCustomElement); - }, 'customElements.define must throw a SyntaxError if the tag name is null').toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - expect(function () { - customElements.define('', MyCustomElement); - }, 'customElements.define must throw a SyntaxError if the tag name is empty').toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - expect(function () { - customElements.define('abc', MyCustomElement); - }, 'customElements.define must throw a SyntaxError if the tag name does not contain "-"').toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - expect(function () { - customElements.define('a-Bc', MyCustomElement); - }, 'customElements.define must throw a SyntaxError if the tag name contains an upper case letter').toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - - var builtinTagNames = [ - 'annotation-xml', - 'color-profile', - 'font-face', - 'font-face-src', - 'font-face-uri', - 'font-face-format', - 'font-face-name', - 'missing-glyph', - ]; - - for (var tagName of builtinTagNames) { - expect( - function () { - customElements.define(tagName, MyCustomElement); - }, - 'customElements.define must throw a SyntaxError if the tag name is "' + tagName + '"', - ).toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - } - }, - ); - context.test( - 'customElements.define must throw when there is already a custom element of the same name', - ({ HTMLElement, customElements, DOMException }) => { - class SomeCustomElement extends HTMLElement {} - - var calls: PropertyKey[] = []; - var OtherCustomElement = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - calls.push(name); - return Reflect.get(target, name); - }, - }); - - customElements.define('some-custom-element', SomeCustomElement); - expect(function () { - customElements.define('some-custom-element', OtherCustomElement); - }, 'customElements.define must throw a NotSupportedError if the specified tag name is already used').toThrow( - expect.objectContaining({ - name: 'NotSupportedError', - code: 9, - constructor: DOMException, - }), - ); - { - const actualArray = calls; - const expectedArray: never[] = []; - expect( - actualArray.length, - 'customElements.define must validate the custom element name before getting the prototype of the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must validate the custom element name before getting the prototype of the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must throw a NotSupportedError when there is already a custom element with the same class', - ({ HTMLElement, customElements, DOMException }) => { - class AnotherCustomElement extends HTMLElement {} - - customElements.define('another-custom-element', AnotherCustomElement); - expect(function () { - customElements.define('some-other-element', AnotherCustomElement); - }, 'customElements.define must throw a NotSupportedError if the specified class already defines an element').toThrow( - expect.objectContaining({ - name: 'NotSupportedError', - code: 9, - constructor: DOMException, - }), - ); - }, - ); - context.test( - 'customElements.define must throw a NotSupportedError when element definition is running flag is set', - ({ HTMLElement, customElements, DOMException }) => { - var outerCalls: PropertyKey[] = []; - var OuterCustomElement = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - outerCalls.push(name); - customElements.define('inner-custom-element', InnerCustomElement); - return Reflect.get(target, name); - }, - }); - var innerCalls: PropertyKey[] = []; - var InnerCustomElement = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - outerCalls.push(name); - return Reflect.get(target, name); - }, - }); - - expect(function () { - customElements.define('outer-custom-element', OuterCustomElement); - }, 'customElements.define must throw a NotSupportedError if the specified class already defines an element').toThrow( - expect.objectContaining({ - name: 'NotSupportedError', - code: 9, - constructor: DOMException, - }), - ); - { - const actualArray = outerCalls; - const expectedArray = ['prototype']; - expect(actualArray.length, 'customElements.define must get "prototype"').toBe( - expectedArray.length, - ); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index], 'customElements.define must get "prototype"').toBe( - expectedArray[index], - ); - } - { - const actualArray = innerCalls; - const expectedArray: never[] = []; - expect( - actualArray.length, - 'customElements.define must throw a NotSupportedError when element definition is running flag is set' + - ' before getting the prototype of the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must throw a NotSupportedError when element definition is running flag is set' + - ' before getting the prototype of the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must check IsConstructor on the constructor before checking the element definition is running flag', - ({ HTMLElement, customElements, TypeError }) => { - var calls: PropertyKey[] = []; - var ElementWithBadInnerConstructor = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - calls.push(name); - customElements.define('inner-custom-element', 1 as unknown as CustomElementConstructor); - return Reflect.get(target, name); - }, - }); - - expect(function () { - customElements.define( - 'element-with-bad-inner-constructor', - ElementWithBadInnerConstructor, - ); - }, 'customElements.define must throw a NotSupportedError if IsConstructor(constructor) is false').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - - { - const actualArray = calls; - const expectedArray = ['prototype']; - expect(actualArray.length, 'customElements.define must get "prototype"').toBe( - expectedArray.length, - ); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index], 'customElements.define must get "prototype"').toBe( - expectedArray[index], - ); - } - }, - ); - context.test( - 'customElements.define must validate the custom element name before checking the element definition is running flag', - ({ HTMLElement, customElements, DOMException }) => { - var calls: PropertyKey[] = []; - var ElementWithBadInnerName = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - calls.push(name); - customElements.define('badname', class extends HTMLElement {}); - return Reflect.get(target, name); - }, - }); - - expect(function () { - customElements.define('element-with-bad-inner-name', ElementWithBadInnerName); - }, 'customElements.define must throw a SyntaxError if the specified name is not a valid custom element name').toThrow( - expect.objectContaining({ - name: 'SyntaxError', - code: 12, - constructor: DOMException, - }), - ); - - { - const actualArray = calls; - const expectedArray = ['prototype']; - expect(actualArray.length, 'customElements.define must get "prototype"').toBe( - expectedArray.length, - ); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index], 'customElements.define must get "prototype"').toBe( - expectedArray[index], - ); - } - }, - ); - context.test( - 'customElements.define must define an instantiatable custom element', - ({ HTMLElement, customElements }) => { - class MyCustomElement extends HTMLElement {} - customElements.define('my-custom-element', MyCustomElement); - - var instance = new MyCustomElement(); - expect( - instance instanceof MyCustomElement, - 'An instance of a custom HTML element be an instance of the associated interface', - ).toBe(true); - - expect( - instance instanceof HTMLElement, - 'An instance of a custom HTML element must inherit from HTMLElement', - ).toBe(true); - - expect( - instance.localName, - 'An instance of a custom element must use the associated tag name', - ).toBe('my-custom-element'); - - expect(instance.namespaceURI, 'A custom element HTML must use HTML namespace').toBe( - 'http://www.w3.org/1999/xhtml', - ); - }, - ); - context.test( - 'CustomElementRegistry interface must have get as a method', - ({ customElements, CustomElementRegistry }) => { - expect( - 'get' in CustomElementRegistry.prototype, - '"get" exists on CustomElementRegistry.prototype', - ).toBe(true); - expect('get' in customElements, '"get" exists on window.customElements').toBe(true); - }, - ); - context.test( - 'customElements.get must return undefined when the registry does not contain an entry with the given name', - ({ customElements }) => { - expect(customElements.get('a-b')).toBe(undefined); - }, - ); - context.test( - 'customElements.get must return undefined when the registry does not contain an entry with the given name even if the name was not a valid custom element name', - ({ customElements }) => { - expect(customElements.get('html')).toBe(undefined); - expect(customElements.get('span')).toBe(undefined); - expect(customElements.get('div')).toBe(undefined); - expect(customElements.get('g')).toBe(undefined); - expect(customElements.get('ab')).toBe(undefined); - }, - ); - context.test( - 'customElements.get return the constructor of the entry with the given name when there is a matching entry.', - ({ HTMLElement, customElements }) => { - expect(customElements.get('existing-custom-element')).toBe(undefined); - class ExistingCustomElement extends HTMLElement {} - customElements.define('existing-custom-element', ExistingCustomElement); - expect(customElements.get('existing-custom-element')).toBe(ExistingCustomElement); - }, - ); - context.test( - 'customElements.whenDefined must return a promise for a valid custom element name', - ({ customElements, Promise }) => { - expect(customElements.whenDefined('some-name') instanceof Promise).toBe(true); - }, - ); - context.test( - 'customElements.whenDefined must return the same promise each time invoked for a valid custom element name which has not been defined', - ({ customElements }) => { - expect(customElements.whenDefined('some-name')).toBe( - customElements.whenDefined('some-name'), - ); - }, - ); - context.test( - 'customElements.whenDefined must return an unresolved promise when the registry does not contain the entry with the given name', - async ({ customElements, Promise }) => { - var resolved = false; - var rejected = false; - customElements.whenDefined('a-b').then( - function () { - resolved = true; - }, - function () { - rejected = true; - }, - ); - return Promise.resolve().then(function () { - expect( - resolved, - 'The promise returned by "whenDefined" must not be resolved until a custom element is defined', - ).toBe(false); - expect( - rejected, - 'The promise returned by "whenDefined" must not be rejected until a custom element is defined', - ).toBe(false); - }); - }, - ); - context.test( - 'customElements.whenDefined must return a rejected promise when the given name is not a valid custom element name', - async ({ customElements, Promise }) => { - var promise = customElements.whenDefined('badname') as Promise & { - resolved?: unknown; - rejected?: unknown; - }; - promise.then( - function (value) { - promise.resolved = value; - }, - function (value) { - promise.rejected = value; - }, - ); - - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - - return Promise.resolve().then(function () { - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(true); - }); - }, - ); - context.test( - 'customElements.whenDefined must return a resolved promise when the registry contains the entry with the given name', - async ({ HTMLElement, customElements, Promise }) => { - class PreexistingCustomElement extends HTMLElement {} - customElements.define('preexisting-custom-element', PreexistingCustomElement); - - var promise = customElements.whenDefined( - 'preexisting-custom-element', - ) as Promise & { resolved?: unknown; rejected?: unknown }; - promise.then( - function (value) { - promise.resolved = value; - }, - function (value) { - promise.rejected = value; - }, - ); - - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - - return Promise.resolve().then(function () { - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(true); - expect( - promise.resolved, - 'The promise returned by "whenDefined" must be resolved with the constructor of the element when a custom element is defined', - ).toBe(PreexistingCustomElement); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(false); - }); - }, - ); - context.test( - 'customElements.whenDefined must return a new resolved promise each time invoked when the registry contains the entry with the given name', - async ({ HTMLElement, customElements, Promise }) => { - class AnotherExistingCustomElement extends HTMLElement {} - customElements.define('another-existing-custom-element', AnotherExistingCustomElement); - - var promise1 = customElements.whenDefined( - 'another-existing-custom-element', - ) as Promise & { resolved?: unknown; rejected?: unknown }; - var promise2 = customElements.whenDefined( - 'another-existing-custom-element', - ) as Promise & { resolved?: unknown; rejected?: unknown }; - promise1.then( - function (value) { - promise1.resolved = value; - }, - function (value) { - promise1.rejected = value; - }, - ); - promise2.then( - function (value) { - promise2.resolved = value; - }, - function (value) { - promise2.rejected = value; - }, - ); - - expect(promise1).not.toBe(promise2); - expect( - 'resolved' in promise1, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'resolved' in promise2, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise1, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise2, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - - return Promise.resolve().then(function () { - expect( - 'resolved' in promise1, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(true); - expect( - promise1.resolved, - 'The promise returned by "whenDefined" must be resolved with the constructor of the element when a custom element is defined', - ).toBe(AnotherExistingCustomElement); - expect( - 'rejected' in promise1, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(false); - - expect( - 'resolved' in promise2, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(true); - expect( - promise2.resolved, - 'The promise returned by "whenDefined" must be resolved with the constructor of the element when a custom element is defined', - ).toBe(AnotherExistingCustomElement); - expect( - 'rejected' in promise2, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(false); - }); - }, - ); - context.test( - 'A promise returned by customElements.whenDefined must be resolved by "define"', - async ({ HTMLElement, customElements, Promise }) => { - class ElementDefinedAfterWhenDefined extends HTMLElement {} - var promise = customElements.whenDefined( - 'element-defined-after-whendefined', - ) as Promise & { resolved?: unknown; rejected?: unknown }; - promise.then( - function (value) { - promise.resolved = value; - }, - function (value) { - promise.rejected = value; - }, - ); - - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - - var promiseAfterDefine: Promise & { - resolved?: unknown; - rejected?: unknown; - }; - return Promise.resolve() - .then(function () { - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must not be resolved until the element is defined', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected until the element is defined', - ).toBe(false); - expect( - customElements.whenDefined('element-defined-after-whendefined'), - '"whenDefined" must return the same unresolved promise before the custom element is defined', - ).toBe(promise); - customElements.define( - 'element-defined-after-whendefined', - ElementDefinedAfterWhenDefined, - ); - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - - promiseAfterDefine = customElements.whenDefined('element-defined-after-whendefined'); - promiseAfterDefine.then( - function (value) { - promiseAfterDefine.resolved = value; - }, - function (value) { - promiseAfterDefine.rejected = value; - }, - ); - expect( - promiseAfterDefine, - '"whenDefined" must return a resolved promise once the custom element is defined', - ).not.toBe(promise); - expect( - 'resolved' in promiseAfterDefine, - 'The promise returned by "whenDefined" must not be resolved until the end of the next microtask', - ).toBe(false); - expect( - 'rejected' in promiseAfterDefine, - 'The promise returned by "whenDefined" must not be rejected until the end of the next microtask', - ).toBe(false); - }) - .then(function () { - expect( - 'resolved' in promise, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(true); - expect( - promise.resolved, - 'The promise returned by "whenDefined" must be resolved with the constructor of the element when a custom element is defined', - ).toBe(ElementDefinedAfterWhenDefined); - expect( - 'rejected' in promise, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(false); - - expect( - 'resolved' in promiseAfterDefine, - 'The promise returned by "whenDefined" must be resolved when a custom element is defined', - ).toBe(true); - expect( - promiseAfterDefine.resolved, - 'The promise returned by "whenDefined" must be resolved with the constructor of the element when a custom element is defined', - ).toBe(ElementDefinedAfterWhenDefined); - expect( - 'rejected' in promiseAfterDefine, - 'The promise returned by "whenDefined" must not be rejected when a custom element is defined', - ).toBe(false); - }); - }, - ); - context.test( - 'A promise returned by customElements.whenDefined must be resolved with the defined class', - async ({ HTMLElement, customElements }) => { - class ResolvedCustomElement extends HTMLElement {} - customElements.define('resolved-custom-element', ResolvedCustomElement); - return customElements.whenDefined('resolved-custom-element').then(function (value) { - expect( - value, - 'The promise returned by "whenDefined" must resolve with the defined class', - ).toBe(ResolvedCustomElement); - }); - }, - ); - context.test( - 'A promise returned by customElements.whenDefined must be resolved with the defined class once such class is defined', - async ({ HTMLElement, customElements }) => { - var promise = customElements - .whenDefined('not-resolved-yet-custom-element') - .then(function (value) { - expect( - value, - 'The promise returned by "whenDefined" must resolve with the defined class once such class is defined', - ).toBe(NotResolvedYetCustomElement) as Promise & { - resolved?: unknown; - rejected?: unknown; - }; - }); - class NotResolvedYetCustomElement extends HTMLElement {} - customElements.define('not-resolved-yet-custom-element', NotResolvedYetCustomElement); - return promise; - }, - ); - } - { - const { expect } = context.runner; - context.test( - 'customElements.define must upgrade elements in the shadow-including tree order', - ({ document, HTMLElement, customElements }) => { - var disconnectedElement = document.createElement('some-custom'); - var connectedElementBeforeShadowHost = document.createElement('some-custom'); - var connectedElementAfterShadowHost = document.createElement('some-custom'); - var elementInShadowTree = document.createElement('some-custom'); - var childElementOfShadowHost = document.createElement('some-custom'); - var customShadowHost = document.createElement('some-custom'); - var elementInNestedShadowTree = document.createElement('some-custom'); - - var container = document.createElement('div'); - var shadowHost = document.createElement('div'); - var shadowRoot = shadowHost.attachShadow({ mode: 'closed' }); - container.appendChild(connectedElementBeforeShadowHost); - container.appendChild(shadowHost); - container.appendChild(connectedElementAfterShadowHost); - shadowHost.appendChild(childElementOfShadowHost); - shadowRoot.appendChild(elementInShadowTree); - shadowRoot.appendChild(customShadowHost); - - var innerShadowRoot = customShadowHost.attachShadow({ mode: 'closed' }); - innerShadowRoot.appendChild(elementInNestedShadowTree); - - var calls: HTMLElement[] = []; - class SomeCustomElement extends HTMLElement { - constructor() { - super(); - calls.push(this); - } - } - - document.body.appendChild(container); - customElements.define('some-custom', SomeCustomElement); - { - const actualArray = calls; - const expectedArray = [ - connectedElementBeforeShadowHost, - elementInShadowTree, - customShadowHost, - elementInNestedShadowTree, - childElementOfShadowHost, - connectedElementAfterShadowHost, - ]; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }, - ); - } - - { - const { expect } = context.runner; - context.test( - 'customElements.define unset the element definition is running flag before upgrading custom elements', - ({ HTMLElement, customElements, document, step }) => { - var unresolvedElement = document.createElement('constructor-calls-define'); - document.body.appendChild(unresolvedElement); - var elementUpgradedDuringUpgrade = document.createElement('defined-during-upgrade'); - document.body.appendChild(elementUpgradedDuringUpgrade); - - var DefinedDuringUpgrade = class extends HTMLElement {}; - - class ConstructorCallsDefine extends HTMLElement { - constructor() { - customElements.define('defined-during-upgrade', DefinedDuringUpgrade); - step(() => expect(unresolvedElement instanceof ConstructorCallsDefine).toBe(false))(); - step(() => - expect(elementUpgradedDuringUpgrade instanceof DefinedDuringUpgrade).toBe(true), - )(); - super(); - step(() => expect(unresolvedElement instanceof ConstructorCallsDefine).toBe(true))(); - step(() => - expect(elementUpgradedDuringUpgrade instanceof DefinedDuringUpgrade).toBe(true), - )(); - } - } - - step(() => expect(unresolvedElement instanceof ConstructorCallsDefine).toBe(false))(); - step(() => - expect(elementUpgradedDuringUpgrade instanceof DefinedDuringUpgrade).toBe(false), - )(); - - customElements.define('constructor-calls-define', ConstructorCallsDefine); - }, - ); - context.test( - 'Custom Elements: CustomElementRegistry interface', - ({ DOMException, HTMLElement, customElements }) => { - var calls: PropertyKey[] = []; - var ElementWithBadInnerName = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - calls.push(name); - customElements.define('badname', class extends HTMLElement {}); - return (target as unknown as Record)[name]; - }, - }); - - expect(function () { - customElements.define('element-with-bad-inner-name', ElementWithBadInnerName); - }, 'customElements.define must throw a SyntaxError if the specified name is not a valid custom element name').toThrow( - expect.objectContaining({ name: 'SyntaxError', code: 12, constructor: DOMException }), - ); - - { - const actualArray = calls; - const expectedArray = ['prototype']; - expect(actualArray.length, 'customElements.define must get "prototype"').toBe( - expectedArray.length, - ); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index], 'customElements.define must get "prototype"').toBe( - expectedArray[index], - ); - } - }, - ); - context.test( - 'customElements.define must get "prototype", "disabledFeatures", and "formAssociated" property of the constructor', - ({ HTMLElement, customElements }) => { - var calls: PropertyKey[] = []; - var proxy = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - calls.push(name); - return (target as unknown as Record)[name]; - }, - }); - customElements.define('proxy-element', proxy as unknown as CustomElementConstructor); - { - const actualArray = calls; - const expectedArray = ['prototype', 'disabledFeatures', 'formAssociated']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor', - ({ HTMLElement, customElements }) => { - var err = { name: 'expectedError' }; - var proxy = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - throw err; - }, - }); - { - let thrown: unknown; - let didThrow = false; - try { - (function () { - customElements.define( - 'element-with-string-prototype', - proxy as unknown as CustomElementConstructor, - ); - })(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - }, - ); - context.test( - 'customElements.define must throw when "prototype" property of the constructor is not an object', - ({ HTMLElement, TypeError, customElements }) => { - var returnedValue: unknown; - var proxy = new Proxy(class extends HTMLElement {}, { - get: function (target, name) { - return returnedValue; - }, - }); - - returnedValue = null; - expect(function () { - customElements.define( - 'element-with-string-prototype', - proxy as unknown as CustomElementConstructor, - ); - }, 'customElements.define must throw when "prototype" property of the constructor is null').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - returnedValue = undefined; - expect(function () { - customElements.define( - 'element-with-string-prototype', - proxy as unknown as CustomElementConstructor, - ); - }, 'customElements.define must throw when "prototype" property of the constructor is undefined').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - returnedValue = 'hello'; - expect(function () { - customElements.define( - 'element-with-string-prototype', - proxy as unknown as CustomElementConstructor, - ); - }, 'customElements.define must throw when "prototype" property of the constructor is a string').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - returnedValue = 1; - expect(function () { - customElements.define( - 'element-with-string-prototype', - proxy as unknown as CustomElementConstructor, - ); - }, 'customElements.define must throw when "prototype" property of the constructor is a number').toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - }, - ); - context.test( - 'customElements.define must get callbacks of the constructor prototype', - ({ Element, customElements }) => { - const moveBefore_supported = 'moveBefore' in Element.prototype; - - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var calls: PropertyKey[] = []; - constructor.prototype = new Proxy(constructor.prototype, { - get: function (target, name) { - calls.push(name); - return (target as unknown as Record)[name]; - }, - }); - customElements.define( - 'element-with-proxy-prototype', - constructor as unknown as CustomElementConstructor, - ); - { - const actualArray = calls; - const expectedArray = moveBefore_supported - ? [ - 'connectedCallback', - 'disconnectedCallback', - 'connectedMoveCallback', - 'adoptedCallback', - 'attributeChangedCallback', - ] - : [ - 'connectedCallback', - 'disconnectedCallback', - 'adoptedCallback', - 'attributeChangedCallback', - ]; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype', - ({ customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var calls: PropertyKey[] = []; - var err = { name: 'expectedError' }; - constructor.prototype = new Proxy(constructor.prototype, { - get: function (target, name) { - calls.push(name); - if (name == 'disconnectedCallback') throw err; - return (target as unknown as Record)[name]; - }, - }); - { - let thrown: unknown; - let didThrow = false; - try { - (function () { - customElements.define( - 'element-with-throwing-callback', - constructor as unknown as CustomElementConstructor, - ); - })(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - { - const actualArray = calls; - const expectedArray = ['connectedCallback', 'disconnectedCallback']; - expect( - actualArray.length, - 'customElements.define must not get callbacks after one of the get throws', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must not get callbacks after one of the get throws', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while converting a callback value to Function callback type', - ({ Element, TypeError, customElements }) => { - const moveBefore_supported = 'moveBefore' in Element.prototype; - - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var calls: PropertyKey[] = []; - constructor.prototype = new Proxy(constructor.prototype, { - get: function (target, name) { - calls.push(name); - if (name == 'adoptedCallback') return 1; - return (target as unknown as Record)[name]; - }, - }); - expect(function () { - customElements.define( - 'element-with-throwing-callback', - constructor as unknown as CustomElementConstructor, - ); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - { - const actualArray = calls; - const expectedArray = moveBefore_supported - ? [ - 'connectedCallback', - 'disconnectedCallback', - 'connectedMoveCallback', - 'adoptedCallback', - ] - : ['connectedCallback', 'disconnectedCallback', 'adoptedCallback']; - expect( - actualArray.length, - 'customElements.define must not get callbacks after one of the conversion throws', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must not get callbacks after one of the conversion throws', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present', - ({ Element, customElements }) => { - const moveBefore_supported = 'moveBefore' in Element.prototype; - - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.prototype.attributeChangedCallback = function () {}; - var prototypeCalls: (PropertyKey | number)[] = []; - var callOrder = 0; - constructor.prototype = new Proxy(constructor.prototype, { - get: function (target, name) { - if (name == 'prototype' || name == 'observedAttributes') - throw 'Unexpected access to observedAttributes'; - prototypeCalls.push(callOrder++); - prototypeCalls.push(name); - return (target as unknown as Record)[name]; - }, - }); - var constructorCalls: (PropertyKey | number)[] = []; - var proxy = new Proxy(constructor, { - get: function (target, name) { - constructorCalls.push(callOrder++); - constructorCalls.push(name); - return (target as unknown as Record)[name]; - }, - }); - customElements.define( - 'element-with-attribute-changed-callback', - proxy as unknown as CustomElementConstructor, - ); - { - const actualArray = prototypeCalls; - const expectedArray = moveBefore_supported - ? [ - 1, - 'connectedCallback', - 2, - 'disconnectedCallback', - 3, - 'connectedMoveCallback', - 4, - 'adoptedCallback', - 5, - 'attributeChangedCallback', - ] - : [ - 1, - 'connectedCallback', - 2, - 'disconnectedCallback', - 3, - 'adoptedCallback', - 4, - 'attributeChangedCallback', - ]; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - { - const actualArray = constructorCalls; - const expectedArray = [ - 0, - 'prototype', - 6, - 'observedAttributes', - 7, - 'disabledFeatures', - 8, - 'formAssociated', - ]; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype', - ({ customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.prototype.attributeChangedCallback = function () {}; - var calls: PropertyKey[] = []; - var err = { name: 'expectedError' }; - var proxy = new Proxy(constructor, { - get: function (target, name) { - calls.push(name); - if (name == 'observedAttributes') throw err; - return (target as unknown as Record)[name]; - }, - }); - { - let thrown: unknown; - let didThrow = false; - try { - (function () { - customElements.define( - 'element-with-throwing-observed-attributes', - proxy as unknown as CustomElementConstructor, - ); - })(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - { - const actualArray = calls; - const expectedArray = ['prototype', 'observedAttributes']; - expect( - actualArray.length, - 'customElements.define must get "prototype" and "observedAttributes" on the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must get "prototype" and "observedAttributes" on the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence', - ({ TypeError, customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.prototype.attributeChangedCallback = function () {}; - var calls: PropertyKey[] = []; - var proxy = new Proxy(constructor, { - get: function (target, name) { - calls.push(name); - if (name == 'observedAttributes') return 1; - return (target as unknown as Record)[name]; - }, - }); - expect(function () { - customElements.define( - 'element-with-invalid-observed-attributes', - proxy as unknown as CustomElementConstructor, - ); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - { - const actualArray = calls; - const expectedArray = ['prototype', 'observedAttributes']; - expect( - actualArray.length, - 'customElements.define must get "prototype" and "observedAttributes" on the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must get "prototype" and "observedAttributes" on the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence', - ({ customElements }) => { - var err = { name: 'SomeError' }; - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.prototype.attributeChangedCallback = function () {}; - constructor.observedAttributes = { - [Symbol.iterator]: function* () { - yield 'foo'; - throw err; - }, - }; - { - let thrown: unknown; - let didThrow = false; - try { - (function () { - customElements.define( - 'element-with-generator-observed-attributes', - constructor as unknown as CustomElementConstructor, - ); - })(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes', - ({ TypeError, customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.prototype.attributeChangedCallback = function () {}; - constructor.observedAttributes = { [Symbol.iterator]: 1 }; - expect(function () { - customElements.define( - 'element-with-observed-attributes-with-uncallable-iterator', - constructor as unknown as CustomElementConstructor, - ); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined', - ({ customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.observedAttributes = 1; - customElements.define( - 'element-without-callback-with-invalid-observed-attributes', - constructor as unknown as CustomElementConstructor, - ); - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype', - ({ customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var calls: PropertyKey[] = []; - var err = { name: 'expectedError' }; - var proxy = new Proxy(constructor, { - get: function (target, name) { - calls.push(name); - if (name == 'disabledFeatures') throw err; - return (target as unknown as Record)[name]; - }, - }); - { - let thrown: unknown; - let didThrow = false; - try { - (() => - customElements.define( - 'element-with-throwing-disabled-features', - proxy as unknown as CustomElementConstructor, - ))(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - { - const actualArray = calls; - const expectedArray = ['prototype', 'disabledFeatures']; - expect( - actualArray.length, - 'customElements.define must get "prototype" and "disabledFeatures" on the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must get "prototype" and "disabledFeatures" on the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence', - ({ TypeError, customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var calls: PropertyKey[] = []; - var proxy = new Proxy(constructor, { - get: function (target, name) { - calls.push(name); - if (name == 'disabledFeatures') return 1; - return (target as unknown as Record)[name]; - }, - }); - expect(() => - customElements.define( - 'element-with-invalid-disabled-features', - proxy as unknown as CustomElementConstructor, - ), - ).toThrow(expect.objectContaining({ constructor: TypeError })); - { - const actualArray = calls; - const expectedArray = ['prototype', 'disabledFeatures']; - expect( - actualArray.length, - 'customElements.define must get "prototype" and "disabledFeatures" on the constructor', - ).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect( - actualArray[index], - 'customElements.define must get "prototype" and "disabledFeatures" on the constructor', - ).toBe(expectedArray[index]); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence', - ({ customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - var err = { name: 'SomeError' }; - constructor.disabledFeatures = { - [Symbol.iterator]: function* () { - yield 'foo'; - throw err; - }, - }; - { - let thrown: unknown; - let didThrow = false; - try { - (() => - customElements.define( - 'element-with-generator-disabled-features', - constructor as unknown as CustomElementConstructor, - ))(); - } catch (error) { - didThrow = true; - thrown = error; - } - expect(didThrow).toBe(true); - expect(thrown).toBe(err); - } - }, - ); - context.test( - 'customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures', - ({ TypeError, customElements }) => { - var constructor: (() => void) & { - observedAttributes?: unknown; - disabledFeatures?: unknown; - } = function () {}; - constructor.disabledFeatures = { [Symbol.iterator]: 1 }; - expect(() => - customElements.define( - 'element-with-disabled-features-with-uncallable-iterator', - constructor as unknown as CustomElementConstructor, - ), - ).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - } - - { - const { expect } = context.runner; - context.test( - 'customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype")', - async ({ document, HTMLElement, customElements, step, cleanup }) => { - await new Promise((resolve) => { - const iframe = document.createElement('iframe'); - cleanup(() => iframe.remove()); - iframe.onload = () => { - step(() => { - const innerWindow = iframe.contentWindow as Window & typeof globalThis; - var InnerCustomElement = class extends innerWindow.HTMLElement {}; - var calls: PropertyKey[] = []; - var proxy = new Proxy(class extends HTMLElement {}, { - get(target, name) { - calls.push(name); - if (name === 'prototype') - innerWindow.customElements.define('another-custom-element', InnerCustomElement); - return (target as unknown as Record)[name]; - }, - }); - customElements.define('element-with-inner-element-define', proxy); - const expected = ['prototype', 'disabledFeatures', 'formAssociated']; - expect( - calls.length, - 'customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor', - ).toBe(expected.length); - for (let i = 0; i < expected.length; i++) - expect( - calls[i], - 'customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor', - ).toBe(expected[i]); - expect( - iframe.contentDocument!.createElement('another-custom-element') instanceof - InnerCustomElement, - ).toBe(true); - })(); - document.body.removeChild(iframe); - resolve(); - }; - document.body.appendChild(iframe); - }); - }, - ); - } -} diff --git a/packages/web-platform-tests/src/wpt/custom-elements/HTMLElement-constructor.html.ts b/packages/web-platform-tests/src/wpt/custom-elements/HTMLElement-constructor.html.ts deleted file mode 100644 index ff3bd54..0000000 --- a/packages/web-platform-tests/src/wpt/custom-elements/HTMLElement-constructor.html.ts +++ /dev/null @@ -1,218 +0,0 @@ -import type { CompatibilityContext } from '../../shared/context.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'HTMLElement constructor must throw a TypeError when NewTarget is equal to itself', - ({ HTMLElement, customElements, TypeError }) => { - customElements.define('html-custom-element', HTMLElement); - expect(function () { - new HTMLElement(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'HTMLElement constructor must throw a TypeError when NewTarget is equal to itself via a Proxy object', - ({ HTMLElement, customElements, TypeError }) => { - customElements.define('html-proxy-custom-element', new Proxy(HTMLElement, {})); - expect(function () { - new HTMLElement(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'HTMLElement constructor must throw TypeError when it has not been defined by customElements.define', - ({ HTMLElement, TypeError }) => { - class SomeCustomElement extends HTMLElement {} - expect(function () { - new SomeCustomElement(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'Custom element constructor must throw TypeError when it does not extend HTMLElement', - ({ customElements, HTMLParagraphElement, TypeError }) => { - class SomeCustomElement extends HTMLParagraphElement {} - customElements.define('some-custom-element', SomeCustomElement); - expect(function () { - new SomeCustomElement(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'Custom element constructor must throw TypeError when it does not extend the proper element interface', - ({ customElements, HTMLButtonElement, TypeError }) => { - class SomeCustomButtonElement extends HTMLButtonElement {} - customElements.define('some-custom-button-element', SomeCustomButtonElement, { - extends: 'p', - }); - expect(function () { - new SomeCustomButtonElement(); - }).toThrow(expect.objectContaining({ constructor: TypeError })); - }, - ); - context.test( - 'HTMLElement constructor must infer the tag name from the element interface', - ({ document, HTMLElement, customElements, Element, Node }) => { - class CustomElementWithInferredTagName extends HTMLElement {} - customElements.define('inferred-name', CustomElementWithInferredTagName); - - var instance = new CustomElementWithInferredTagName(); - expect(instance instanceof Element, 'A custom element must inherit from Element').toBe(true); - expect(instance instanceof Node, 'A custom element must inherit from Node').toBe(true); - expect(instance.localName).toBe('inferred-name'); - expect(instance.nodeName).toBe('INFERRED-NAME'); - expect(instance.namespaceURI, 'A custom HTML element must use HTML namespace').toBe( - 'http://www.w3.org/1999/xhtml', - ); - - document.body.appendChild(instance); - expect( - document.body.lastChild, - 'document.body.appendChild must be able to insert a custom element', - ).toBe(instance); - expect( - document.querySelector('inferred-name'), - 'document.querySelector must be able to find a custom element by its tag name', - ).toBe(instance); - }, - ); - context.test( - 'HTMLElement constructor must allow subclassing a custom element', - ({ HTMLElement, customElements }) => { - class ConcreteCustomElement extends HTMLElement {} - class SubCustomElement extends ConcreteCustomElement {} - customElements.define('concrete-custom-element', ConcreteCustomElement); - customElements.define('sub-custom-element', SubCustomElement); - - var instance = new ConcreteCustomElement(); - expect(instance instanceof ConcreteCustomElement).toBe(true); - expect(instance instanceof SubCustomElement).toBe(false); - expect(instance.localName).toBe('concrete-custom-element'); - expect(instance.nodeName).toBe('CONCRETE-CUSTOM-ELEMENT'); - - var instance = new SubCustomElement(); - expect(instance instanceof ConcreteCustomElement).toBe(true); - expect(instance instanceof SubCustomElement).toBe(true); - expect(instance.localName).toBe('sub-custom-element'); - expect(instance.nodeName).toBe('SUB-CUSTOM-ELEMENT'); - }, - ); - context.test( - 'HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement', - ({ HTMLElement, customElements }) => { - class AbstractCustomElement extends HTMLElement {} - class ConcreteSubCustomElement extends AbstractCustomElement {} - customElements.define('concrete-sub-custom-element', ConcreteSubCustomElement); - - var instance = new ConcreteSubCustomElement(); - expect(instance instanceof AbstractCustomElement).toBe(true); - expect(instance instanceof ConcreteSubCustomElement).toBe(true); - expect(instance.localName).toBe('concrete-sub-custom-element'); - expect(instance.nodeName).toBe('CONCRETE-SUB-CUSTOM-ELEMENT'); - }, - ); - context.test( - 'HTMLElement constructor must only get .prototype once, calling proxy constructor directly', - ({ HTMLElement, customElements }) => { - class SomeCustomElement extends HTMLElement {} - var getCount = 0; - var countingProxy = new Proxy(SomeCustomElement, { - get: function (target, prop, receiver) { - if (prop == 'prototype') { - ++getCount; - } - return Reflect.get(target, prop, receiver); - }, - }); - customElements.define('success-counting-element-1', countingProxy); - // define() gets the prototype of the constructor it's passed, so - // reset the counter. - getCount = 0; - var instance = new countingProxy(); - expect(getCount, 'Should have gotten .prototype once').toBe(1); - expect(instance instanceof countingProxy).toBe(true); - expect(instance instanceof HTMLElement).toBe(true); - expect(instance instanceof SomeCustomElement).toBe(true); - expect(instance.localName).toBe('success-counting-element-1'); - expect(instance.nodeName).toBe('SUCCESS-COUNTING-ELEMENT-1'); - }, - ); - context.test( - 'HTMLElement constructor must only get .prototype once, calling proxy constructor via Reflect', - ({ HTMLElement, customElements }) => { - class SomeCustomElement extends HTMLElement {} - var getCount = 0; - var countingProxy = new Proxy(SomeCustomElement, { - get: function (target, prop, receiver) { - if (prop == 'prototype') { - ++getCount; - } - return Reflect.get(target, prop, receiver); - }, - }); - customElements.define('success-counting-element-2', countingProxy); - // define() gets the prototype of the constructor it's passed, so - // reset the counter. - getCount = 0; - var instance = Reflect.construct(HTMLElement, [], countingProxy); - expect(getCount, 'Should have gotten .prototype once').toBe(1); - expect(instance instanceof countingProxy).toBe(true); - expect(instance instanceof HTMLElement).toBe(true); - expect(instance instanceof SomeCustomElement).toBe(true); - expect(instance.localName).toBe('success-counting-element-2'); - expect(instance.nodeName).toBe('SUCCESS-COUNTING-ELEMENT-2'); - }, - ); - context.test( - 'HTMLElement constructor must only get .prototype once, calling proxy constructor via Reflect with no inheritance', - ({ HTMLElement, customElements }) => { - class SomeCustomElement {} - var getCount = 0; - var countingProxy = new Proxy(SomeCustomElement, { - get: function (target, prop, receiver) { - if (prop == 'prototype') { - ++getCount; - } - return Reflect.get(target, prop, receiver); - }, - }); - customElements.define( - 'success-counting-element-3', - countingProxy as unknown as CustomElementConstructor, - ); - // define() gets the prototype of the constructor it's passed, so - // reset the counter. - getCount = 0; - var instance = Reflect.construct(HTMLElement, [], countingProxy); - expect(getCount, 'Should have gotten .prototype once').toBe(1); - expect(instance instanceof countingProxy).toBe(true); - expect(instance instanceof SomeCustomElement).toBe(true); - expect(instance.localName).toBe(undefined); - expect(instance.nodeName).toBe(undefined); - }, - ); - context.test( - 'HTMLElement constructor must not get .prototype until it finishes its registration sanity checks, calling via Reflect', - ({ HTMLElement, TypeError }) => { - class SomeCustomElement extends HTMLElement {} - var getCount = 0; - var countingProxy = new Proxy(SomeCustomElement, { - get: function (target, prop, receiver) { - if (prop == 'prototype') { - ++getCount; - } - return Reflect.get(target, prop, receiver); - }, - }); - - // Purposefully don't register it. - expect(function () { - Reflect.construct(HTMLElement, [], countingProxy); - }, "Should not be able to construct an HTMLElement named 'button'").toThrow( - expect.objectContaining({ constructor: TypeError }), - ); - expect(getCount, 'Should never have gotten .prototype').toBe(0); - }, - ); -} diff --git a/packages/web-platform-tests/src/wpt/custom-elements/adopted-callback.html.ts b/packages/web-platform-tests/src/wpt/custom-elements/adopted-callback.html.ts deleted file mode 100644 index eae101d..0000000 --- a/packages/web-platform-tests/src/wpt/custom-elements/adopted-callback.html.ts +++ /dev/null @@ -1,452 +0,0 @@ -import type { CompatibilityContext } from '../../shared/context.ts'; -import { documentNames, document_types } from './resources/custom-elements-helpers.js.ts'; - -export function register(context: CompatibilityContext): void { - const { expect } = context.runner; - context.test( - 'Inserting a custom element into the owner document must not enqueue and invoke adoptedCallback', - ({ document, HTMLElement, customElements }) => { - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - var instance = document.createElement('my-custom-element'); - calls = []; - document.body.appendChild(instance); - { - const actualArray = calls; - const expectedArray = ['connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }, - ); - for (const [index, documentName] of documentNames.entries()) { - if (index === 0) continue; - context.test( - 'Inserting a custom element into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - calls = []; - doc.documentElement.appendChild(instance); - { - const actualArray = calls; - const expectedArray = ['adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Moving a custom element from the owner document into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - document.body.appendChild(instance); - calls = []; - doc.documentElement.appendChild(instance); - { - const actualArray = calls; - const expectedArray = ['disconnected', 'adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Inserting an ancestor of custom element into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - var parent = document.createElement('div'); - parent.appendChild(instance); - calls = []; - doc.documentElement.appendChild(parent); - { - const actualArray = calls; - const expectedArray = ['adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Moving an ancestor of custom element from the owner document into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - var parent = document.createElement('div'); - parent.appendChild(instance); - document.body.appendChild(parent); - calls = []; - doc.documentElement.appendChild(parent); - { - const actualArray = calls; - const expectedArray = ['disconnected', 'adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Inserting a custom element into a shadow tree in ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); - var shadowRoot = host.attachShadow({ mode: 'closed' }); - doc.documentElement.appendChild(host); - - calls = []; - shadowRoot.appendChild(instance); - { - const actualArray = calls; - const expectedArray = ['adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Inserting the shadow host of a custom element into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - var host = document.createElement('div'); - var shadowRoot = host.attachShadow({ mode: 'closed' }); - shadowRoot.appendChild(instance); - - calls = []; - doc.documentElement.appendChild(host); - { - const actualArray = calls; - const expectedArray = ['adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - 'Moving the shadow host of a custom element from the owner document into ' + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - var instance = document.createElement('my-custom-element'); - var host = document.createElement('div'); - var shadowRoot = host.attachShadow({ mode: 'closed' }); - shadowRoot.appendChild(instance); - document.body.appendChild(host); - - calls = []; - doc.documentElement.appendChild(host); - { - const actualArray = calls; - const expectedArray = ['disconnected', 'adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - "Moving the shadow host's shadow of a custom element from the owner document into " + - documentName + - ' must enqueue and invoke adoptedCallback', - async (fixture) => { - const { document, HTMLElement, customElements } = fixture; - const getDocument = document_types(document, fixture.Document)[index]!.create; - var calls: unknown[] = []; - class MyCustomElement extends HTMLElement { - connectedCallback() { - calls.push('connected'); - } - adoptedCallback(oldDocument: Document, newDocument: Document) { - calls.push('adopted'); - calls.push(oldDocument); - calls.push(newDocument); - } - disconnectedCallback() { - calls.push('disconnected'); - } - } - customElements.define('my-custom-element', MyCustomElement); - - return getDocument().then(function (doc) { - const instance = document.createElement('my-custom-element'); - const host = document.createElement('div'); - const shadowRoot = host.attachShadow({ mode: 'closed' }); - shadowRoot.appendChild(instance); - document.body.appendChild(host); - - calls = []; - doc.documentElement.appendChild(shadowRoot); - { - const actualArray = calls; - const expectedArray = ['disconnected', 'adopted', document, doc, 'connected']; - expect(actualArray.length).toBe(expectedArray.length); - for (let index = 0; index < expectedArray.length; index++) - expect(actualArray[index]).toBe(expectedArray[index]); - } - }); - }, - ); - context.test( - "Moving the