Bug 1636288 [wpt PR 23467] - Test the sourceText of event handlers, a=testonly
authorDomenic Denicola <d@domenic.me>
Wed, 13 May 2020 09:48:00 +0000
changeset 531153 ae48b7d4543c9eec53af8fc3cb444f08296bddd7
parent 531152 da766ca50e082a89387305f78f68203fc36496ee
child 531154 716ce44ad8a081d407caa06714a4b3fc263c0750
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1636288, 23467
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1636288 [wpt PR 23467] - Test the sourceText of event handlers, a=testonly Automatic update from web-platform-tests Test the sourceText of event handlers Follows https://github.com/whatwg/html/pull/5514. -- wpt-commits: af188628fbb56cbce2ba5c9ca418b5f465a64063 wpt-pr: 23467
testing/web-platform/tests/html/webappapis/scripting/events/event-handler-sourcetext.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-sourcetext.html
@@ -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>