Skip to content

Commit

Permalink
Remove ErrorEventInit's error's null default value
Browse files Browse the repository at this point in the history
Per the spec change [1], this removes ErrorEventInit's default value
of null, which makes the error attribute have no null default.

This change has already shipped on WebKit and Gecko, and the change
makes Chromium match the spec and other implementations. This is tested
by this WPT:

wpt/html/webappapis/scripting/events/event-handler-processing-algorithm-error/document-synthetic-errorevent.html

[1] whatwg/html#7983

Fixed: 1332448
Change-Id: Ia64a62e8c5739ab278016a94b0c3b0419d6a68f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3749784
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021841}
  • Loading branch information
mfreed7 authored and Chromium LUCI CQ committed Jul 7, 2022
1 parent f980ab8 commit 6f838d8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 3 additions & 4 deletions third_party/blink/renderer/core/events/error_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ ErrorEvent::ErrorEvent(ScriptState* script_state,
location_ = std::make_unique<SourceLocation>(initializer->filename(),
String(), initializer->lineno(),
initializer->colno(), nullptr);
// TODO(crbug.com/1070964): Remove this existence check. There is a bug that
// the current code generator does not initialize a ScriptValue with the
// v8::Null value despite that the dictionary member has the default value of
// IDL null. |hasError| guard is necessary here.
if (initializer->hasError()) {
v8::Local<v8::Value> error = initializer->error().V8Value();
// TODO(crbug.com/1070871): Remove the following IsNullOrUndefined() check.
Expand All @@ -79,6 +75,9 @@ ErrorEvent::ErrorEvent(ScriptState* script_state,
if (!error->IsNullOrUndefined()) {
error_.Set(script_state->GetIsolate(), error);
}
} else {
error_.Set(script_state->GetIsolate(),
v8::Undefined(script_state->GetIsolate()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dictionary ErrorEventInit : EventInit {
DOMString filename = "";
unsigned long lineno = 0;
unsigned long colno = 0;
any error = null;
any error;
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,20 @@
assert_equals(e.colno, 0);
assert_equals(e.error, undefined);
}, "Initial values of ErrorEvent members")

test(() => {
const e = new ErrorEvent("error", {error : null});
assert_equals(e.error, null);
}, "error member can be set to null")

test(() => {
const e = new ErrorEvent("error", {error : undefined});
assert_equals(e.error, undefined);
}, "error member can be set to undefined")

test(() => {
const e = new ErrorEvent("error", {error : "foo"});
assert_equals(e.error, "foo");
}, "error member can be set to arbitrary")

</script>

This file was deleted.

0 comments on commit 6f838d8

Please sign in to comment.