Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c0625bcafb6cc6cf5774ecbeb47ca330fe4f0cf6
https://github.com/WebKit/WebKit/commit/c0625bcafb6cc6cf5774ecbeb47ca330fe4f0cf6
Author: Chris Dumez <[email protected]>
Date: 2026-08-10 (Mon, 10 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-is-error.any-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-is-error.any.worker-expected.txt
A LayoutTests/js/dom/dom-exception-is-error-expected.txt
A LayoutTests/js/dom/dom-exception-is-error.html
A LayoutTests/js/dom/dom-exception-tostringtag-expected.txt
A LayoutTests/js/dom/dom-exception-tostringtag.html
A LayoutTests/js/dom/script-tests/dom-exception-is-error.js
M Source/JavaScriptCore/runtime/CloneSerializerBase.h
M Source/JavaScriptCore/runtime/ErrorInstance.cpp
M Source/JavaScriptCore/runtime/ErrorInstance.h
M Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp
M Source/WebCore/bindings/js/JSDOMWrapper.h
M Source/WebCore/bindings/js/WebCoreJSClientData.cpp
M Source/WebCore/bindings/js/WebCoreJSClientData.h
M Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
M Source/WebCore/bindings/scripts/test/BindingTestGlobalConstructors.idl
M Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
M Source/WebCore/bindings/scripts/test/JS/JSTestException.h
A Source/WebCore/bindings/scripts/test/JS/JSTestExceptionSubclass.cpp
A Source/WebCore/bindings/scripts/test/JS/JSTestExceptionSubclass.h
M Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
M Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep
A Source/WebCore/bindings/scripts/test/TestExceptionSubclass.idl
Log Message:
-----------
Error.isError() should return true for
DOMException
https://bugs.webkit.org/show_bug.cgi?id=321064
<rdar://problem/183139377>
Reviewed by Yusuke Suzuki.
Per the "is-error" proposal and WebIDL PR #1421, DOMException has the
[[ErrorData]] internal slot, so Error.isError(new DOMException()) must
return true. This matches Chrome and Firefox.
- https://github.com/tc39/proposal-is-error/issues/9
- https://github.com/whatwg/webidl/pull/1421
We give DOMException the [[ErrorData]] slot by making its JS wrapper a
genuine JSC::ErrorInstance subclass (JSType ErrorInstanceType). Its
prototype already chains to Error.prototype (a pre-existing effect of the
[Exception] IDL attribute), so new DOMException() is now an Error in every
respect: Error.isError() and `instanceof Error` return true, and the
existing ErrorIsErrorIntrinsic recognizes it in the DFG/FTL with no
special casing. This also covers DOMException's subclasses (WebTransportError,
GPUPipelineError, RTCError, OverconstrainedError).
A new
JSDOMErrorWrapper<T> base (analogous to JSDOMEmbedderArrayLikeWrapper)
holds the impl Ref and derives from ErrorInstance. It deliberately skips
ErrorInstance::finishCreation so it neither captures a JS stack trace nor
adds own "message"/"stack" properties; DOMException's WebIDL attributes and
Error.prototype provide its surface, so its property set is unchanged. The
code generator routes [Exception] interfaces to this base, gives them an
ErrorInstanceType structure, and, because ErrorInstance needs destruction
but is not a JSDestructibleObject, allocates them in a subspace with a
per-class custom IsoHeapCellType, declared alongside the existing ones in
JSHeapData. ErrorInstance's constructor and property method-table entries
are exported so WebCore can subclass it.
Because a DOMException is now an ErrorInstance, WebCore's exception reporting
(retrieveErrorMessage / retrieveErrorMessageWithoutName) must describe it from
its
WebIDL name/message rather than
ErrorInstance::sanitizedToString, which only reads
own data properties (DOMException exposes name/message as inherited getters).
Those
functions now check for JSDOMException before ErrorInstance.
Structured clone must also serialize a DOMException as a DOMException rather
than as
a generic Error: CloneSerializerBase::dumpIfTerminal now gives the embedder's
dumpDerivedTerminal first refusal before its generic ErrorInstance path, so
DOMException
(and its subclasses) still round-trip through postMessage with the correct
name/code.
One consequence: Object.prototype.toString.call(domException) now reports
"[object Error]" once DOMException.prototype's @@toStringTag has been
deleted (it has [[ErrorData]], so that is the spec result). This differs
from Chrome and Firefox, which still report "[object Object]".
*
LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-is-error.any-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-is-error.any.worker-expected.txt:
* LayoutTests/js/dom/dom-exception-is-error-expected.txt: Added.
* LayoutTests/js/dom/dom-exception-is-error.html: Added.
* LayoutTests/js/dom/script-tests/dom-exception-is-error.js: Added.
* LayoutTests/js/dom/dom-exception-tostringtag-expected.txt: Added.
* LayoutTests/js/dom/dom-exception-tostringtag.html: Added.
* Source/JavaScriptCore/runtime/CloneSerializerBase.h:
* Source/JavaScriptCore/runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::finishCreation):
* Source/JavaScriptCore/runtime/ErrorInstance.h:
* Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp:
(WebCore::retrieveErrorMessageWithoutName):
(WebCore::retrieveErrorMessage):
* Source/WebCore/bindings/js/JSDOMWrapper.h:
* Source/WebCore/bindings/js/WebCoreJSClientData.cpp:
* Source/WebCore/bindings/js/WebCoreJSClientData.h:
*
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(GetParentClassName):
(GenerateImplementation):
* Source/WebCore/bindings/scripts/test/BindingTestGlobalConstructors.idl:
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestExceptionSubclass.idl: Added.
* Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestException.h:
* Source/WebCore/bindings/scripts/test/JS/JSTestExceptionSubclass.cpp: Added.
* Source/WebCore/bindings/scripts/test/JS/JSTestExceptionSubclass.h: Added.
* Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp:
Canonical link:
https://flagged.apple.com:443/proxy?t2=DC7c3G7eA7&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE4OTMwQG1haW4=&emid=83e774c3-2f1c-47f8-9cd3-414062059833&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications