Commit Graph
1644 Commits
Author SHA1 Message Date
ldm0 51455017c5 fix(parser): respect script nesting for stylesheet waits 2026-09-23 00:14:09 +08:00
ldm0 91368fe52f fix(runtime): admit document lifecycle during awaited evaluation 2026-09-23 00:14:09 +08:00
ldm0 d84059e00c fix(script): report document.write script exceptions
Use the shared source executor for written main-document scripts so syntax and runtime exceptions reach their Window without escaping to the writer. Preserve script provenance, cleanup, and load events for fetched classic scripts after execution errors.

Add four main/child parser regressions. Verified with fmt, strict workspace Clippy, 19478 passing nextest tests, 84 Chromium comparison checks, and 62 WPT pages without new failures.
2026-09-23 00:14:09 +08:00
ldm0 a8955e6ea1 fix(parser): preserve nested document.write insertion points
Keep blocked writes with the input position saved by each parser script. Share the context between main and child parsers so external-script suspension preserves nested caller tails and consecutive write order.

Add four integration regressions across main/child and navigation/script-created parsers. Validated with fmt, strict workspace Clippy, 19474 passing nextest tests, 18 Chromium comparison checks, and 50 WPT pages without new failures.
2026-09-23 00:14:09 +08:00
ldm0 d341b0b48d fix(dom): dispatch document streams by their receiver
Use the realm Document prototype bindings instead of frame-captured own
methods, so borrowed calls and retained Documents select their own parser.
Validate native receivers before conversion and use the receiver global for
Trusted Types requirements and default policies.

Clear listeners through actual parent and shadow-host relationships when
replacing a retired document tree, preserving listeners outside that tree.

Validation: cargo fmt --all; strict all-feature, all-target workspace Clippy;
cargo nextest run --no-fail-fast (19,470 passed, 13 skipped); 392 fixture
tests; 179/179 cross-engine probe checks. The active.window.js WPT improves
from 4/7 to 7/7 with no new failures across the comparison set.
2026-09-23 00:14:09 +08:00
ldm0 0f4983d23b test(webidl): cover Document lifecycle receiver attributes
Exercise wasDiscarded with the other branded Document attributes and verify
LegacyLenientThis behavior for onreadystatechange across both realms.

Validation: cargo fmt --all; strict all-feature, all-target workspace Clippy;
cargo nextest run --no-fail-fast (19,470 passed, 13 skipped).
2026-09-23 00:14:09 +08:00
ldm0 31c94ffba0 fix(dom): preserve windowless document parser streams 2026-09-23 00:14:09 +08:00
ldm0 62d497a77a fix(dom): preserve document clone URLs, modes and encodings 2026-09-23 00:14:09 +08:00
ldm0 dbb70ca46b fix(dom): return empty shallow clones of detached HTML documents
Clear the initialized HTML shell before returning a shallow Document clone.
This removes the unexpected doctype/root and allows callers to append a new
document element. Deep clones still copy the source children.

Cover omitted/false/undefined deep arguments, rootless and custom-root HTML,
doctype-only documents, XHTML/XML controls, and preserved source identity.
All 273 shared browser assertions pass; 15 upstream cases retain all 1442
passing subtests.

Validation: cargo fmt --all; workspace/all-targets/all-features Clippy with
-D warnings; cargo nextest run --no-fail-fast (19464 passed, 13 skipped).
2026-09-23 00:14:09 +08:00
ldm0 4787f31632 fix(dom): preserve document content types for element creation
Resolve the default element namespace from internal Document metadata instead
of the current root element. Initialize native and detached MIME state together
and preserve it when cloning, without reading overwritten public properties.

Cover parser MIME types, root replacement, shallow/deep clones, explicit
namespaces and getter overrides with 689 shared browser/Rust assertions.
Document-createElement-namespace.html now passes all 51 subtests; all 13
related upstream cases pass (1438 subtests).

Validation: cargo fmt --all; workspace/all-targets/all-features Clippy with
-D warnings; cargo nextest run --no-fail-fast (19463 passed, 13 skipped).
2026-09-23 00:14:09 +08:00
ldm0 ade7fbc5a1 fix(dom): preserve retained iframe document creation and identity
Keep Document registry associations after iframe removal and resolve default
registry objects through the Document realm's intrinsic cache. Preserve reachable
DOM wrappers with weak entries before retiring child execution contexts,
including prebootstrapped realms, without reviving inactive scripts.

