Skip to content

Commit

Permalink
events: check signal before listener
Browse files Browse the repository at this point in the history
In WPT Events, TypeError is expected if both listener and
signal are null. But checking listener doesn't throw TypeError.
So check signal before listener because checking signal throws
TypeError if signal is null.

PR-URL: #46054
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
  • Loading branch information
deokjinkim authored Jan 4, 2023
1 parent 57048ac commit 5d4cb84
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ class EventTarget {
weak,
} = validateEventListenerOptions(options);

validateAbortSignal(signal, 'options.signal');

if (!validateEventListener(listener)) {
// The DOM silently allows passing undefined as a second argument
// No error code for this since it is a Warning
Expand All @@ -575,8 +577,6 @@ class EventTarget {
}
type = String(type);

validateAbortSignal(signal, 'options.signal');

if (signal) {
if (signal.aborted) {
return;
Expand Down
7 changes: 0 additions & 7 deletions test/wpt/status/dom/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
]
}
},
"AddEventListenerOptions-signal.any.js": {
"fail": {
"expected": [
"Passing null as the signal should throw (listener is also null)"
]
}
},
"Event-constructors.any.js": {
"fail": {
"expected": [
Expand Down

0 comments on commit 5d4cb84

Please sign in to comment.