Skip to content

Commit

Permalink
Remove ErrorEventInit's error default
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=241259
<rdar://94793559>

Reviewed by Darin Adler.

Update ErrorEventInit's error default to be undefined instead of null, as per:
- whatwg/html#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
  • Loading branch information
cdumez authored and EWS Buildbot Worker committed Jun 23, 2022
1 parent 2baeebb commit c649008
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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")
</script>
2 changes: 1 addition & 1 deletion Source/WebCore/dom/ErrorEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ErrorEvent> create(const AtomString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/ErrorEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ dictionary ErrorEventInit : EventInit {
USVString filename = "";
unsigned long lineno = 0;
unsigned long colno = 0;
any error = null;
any error;
};

0 comments on commit c649008

Please sign in to comment.