Cover blank/srcdoc documents, cross-task registry operations, lazy creation with
replaced public properties, wrapper identity, and garbage collection.

Validation: cargo fmt --all; workspace/all-targets/all-features clippy with
-D warnings; cargo nextest run --no-fail-fast (19462 passed, 13 skipped).
All 52 browser assertions pass; 21 upstream WPT results retain the baseline
20 passes and one existing DOMParser XHTML namespace failure.
2026-09-23 00:14:09 +08:00
ldm0 4aec55df56 fix(scripts): execute child inline classics synchronously
Prepare connected script candidates after DOM mutation borrows are released
and execute child inline classics before the inserting DOM call returns.
Reuse the child realm runner for CSP, error reporting and execution cleanup;
remove the obsolete queued DynamicClassic work and preserve currentScript
on the execution Document across nested scripts and adoption.

Cover initial about:blank, srcdoc, reentrant fragments, script errors,
Shadow DOM, retirement and microtask order. Move three location WPT cases
to passed and the newly observable window.open referrer failure to failed.

Validation: cargo fmt --all; full workspace clippy with all targets and
features and -D warnings; cargo nextest run --no-fail-fast (19457 passed,
13 skipped). 35 related WPT cases show no previously passing regression;
104 timing/CSP checks pass against Chromium. The running-script shadow
movement probe follows the HTML currentScript algorithm and differs from
Chromium 145; both official Shadow DOM WPT cases pass.
2026-09-23 00:14:09 +08:00
ldm0 506b2d4dc4 fix: reconcile WPT bindings and layout state after main rebase
Keep strict Element receiver checks and bind ShadowRoot.onslotchange through
its generated native brand check. Deduplicate replayed helpers, modules and
identical visibility regressions.

Invalidate style observations only when StyleViewport changes, and update the
visual-state generation independently so CDP presentation changes still emit
screencast frames. Align the Grid regression's CSSOM and capture viewports
without changing its value or layout-count assertions. Format the merged
parser and layout code.

Validation: cargo fmt --all; strict all-feature, all-target workspace Clippy;
cargo nextest run --no-fail-fast; workspace Moli build; 665 Python tests;
80 CSP WPT cases retain exactly the same results as before the rebase.
2026-09-23 00:14:09 +08:00
ldm0 313b9b1826 fix(csp): normalize base64url inline hashes 2026-09-23 00:14:09 +08:00
ldm0 38d43bd9c9 fix(worker): enforce CSP for WebAssembly compilation 2026-09-23 00:14:09 +08:00
ldm0 2d18ec7a16 fix(csp): preserve parsed source token boundaries 2026-09-23 00:14:09 +08:00
ldm0 e4857c6bf0 feat(dom): add Observable error recovery
Add catch(callback) with native receiver and callback bindings. Forward source
values and completion, then convert the catcher's return value into one recovery
subscription after a source error. Recovery errors go directly downstream.

Replace the traced upstream observer when recovery starts so pending Promises
retain the replacement producer without retaining the exhausted source and
catcher. Reuse the existing signal-owned cancellation algorithms.

Cover Window/Worker conversion, error identity, shared subscriptions, reentrant
cancellation, teardown ordering, realms and GC. Verify all nine upstream catch
subtests in both realms and add those cases to the pass catalogue.
2026-09-23 00:14:09 +08:00
ldm0 d63d679b7c feat(dom): add Observable switchMap subscriptions
Cancel the previous inner before mapping each source value, convert mapper
results through the native Observable path, and wait for active inner
completion after the source completes. Preserve the draft's shared controller
reference under reentrant mapper, conversion and teardown callbacks.

Trace each live inner and release replaced observers without persistent roots
outside the existing signal stores. Finish Window and Worker dependent abort
dispatch after IteratorClose failures, then propagate the first exception.

