Skip to content

Commit

Permalink
Bug 1636288 [wpt PR 23467] - Test the sourceText of event handlers, a…
Browse files Browse the repository at this point in the history
…=testonly

Automatic update from web-platform-tests
Test the sourceText of event handlers

Follows whatwg/html#5514.

--

wpt-commits: af188628fbb56cbce2ba5c9ca418b5f465a64063
wpt-pr: 23467
  • Loading branch information
domenic authored and moz-wptsync-bot committed May 14, 2020
1 parent 5b8a195 commit a29ec1f
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test the sourceText of event handlers</title>
<link rel="help" href="https://github.com/whatwg/html/issues/5500">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
"use strict";

test(() => {
const el = document.createElement("div");
el.setAttribute("onclick", "foo");
assert_equals(el.onclick.toString(), "function onclick(event) {\nfoo\n}");
}, "non-error event handler");

test(() => {
const el = document.createElement("div");
el.setAttribute("onerror", "foo");
assert_equals(el.onerror.toString(), "function onerror(event) {\nfoo\n}");
}, "error event handler not on body");

test(() => {
const el = document.createElement("body");
el.setAttribute("onerror", "foo");
assert_equals(el.onerror.toString(), "function onerror(event, source, lineno, colno, error) {\nfoo\n}");
}, "error event handler on disconnected body");

test(() => {
const el = document.createElement("frameset");
el.setAttribute("onerror", "foo");
assert_equals(el.onerror.toString(), "function onerror(event, source, lineno, colno, error) {\nfoo\n}");
}, "error event handler on disconnected frameset");

test(() => {
document.body.setAttribute("onerror", "foo");
assert_equals(window.onerror.toString(), "function onerror(event, source, lineno, colno, error) {\nfoo\n}");
}, "error event handler on connected body, reflected to Window");
</script>

0 comments on commit a29ec1f

Please sign in to comment.