Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion ext/web/01_dom_exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference path="../web/internal.d.ts" />
/// <reference path="../../cli/tsc/dts/lib.deno_web.d.ts" />

import { primordials } from "ext:core/mod.js";
import { core, primordials } from "ext:core/mod.js";
const {
Error,
ErrorPrototype,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 };
4 changes: 1 addition & 3 deletions tests/wpt/runner/expectations/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
},
Expand Down
15 changes: 3 additions & 12 deletions tests/wpt/runner/expectations/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -204,10 +199,6 @@
]
},
"worker.html": true,
"writable-stream.html": {
"expectedFailures": [
"writing a unclonable object should error the stream"
]
}
"writable-stream.html": true
}
}
Loading