Cover Window and Worker conversion, switching, cancellation, cross-realm
receivers and callbacks, GC, and reentrant synchronous completion. Verify 61
related WPT cases: 576/592 to 590/592 subtests, no regressions. Add switchMap
and finally Window/Worker cases to the verified pass catalogue.
2026-09-23 00:14:09 +08:00
ldm0 0ba8a821f2 feat(dom): add serial Observable flatMap subscriptions
Queue source values until each mapped inner subscription completes, preserving
mapper indices, synchronous completion order, sharing and callback realms.
Trace the producer graph in V8 and release exhausted sources and queued values.

Finish shared abort algorithms before rethrowing the first IteratorClose
failure so cancellation always reaches both source and inner producers.
Cover Window/worker behavior, reentrancy, cancellation, realms and GC lifetimes.
2026-09-23 00:14:09 +08:00
ldm0 7a79fd946b feat(dom): add Observable finalization callbacks
Register finally callbacks through the existing Subscriber teardown path and
forward notifications with a native observer. Preserve cleanup ordering,
original terminal outcomes and callback-realm exception reporting.

Cover shared consumers, pre-abort, reentrant subscription, iterator-close
failures, Window/worker behavior, cross-realm calls and GC lifetimes.
2026-09-23 00:14:09 +08:00
ldm0 cd2f0b6f34 fix(webidl): make the Window global prototype chain immutable
Build WindowProperties into the native template inheritance chain before
context creation so Window.prototype and EventTarget.prototype can keep
immutable prototypes while remaining extensible. Link Window's interface
constructor to EventTarget as well.

Preserve WindowProperties visibility and exotic mutation rules through
native interceptors, including inherited accessors, different receivers,
numeric names and symbols. Remove the post-bootstrap Proxy insertion.

Cover main and child realms with 186 regression assertions, verify
cross-origin navigation and promote the passing immutable-prototype WPT.
2026-09-23 00:14:09 +08:00
ldm0 62dd58bded fix(workers): inherit EventTarget across worker global scopes
Build dedicated, shared and service worker globals from the native
EventTarget template before context creation. Preserve immutable global
prototype chains and explicitly link the Web IDL interface constructors.

Cover all three worker kinds with the same regression fixture, including
inherited when(), event delivery, cancellation, global error reporting,
receiver branding and replacement of the public EventTarget constructor.

Promote the passing worker inspect and immutable-prototype WPT cases.
2026-09-23 00:14:09 +08:00
ldm0 2a2f00575c feat(dom): add Observable inspection hooks
Convert inspector callbacks through the shared observer conversion boundary and
invoke them before source notifications. Remove the abort hook on producer
termination, report consumer-abort callback errors in their own realm, and trace
pending subscriptions without retaining abandoned callbacks.

Cover Window/Worker behavior, conversion order, reentrancy, cleanup errors,
callback realms and garbage collection. Fix 27 WPT subtests, including the two
takeUntil-toArray crashtests; worker-global when exposure remains a separate fix.
2026-09-23 00:14:09 +08:00
ldm0 3bbb742fde feat(dom): add Observable takeUntil
Convert notifier inputs using the native Observable conversion path, subscribe
to the notifier first, and share downstream cancellation across both inputs.
Notifier next/error completes downstream; notifier completion leaves the source
running and releases the exhausted notifier graph.

Cover receiver and conversion semantics, sharing, reentrancy, cleanup errors,
cross-realm results, Window/Worker behavior and garbage collection. Add the
three passing takeUntil WPT cases, fixing 26 subtests without regressions.
2026-09-23 00:14:08 +08:00
ldm0 96d2b190d6 feat(dom): add Observable take and drop operators
Reuse lazy native transform subscriptions for take/drop, preserving shared
counts, reentrant notification ordering, cancellation and early completion.
Keep each subscription's unsigned 64-bit count in a traced BigInt slot.

Fix unsigned-long-long conversion losing low bits for negative values by
applying the sign wrap in u64 after converting the magnitude. Add count,
conversion, Window/worker, realm, iterator-close and GC regression coverage.

Validation: fmt, all-target/all-feature workspace clippy, 172 targeted tests,
full nextest (19,297 passed; 13 skipped), 194 runtime checks, 40 realm checks,
and 43 WPT cases improving from 441/469 to 467/469 without regressions.
2026-09-23 00:14:08 +08:00
ldm0 96681ab08a feat(dom): add lazy Observable map and filter
Share native transform observers and callback indices across Window and worker
bindings. Trace live upstream chains without rooting abandoned subscriptions,
and release observer state after cancellation and pre-aborted subscriptions.

