From c649008d0fd5c0f083c8a13e867b5f8042f2ecde Mon Sep 17 00:00:00 2001 From: Chris Dumez Date: Thu, 23 Jun 2022 12:49:25 -0700 Subject: [PATCH] Remove ErrorEventInit's error default https://bugs.webkit.org/show_bug.cgi?id=241259 Reviewed by Darin Adler. Update ErrorEventInit's error default to be undefined instead of null, as per: - https://github.com/whatwg/html/pull/7983 * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html: * Source/WebCore/dom/ErrorEvent.cpp: (WebCore::ErrorEvent::error): * Source/WebCore/dom/ErrorEvent.idl: Canonical link: https://commits.webkit.org/251797@main --- .../error-event-constructor-expected.txt | 2 +- .../constructors/error-event-constructor.html | 2 +- .../document-synthetic-errorevent-expected.txt | 1 + .../document-synthetic-errorevent.html | 14 ++++++++++++++ Source/WebCore/dom/ErrorEvent.h | 2 +- Source/WebCore/dom/ErrorEvent.idl | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/LayoutTests/fast/events/constructors/error-event-constructor-expected.txt b/LayoutTests/fast/events/constructors/error-event-constructor-expected.txt index 1a3394ae0bf54..c22234d207a24 100644 --- a/LayoutTests/fast/events/constructors/error-event-constructor-expected.txt +++ b/LayoutTests/fast/events/constructors/error-event-constructor-expected.txt @@ -64,7 +64,7 @@ PASS new ErrorEvent('eventType', { colno: 0 }).colno is 0 PASS new ErrorEvent('eventType', { colno: 1 }).colno is 1 PASS new ErrorEvent('eventType', { colno: 4294967294 }).colno is 4294967294 PASS new ErrorEvent('eventType', { colno: 4294967295 }).colno is 4294967295 -PASS new ErrorEvent('eventType', { error: undefined }).error is null +PASS new ErrorEvent('eventType', { error: undefined }).error is undefined PASS new ErrorEvent('eventType', { error: null }).error is null PASS new ErrorEvent('eventType', { error: '' }).error is '' PASS new ErrorEvent('eventType', { error: '12345' }).error is '12345' diff --git a/LayoutTests/fast/events/constructors/error-event-constructor.html b/LayoutTests/fast/events/constructors/error-event-constructor.html index af36de07f7bd2..3a0757f00847a 100644 --- a/LayoutTests/fast/events/constructors/error-event-constructor.html +++ b/LayoutTests/fast/events/constructors/error-event-constructor.html @@ -82,7 +82,7 @@ shouldBe("new ErrorEvent('eventType', { colno: 4294967295 }).colno", "4294967295"); // error is passed. -shouldBe("new ErrorEvent('eventType', { error: undefined }).error", "null"); +shouldBe("new ErrorEvent('eventType', { error: undefined }).error", "undefined"); shouldBe("new ErrorEvent('eventType', { error: null }).error", "null"); shouldBe("new ErrorEvent('eventType', { error: '' }).error", "''"); shouldBe("new ErrorEvent('eventType', { error: '12345' }).error", "'12345'"); diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent-expected.txt index 7a15944694908..5cfa324020d11 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent-expected.txt @@ -1,3 +1,4 @@ PASS error event is normal (return true does not cancel; one arg) on Document, with a synthetic ErrorEvent +PASS Initial values of ErrorEvent members diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html b/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html index 8b1b3cfb5b2c3..a541611909767 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html +++ b/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html @@ -21,10 +21,24 @@ const eventWatcher = new EventWatcher(t, document, "error"); const promise = eventWatcher.wait_for("error").then(e => { assert_equals(e.defaultPrevented, false); + assert_equals(e.message, ""); + assert_equals(e.filename, ""); + assert_equals(e.lineno, 0); + assert_equals(e.colno, 0); + assert_equals(e.error, undefined); }); document.dispatchEvent(new ErrorEvent("error", { cancelable: true })); return promise; }, "error event is normal (return true does not cancel; one arg) on Document, with a synthetic ErrorEvent"); + +test(() => { + const e = new ErrorEvent("error"); + assert_equals(e.message, ""); + assert_equals(e.filename, ""); + assert_equals(e.lineno, 0); + assert_equals(e.colno, 0); + assert_equals(e.error, undefined); +}, "Initial values of ErrorEvent members") diff --git a/Source/WebCore/dom/ErrorEvent.h b/Source/WebCore/dom/ErrorEvent.h index c6c2c448b8633..fe39e44e04511 100644 --- a/Source/WebCore/dom/ErrorEvent.h +++ b/Source/WebCore/dom/ErrorEvent.h @@ -57,7 +57,7 @@ class ErrorEvent final : public Event { String filename; unsigned lineno { 0 }; unsigned colno { 0 }; - JSC::JSValue error; + JSC::JSValue error { JSC::jsUndefined() }; }; static Ref create(const AtomString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No) diff --git a/Source/WebCore/dom/ErrorEvent.idl b/Source/WebCore/dom/ErrorEvent.idl index 7983f292fbb88..b6354d7584f5a 100644 --- a/Source/WebCore/dom/ErrorEvent.idl +++ b/Source/WebCore/dom/ErrorEvent.idl @@ -47,5 +47,5 @@ dictionary ErrorEventInit : EventInit { USVString filename = ""; unsigned long lineno = 0; unsigned long colno = 0; - any error = null; + any error; };