Source code

Revision control

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<link rel="author" title="Domenic Denicola" href="">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
"use strict";
// The prefixed animation events are special; their event types are
// camel-case.
const prefixedAnimationAttributeToEventType = new Map([
["webkitanimationend", "webkitAnimationEnd"],
["webkitanimationiteration", "webkitAnimationIteration"],
["webkitanimationstart", "webkitAnimationStart"],
["webkittransitionend", "webkitTransitionEnd"],
setup({ explicit_done: true });
fetch("/interfaces/html.idl").then(res => res.text()).then(htmlIDL => {
const parsedHTMLIDL = WebIDL2.parse(htmlIDL);
const globalEventHandlers = parsedHTMLIDL.find(idl => === "GlobalEventHandlers");
// onerror is too special
const names = => => name !== "onerror");
for (const name of names) {
const withoutOn = name.substring(2);
test(() => {
for (const location of [window, HTMLElement.prototype, SVGElement.prototype, Document.prototype]) {
`${} has an own property named "${name}"`);
assert_false(name in Element.prototype, `Element.prototype must not contain a "${name}" property`);
}, `${name}: must be on the appropriate locations for GlobalEventHandlers`);
test(() => {
const htmlElement = document.createElement("span");
const svgElement = document.createElementNS("", "g");
for (var location of [window, htmlElement, svgElement, document]) {
assert_equals(location[name], null,
`The default value of the property is null for a ${} instance`);
}, `${name}: the default value must be null`);
test(() => {
const el = document.createElement("div");
el.setAttribute(name, `window.${name}Happened = true;`);
const compiledHandler = el[name];
assert_equals(typeof compiledHandler, "function", `The ${name} property must be a function`);
assert_true(window[name + "Happened"], "Calling the handler must run the code");
}, `${name}: the content attribute must be compiled into a function as the corresponding property`);
test(() => {
const el = document.createElement("div");
el.setAttribute(name, `window.${name}Happened2 = true;`);
let eventType = withoutOn;
if (prefixedAnimationAttributeToEventType.has(eventType)) {
eventType = prefixedAnimationAttributeToEventType.get(eventType);
el.dispatchEvent(new Event(eventType));
assert_true(window[name + "Happened2"], "Dispatching an event must run the code");
}, `${name}: the content attribute must execute when an event is dispatched`);
test(() => {
const element = document.createElement("meta");
element[name] = e => {
assert_equals(e.currentTarget, element, "The event must be fired at the <meta> element");
element.dispatchEvent(new Event(withoutOn));
}, `${name}: dispatching an Event at a <meta> element must trigger element.${name}`);