Preserve callback errors and terminal notifications when iterator closing fails,
finish teardown before propagating explicit cancellation errors, and cover
sharing, reentrancy, cross-realm calls, native lifetimes and mutable globals.

Validation: fmt, workspace clippy with all targets/features, full nextest
(19,292 passed; 13 skipped), 201 Window/worker fixture checks, 40 realm checks,
and 39 WPT cases improving from 416/443 to 441/443 subtests without regressions.
2026-09-23 00:14:08 +08:00
ldm0 0bc09d0861 feat(dom): add Observable some, every and find
Resolve predicate consumers on the first deciding value and cancel only
their own observer. Reuse traced WebIDL callbacks and native Promise state,
with boolean predicate conversion and reentrant settlement protection.

Cover shared subscriptions, conversion order, exception identity, worker
execution, callback/Promise realms, and callback lifetime after cancellation.
The focused WPT set improves from 364/418 to 416/418 subtests; eight complete
cases are added to the passing catalogue.

Validation: cargo fmt --all; all-targets/all-features workspace clippy with
-D warnings; CLI build; 160 focused tests; full nextest (19,287 passed,
13 skipped); 302 semantic checks in Window and worker; 48 realm checks.
2026-09-23 00:14:08 +08:00
ldm0 df54ffc84f feat(dom): consume Observables with forEach and reduce
Implement native callback-driven Promise consumers for Window and workers,
using traced WebIDL callbacks and shared cancellation/settlement helpers.
Preserve exception identity, raw reducer values, reentrant notification
ordering, callback realms, and independent subscriptions.

Add conversion, cancellation, cross-realm, GC, and worker coverage. Record
five newly passing WPT cases: the audited suites improve from 330/372 to
364/372 subtests, with EventTarget regressions remaining 150/150.

Validation: cargo fmt --all; workspace all-targets/all-features clippy with
-D warnings; CLI build; 156 focused tests; full nextest (19,283 passed,
13 skipped). The supplemental fixture passes 132 checks in both globals.
2026-09-23 00:14:08 +08:00
ldm0 c894362a2c feat(dom): collect Observable values with last and toArray
Add completion-based Promise operators in Window and workers, preserving
raw values, shared subscriptions and direct AbortSignal ordering. Reuse
the native Promise observer lifetime and settlement logic with first.

Cover receiver conversion, callee realms, thenable reentrancy, inherited
array setters and value reachability. Related WPTs improve from 302/326
to 324/326; EventTarget regressions remain 150/150.
2026-09-23 00:14:08 +08:00
ldm0 86858e7bd7 feat(dom): resolve first Observable values with native observers
Add Observable.first in Window and workers through the shared WebIDL
receiver and Promise adapters. Native observers use internal subscription
and AbortSignal dependency graphs, preserving shared producers and
reentrant Promise resolution without consulting public JS methods.

Cover thenable reentrancy, abort/teardown order, iterable closing,
callee realms, and observer reachability. Related WPTs improve from
290/304 to 302/304; EventTarget regressions remain 150/150.
2026-09-23 00:14:08 +08:00
ldm0 7d32c1eef8 feat(dom): convert iterables and promises to Observables
Implement Observable.from for Window and workers with native input brands,
per-subscription iterator records, Promise reactions and async-from-sync
adaptation. Preserve getter timing, exception identities and cancellation.

Keep private iterator abort algorithms weak in the existing signal stores,
and propagate synchronous iterator close errors through native cancellation.
Cover shared Window/worker semantics, callee realms and abandoned iterator GC.

The two official from variants improve from 2/48 to 46/48 each. Retain the
next-getter timing discrepancy and the unimplemented first() dependency as
failures; the existing Observable, AbortSignal and EventTarget cases pass.
2026-09-23 00:14:08 +08:00
ldm0 db1b10c655 feat(dom): add EventTarget observable event streams
Implement EventTarget.when for Window and worker targets using native Observable subscriptions and the existing event listener and AbortSignal routes. Preserve capture/passive conversion, weak targets, native receiver brands and exact Window identity across navigation.

