Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ext/web): add [[ErrorData]] slot to DOMException #27342

Merged
Merged
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
15 changes: 9 additions & 6 deletions ext/web/01_dom_exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

import { primordials } from "ext:core/mod.js";
const {
Error,
ErrorPrototype,
ErrorCaptureStackTrace,
ObjectDefineProperty,
ObjectCreate,
ObjectEntries,
ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
ReflectConstruct,
Symbol,
SymbolFor,
} = primordials;
Expand Down Expand Up @@ -107,12 +108,14 @@ class DOMException {
);
const code = nameToCodeMapping[name] ?? 0;

this[_message] = message;
this[_name] = name;
this[_code] = code;
this[webidl.brand] = webidl.brand;
// execute Error constructor to have stack property and [[ErrorData]] internal slot
const error = ReflectConstruct(Error, [], new.target);
error[_message] = message;
error[_name] = name;
error[_code] = code;
error[webidl.brand] = webidl.brand;

ErrorCaptureStackTrace(this, DOMException);
return error;
}

get message() {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_node/util_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Deno.test({
fn() {
assert(util.types.isNativeError(new Error()));
assert(util.types.isNativeError(new TypeError()));
assert(!util.types.isNativeError(new DOMException()));
assert(util.types.isNativeError(new DOMException()));
},
});

Expand Down
15 changes: 5 additions & 10 deletions tests/wpt/runner/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3594,16 +3594,13 @@
"DOMException-constructor-behavior.any.html": true,
"DOMException-constructor-behavior.any.worker.html": true,
"DOMException-custom-bindings.any.html": true,
"DOMException-custom-bindings.any.worker.html": true
"DOMException-custom-bindings.any.worker.html": true,
"exceptions.html": false
},
"class-string-interface.any.html": true,
"class-string-interface.any.worker.html": true,
"class-string-iterator-prototype-object.any.html": [
"Object.prototype.toString applied after deleting @@toStringTag"
],
"class-string-iterator-prototype-object.any.worker.html": [
"Object.prototype.toString applied after deleting @@toStringTag"
],
"class-string-iterator-prototype-object.any.html": true,
"class-string-iterator-prototype-object.any.worker.html": true,
"class-string-named-properties-object.window.html": false,
"global-immutable-prototype.any.html": [
"Setting to a different prototype"
Expand Down Expand Up @@ -9754,16 +9751,14 @@
"structured-cloning-error-stack-optional.sub.window.html": [
"page-created Error (cross-site iframe)",
"page-created Error (same-origin iframe)",
"page-created DOMException (structuredClone())",
"page-created DOMException (cross-site iframe)",
"page-created DOMException (same-origin iframe)",
"JS-engine-created TypeError (cross-site iframe)",
"JS-engine-created TypeError (same-origin iframe)",
"web API-created TypeError (cross-site iframe)",
"web API-created TypeError (same-origin iframe)",
"web API-created DOMException (cross-site iframe)",
"web API-created DOMException (same-origin iframe)",
"page-created DOMException (worker)"
"web API-created DOMException (same-origin iframe)"
],
"transfer-errors.window.html": false,
"window-postmessage.window.html": false
Expand Down
Loading