Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(wpt): honor DOMException assertion constructors and realms
ldm05ab69e4aac44
diff --git a/moli-core/tests/wpt_compat.rs b/moli-core/tests/wpt_compat.rsindex 036f17c75..72829289e 100644--- a/moli-core/tests/wpt_compat.rs+++ b/moli-core/tests/wpt_compat.rs@@ -75,6 +75,7 @@ wpt_compat_cases! {wpt_compat_case_cssstyledeclaration_basic => "cssstyledeclaration-basic",wpt_compat_case_eventtarget_idlharness => "eventtarget-idlharness",wpt_compat_case_idlharness_shim_basic => "idlharness-shim-basic",+ wpt_compat_case_testharness_dom_exception_assertions => "testharness-dom-exception-assertions",wpt_compat_case_cssstyledeclaration_idlharness => "cssstyledeclaration-idlharness",wpt_compat_case_cssstylesheet_idlharness => "cssstylesheet-idlharness",wpt_compat_case_upstream_css_css_properties_values_api_property_cascade => "upstream-css-css-properties-values-api-property-cascade",diff --git a/moli-wpt-compat/fixtures/wpt/manifest.toml b/moli-wpt-compat/fixtures/wpt/manifest.tomlindex ac7494cce..23356d6b3 100644--- a/moli-wpt-compat/fixtures/wpt/manifest.toml+++ b/moli-wpt-compat/fixtures/wpt/manifest.toml@@ -20633,3 +20633,17 @@ source_path = "workers/semantics/xhr/006.html"source_commit = "a03603fe9af6230a12f1b2fb2c18a7d003a0d937"tags = ["sharedworker", "worker", "xhr", "sync-xhr", "baseurl"]notes = "Imported upstream WPT SharedWorker synchronous XMLHttpRequest coverage for resolving relative URLs against the shared worker script directory. Uses the long local timeout because full-workspace nextest can run many fixture servers and worker runtimes concurrently before this window/iframe/SharedWorker chain reports its first subtest."++[[test]]+id = "testharness-dom-exception-assertions"+upstream = "local WPT harness DOMException assertion overload and realm canary"+upstream_commit = "local-regression-2026-09-20"+local_path = "ported/harness/dom-exception-assertions.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+tags = ["testharness", "domexception", "cross-realm"]+notes = "Local harness canary for implicit and explicit DOMException constructors, cross-realm exceptions, and rejection of incorrect constructors or missing exceptions."diff --git a/moli-wpt-compat/fixtures/wpt/ported/harness/dom-exception-assertions.html b/moli-wpt-compat/fixtures/wpt/ported/harness/dom-exception-assertions.htmlnew file mode 100644index 000000000..ac9629970--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/ported/harness/dom-exception-assertions.html@@ -0,0 +1,48 @@+<!doctype html>+<meta charset="utf-8">+<script src="/wpt/resources/testharness.js"></script>+<script src="/wpt/resources/testharnessreport.js"></script>+<script src="/wpt/resources/moli-wpt-adapter.js"></script>+<body>+<script>+test(() => {+ const error = new DOMException("canceled", "AbortError");+ const fail = () => { throw error; };+ assert_throws_dom("AbortError", fail);+ assert_throws_dom("AbortError", fail, "implicit current realm");+ assert_throws_dom("AbortError", DOMException, fail);+ assert_throws_dom("AbortError", DOMException, fail, "explicit current realm");+}, "DOM exception assertions accept implicit and explicit constructors");++test(t => {+ const frame = document.createElement("iframe");+ document.body.appendChild(frame);+ t.add_cleanup(() => frame.remove());+ const ForeignDOMException = frame.contentWindow.DOMException;+ assert_not_equals(ForeignDOMException, DOMException);+ const foreign = new ForeignDOMException("canceled", "AbortError");+ assert_throws_dom("AbortError", ForeignDOMException, () => { throw foreign; });+ assert_throws_js(AssertionError, () => {+ assert_throws_dom("AbortError", DOMException, () => { throw foreign; });+ });+ assert_throws_js(AssertionError, () => {+ assert_throws_dom("AbortError", () => { throw foreign; });+ });+}, "DOM exception assertions enforce the selected realm");++test(() => {+ for (const error of [+ {name: "AbortError"},+ Object.assign(new Error("wrong constructor"), {name: "AbortError"}),+ new DOMException("wrong name", "InvalidStateError"),+ ]) {+ assert_throws_js(AssertionError, () => {+ assert_throws_dom("AbortError", DOMException, () => { throw error; });+ });+ }+ assert_throws_js(AssertionError, () => assert_throws_dom("AbortError", DOMException, () => {}));+ assert_throws_js(AssertionError, () => assert_throws_dom("AbortError", () => {}, "description", "extra"));+ const error = new AssertionError("nested assertion");+ assert_throws_exactly(error, () => assert_throws_dom("AbortError", () => { throw error; }));+}, "DOM exception assertions reject mismatches and preserve nested assertions");+</script>diff --git a/moli-wpt-compat/fixtures/wpt/resources/testharness.js b/moli-wpt-compat/fixtures/wpt/resources/testharness.jsindex 7ef5d78ef..3caab9a4f 100644--- a/moli-wpt-compat/fixtures/wpt/resources/testharness.js+++ b/moli-wpt-compat/fixtures/wpt/resources/testharness.js@@ -836,12 +836,30 @@throw assertionError((description || "assert_throws_exactly") + ": did not throw");};- global.assert_throws_dom = function (name, callback, description) {+ global.assert_throws_dom = function (name, funcOrConstructor, descriptionOrFunc, maybeDescription) {+ let constructor = global.DOMException;+ let callback = funcOrConstructor;+ let description = descriptionOrFunc;+ if (typeof funcOrConstructor === "function" && funcOrConstructor.name === "DOMException") {+ constructor = funcOrConstructor;+ callback = descriptionOrFunc;+ description = maybeDescription;+ } else if (maybeDescription !== undefined) {+ throw assertionError("Too many args passed to no-constructor version of assert_throws_dom");+ }const expectedName = domExceptionLegacyNames[name] || name;try {callback();} catch (error) {+ if (error instanceof global.AssertionError) {+ throw error;+ }if (error && error.name === expectedName) {+ if (error.constructor !== constructor) {+ throw assertionError(+ (description || "assert_throws_dom") + ": exception came from the wrong global",+ );+ }return;}throw assertionError(