Cover multicast cancellation and restart, DOM propagation, public method tampering, cross-realm receivers, garbage collection and Window replacement. Add four verified WPT cases: 348/348 relevant subtests pass against Chromium. Workspace fmt, clippy and nextest pass (19267 tests, 13 skipped).
2026-09-23 00:14:08 +08:00
ldm0 f030d79519 feat(dom): implement Observable subscription lifecycle 2026-09-23 00:14:08 +08:00
ldm0 ca23e4aff2 fix(dom): return standard XML parser error documents
Replace partial XML trees with a single parsererror root in the namespace
specified by HTML's DOMParser algorithm. Keep diagnostics as text and retain
the requested content type and document metadata. XHR parsing continues to
return no document on XML errors.

Replace Chromium-specific error-wrapper assertions with coverage for empty,
malformed and namespace-invalid input, prologues, doctypes, cross-realm
documents, serialization and valid author-created parsererror elements.

Validation: workspace fmt and strict all-feature Clippy; full nextest
19258 passed, 13 skipped; 22 WPT cases / 344 subtests; 1776 JS assertions.
2026-09-23 00:14:08 +08:00
ldm0 ca9763da71 fix(dom): keep class collections live and honor quirks mode
Use the query root's current owner-document mode for ASCII class matching,
including cached collections after adoption. Standards and limited-quirks
documents retain case-sensitive matching.

Reuse native live collections for detached class queries so class changes,
tree mutations and cross-realm method calls use the current DOM. Cover
HTML, SVG, MathML, XML, whitespace and non-ASCII class names.

Validation: workspace fmt and strict all-feature Clippy; full nextest
19258 passed, 13 skipped; 37 WPT cases / 76 subtests; 813 JS assertions.
2026-09-23 00:14:08 +08:00
ldm0 af6f01210a fix(fetch): request identity encoding for HTTP ranges 2026-09-23 00:14:08 +08:00
ldm0 c27329c0f8 test(wpt): serve Fetch Range streaming resources 2026-09-23 00:14:08 +08:00
ldm0 de8e088ad5 fix(file-api): retain MediaSource targets in object URLs
Register branded MediaSource objects alongside Blob entries, preserving native
identity, creator keys and URL lifetimes. Capture the entry kind in parsed URLs
and reject MediaSource fetches with a network error.

Cover identity retention through wrapper GC and isolate teardown, revocation,
cross-realm receivers and worker consumers. Add the passing MediaSource WPT
to the catalogue.
2026-09-23 00:14:08 +08:00
ldm0 6eeff41636 fix(fetch): observe header mutations during forEach
Refresh the sorted, combined header pairs after each callback while keeping
the iteration index. Deletions, updates and additions made by script now
affect subsequent visits as required by WebIDL pair iteration.

Cover mutations, Set-Cookie entries, reentrancy, author iterator overrides,
callback Proxies and abrupt completion in Window and Worker contexts. Extend
the callback realm regression to append and visit a header from an iframe.
2026-09-23 00:14:08 +08:00
ldm0 1702a4d096 fix(fetch): preserve internal header lists across request copies
Keep normalized fields in their original order and combine them for public
iteration and header consumers. Read inherited Request headers from private
slots so mode changes preserve safe fields and do not invoke author getters.

Preserve the lists through Headers mutation, Request/Response clone and Cache
round trips, with shared Window/Worker regressions for duplicates, empty values,
public projections, script overrides and body clones.
2026-09-23 00:14:08 +08:00
ldm0 81ebcc437c fix(fetch): apply no-cors guards while filling headers
Check the combined header value before each append, both during Request/fetch
initialization and Headers.append. Reject an unsafe addition without losing
previously accepted fields, and apply the MIME parser to Content-Type parameters.

Add shared Window/Worker regression coverage for length boundaries, duplicate
fields, content types, cloning, guard overrides and Headers mutations.
2026-09-23 00:14:08 +08:00
ldm0 16ef7ac83b fix(fetch): honor byte ranges in blob URL responses
Resolve single ranges against captured Blob bytes for Window and Worker Fetch
and XHR, including partial response headers and integrity verification. Reject
malformed or unsatisfiable ranges and normalize author headers before CORS
preflight and context overrides so repeated ranges cannot lose earlier values
or skip preflight.

