diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js
index d654d07317f7ea..f50ebac2e37122 100644
--- a/ext/web/01_dom_exception.js
+++ b/ext/web/01_dom_exception.js
@@ -7,7 +7,7 @@
///
///
-import { primordials } from "ext:core/mod.js";
+import { core, primordials } from "ext:core/mod.js";
const {
Error,
ErrorPrototype,
@@ -137,6 +137,18 @@ class DOMException {
error[_name] = name;
error[_code] = code;
error[webidl.brand] = webidl.brand;
+ ObjectDefineProperty(error, core.hostObjectBrand, {
+ __proto__: null,
+ value: () => ({
+ type: "DOMException",
+ message,
+ name,
+ stack: error.stack,
+ }),
+ enumerable: false,
+ configurable: false,
+ writable: false,
+ });
return error;
}
@@ -217,4 +229,18 @@ for (let i = 0; i < entries.length; ++i) {
ObjectDefineProperty(DOMException.prototype, key, desc);
}
+core.registerCloneableResource("DOMException", (data) => {
+ const ex = new DOMException(data.message, data.name);
+ if (data.stack !== undefined) {
+ ObjectDefineProperty(ex, "stack", {
+ __proto__: null,
+ value: data.stack,
+ configurable: true,
+ writable: true,
+ enumerable: false,
+ });
+ }
+ return ex;
+});
+
export { DOMException, DOMExceptionPrototype };
diff --git a/tests/wpt/runner/expectations/html.json b/tests/wpt/runner/expectations/html.json
index 70937b21810306..83c8246f4b5bf9 100644
--- a/tests/wpt/runner/expectations/html.json
+++ b/tests/wpt/runner/expectations/html.json
@@ -1154,9 +1154,7 @@
"ImageData object can be cloned",
"ImageData expandos are not cloned",
"Document objects cannot be cloned",
- "URIError objects from other realms are treated as URIError",
- "DOMException objects can be cloned",
- "DOMException objects created by the UA can be cloned"
+ "URIError objects from other realms are treated as URIError"
]
}
},
diff --git a/tests/wpt/runner/expectations/streams.json b/tests/wpt/runner/expectations/streams.json
index af6adac3f9ffba..b516b975739a5c 100644
--- a/tests/wpt/runner/expectations/streams.json
+++ b/tests/wpt/runner/expectations/streams.json
@@ -184,15 +184,10 @@
"readable-stream.html": {
"expectedFailures": [
"cancel should be propagated to the original",
- "cancel should abort a pending read()",
- "transferring a non-serializable chunk should error both sides"
- ]
- },
- "reason.html": {
- "expectedFailures": [
- "DOMException errors should be preserved"
+ "cancel should abort a pending read()"
]
},
+ "reason.html": true,
"service-worker.https.html": false,
"shared-worker.html": false,
"transform-stream-members.any.html": true,
@@ -204,10 +199,6 @@
]
},
"worker.html": true,
- "writable-stream.html": {
- "expectedFailures": [
- "writing a unclonable object should error the stream"
- ]
- }
+ "writable-stream.html": true
}
}