-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle null and undefined thrown as exceptions
Closes #3183.
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...pstream/html/webappapis/scripting/processing-model-2/window-onerror-event-throw-null.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<meta charset="UTF-8"> | ||
<title>window.onerror: throwing null in event listeners</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
"use strict"; | ||
|
||
setup({ allow_uncaught_exception: true }); | ||
|
||
test(() => { | ||
let errorEvents = 0; | ||
let errorEvent; | ||
window.addEventListener("error", event => { | ||
errorEvent = event; | ||
++errorEvents; | ||
}); | ||
|
||
const element = document.createElement("div"); | ||
|
||
element.addEventListener("click", () => { | ||
throw null; // eslint-disable-line no-throw-literal | ||
}); | ||
|
||
element.dispatchEvent(new Event("click")); | ||
|
||
assert_equals(errorEvents, 1); | ||
assert_equals(errorEvent.message, "uncaught exception: null"); | ||
assert_equals(errorEvent.error, null); | ||
}, "Throwing null in event listener"); | ||
</script> |