Cover byte boundaries, cloned and revoked URL entries, empty and binary bodies,
request guards, synchronous XHR, and partial-body integrity. Add the two passing
Blob range WPT cases to the verified catalogue.
2026-09-23 00:14:08 +08:00
ldm0 61c87dbe07 fix(fetch): enforce integrity before response handover
Preserve integrity through Window and worker fetch continuations and wait for
complete response bytes before applying the shared SRI validator. Cover local,
network, intercepted, and Service Worker responses, retaining null-body state
and abort reasons.

Add regressions for digest selection, body completion, and null versus empty
responses; preserve non-ASCII whitespace in integrity metadata parsing.
2026-09-23 00:14:08 +08:00
ldm0 c0a60dcb2f fix(fetch): include required headers in blob URL responses
Always expose Content-Length from the Blob's byte size and Content-Type
from its type, including empty values. Fetch and XHR use the same builder
for fresh and captured Blob URL entries.

Cover binary and Unicode payloads, empty types, File and slice responses,
cloned requests, and URL revocation in Window and Worker tests.
2026-09-23 00:14:08 +08:00
ldm0 639216a32b fix(xhr): validate send bodies before request state checks
Reject shared and resizable BufferSource bodies and validate receivers
through the existing WebIDL brand checks. Convert arguments before checking
send state or discarding GET/HEAD bodies, preserving coercion exceptions.

Read method and synchronization state after conversion so reentrant open()
and send() calls take effect. Defer native body extraction until conversion
and state checks finish, avoiding buffer copies for GET and HEAD.

Cover Window and Worker conversion ordering and real HTTP reentrancy.
Validation: cargo fmt --all; strict workspace/all-target/all-feature clippy;
full nextest (19236 passed, 13 skipped). Official Fetch/XHR comparison gains
2 passing cases and 28 subtests with no other changes across 154 cases.
Window, Dedicated and Shared Worker probes match Chrome on 4872 checks
and 57 actual HTTP requests.
2026-09-23 00:14:08 +08:00
ldm0 4996a1b49d fix(xhr): allow repeated synchronous requests to the same URL
Remove the per-document 32-request quota that rejected otherwise valid
synchronous XHR sends. Keep the existing script watchdog and page
cancellation, with regressions for repeated requests across objects and
script turns, plus recovery after terminating an infinite request loop.

Validation: cargo fmt --all; strict workspace/all-target/all-feature clippy;
full nextest (19233 passed, 13 skipped). The 154-case official Fetch/XHR
comparison gains one passing case and two subtests without regressions.
Window and both worker probes match Chrome on 6720 checks and 960 POSTs.
2026-09-23 00:14:08 +08:00
ldm0 40666bc3ef fix(fetch): propagate explicit referrers and preflight policies
Forward Window and Worker Fetch referrer values into the transport without
changing the request origin, cookie initiator, or network partition.
Derived preflight requests inherit referrer state and policies while keeping
other metadata, including integrity, separate.

Cover real Window and Worker requests, buffered and streaming preflights,
referrer overrides, sanitization, and request identity preservation.
2026-09-23 00:14:08 +08:00
ldm0 e8dc789fda fix(fetch): enforce request header guards on fetch initializers
Use the existing Request guard selection for Window and Worker fetch headers,
including Request inputs with overridden headers. Preserve inherited headers
when no override is supplied and retain the no-cors guard.

Cover forbidden headers, method override values, all initializer forms,
conversion exceptions, and unmodified inputs in both native fetch paths.
2026-09-23 00:14:08 +08:00
ldm0 0364991a43 fix(fetch): finalize response headers at successful EOF
Finalize pending final headers when curl completes a streaming transfer
without an empty header separator. Apply the existing cookie, cache, and
client-hint policy before the owner publishes or retries the response.

Track header finalization separately from response start, preserving
redirects and deferred 304 responses. Keep failed and cancelled transfers
on their existing error paths and cover the behavior with raw TCP tests.
2026-09-23 00:14:08 +08:00
ldm0 d60093e4bb fix(xhr): normalize script-visible response headers
Project the response header list once for all delivery paths, reusing
Headers response guards and normalization. Hide both cookie headers,
combine repeated values, and use XHR legacy uppercase-byte sorting.

Preserve the original response head for MIME processing and network
metadata; cover delivery states, credential modes, and request reuse.
2026-09-23 00:14:08 +08:00