This allows libraries to emulate the behavior of throwing exceptions in an event listener (triggers self.onerror). HTML change: https://github.com/whatwg/html/pull/1196. Tests: https://github.com/web-platform-tests/wpt/pull/29738.
<rdar://problem/81446162>
Created attachment 436682 [details] Patch
Comment on attachment 436682 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=436682&action=review > Source/WebCore/page/DOMWindow.cpp:1809 > + auto* exception = JSC::jsDynamicCast<JSC::Exception*>(vm, error); FYI, I initially tried to call `reportException(JSGlobalObject* lexicalGlobalObject, JSValue exceptionValue, CachedScript* cachedScript)` overload directly with the JSValue. However, for some reason, that reportException() overload doesn't capture the stack when constructing the JSC::Exception. This was causing some failures in the WPT tests as a result (things like e.filename were not populated).
(In reply to Chris Dumez from comment #3) > Comment on attachment 436682 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=436682&action=review > > > Source/WebCore/page/DOMWindow.cpp:1809 > > + auto* exception = JSC::jsDynamicCast<JSC::Exception*>(vm, error); > > FYI, I initially tried to call `reportException(JSGlobalObject* > lexicalGlobalObject, JSValue exceptionValue, CachedScript* cachedScript)` > overload directly with the JSValue. > However, for some reason, that reportException() overload doesn't capture > the stack when constructing the JSC::Exception. This was causing some > failures in the WPT tests as a result (things like e.filename were not > populated). We definitely have other issues where the stack is not captured or exposed for DOM related errors: http://wpt.live/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.html
Comment on attachment 436682 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=436682&action=review > Source/WebCore/page/WindowOrWorkerGlobalScope.idl:71 > + [CallWith=GlobalObject] undefined reportError(any error); Please move this to below crossOriginIsolated; to match it's location in the spec (I try to keep these as close to the spec IDL as I can). > Source/WebCore/workers/WorkerGlobalScope.cpp:551 > +void WorkerGlobalScope::reportError(JSC::JSGlobalObject& globalObject, JSC::JSValue error) Kind of a bummer to have to repeat this.
Created attachment 436768 [details] Patch
Committed r281756 (241098@main): <https://commits.webkit.org/241098@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 436768 [details].
(In reply to Sam Weinig from comment #5) > Comment on attachment 436682 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=436682&action=review > > > Source/WebCore/page/WindowOrWorkerGlobalScope.idl:71 > > + [CallWith=GlobalObject] undefined reportError(any error); > > Please move this to below crossOriginIsolated; to match it's location in the > spec (I try to keep these as close to the spec IDL as I can). > > > Source/WebCore/workers/WorkerGlobalScope.cpp:551 > > +void WorkerGlobalScope::reportError(JSC::JSGlobalObject& globalObject, JSC::JSValue error) > > Kind of a bummer to have to repeat this. Yes, I agree. I'll find a way to share and follow up.