RESOLVED FIXED Bug 228316
Implement self.reportError()
https://bugs.webkit.org/show_bug.cgi?id=228316
Summary Implement self.reportError()
Anne van Kesteren
Reported 2021-07-26 23:10:56 PDT
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.
Attachments
Patch (11.60 KB, patch)
2021-08-27 15:28 PDT, Chris Dumez
no flags
Patch (11.51 KB, patch)
2021-08-30 07:26 PDT, Chris Dumez
no flags
Radar WebKit Bug Importer
Comment 1 2021-08-02 23:11:17 PDT
Chris Dumez
Comment 2 2021-08-27 15:28:57 PDT
Chris Dumez
Comment 3 2021-08-27 15:33:56 PDT
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).
Sam Weinig
Comment 4 2021-08-28 11:10:02 PDT
(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
Sam Weinig
Comment 5 2021-08-28 11:15:09 PDT
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.
Chris Dumez
Comment 6 2021-08-30 07:26:46 PDT
EWS
Comment 7 2021-08-30 07:59:48 PDT
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].
Chris Dumez
Comment 8 2021-08-30 12:28:26 PDT
(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.
Note You need to log in before you can comment on or make changes to this bug.