Update web-platform-tests to revision a46616a5b18e83587ddbbed756c7b96cbb4b015d

This commit is contained in:
Josh Matthews 2017-06-19 19:07:14 -04:00 committed by Ms2ger
parent 3f07cfec7c
commit 578498ba24
4001 changed files with 159517 additions and 30260 deletions

View file

@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<title>HTML contextmenu event is a MouseEvent</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>#contextmenutarget { width: 100px; height: 100px; background-color: red; }</style>
</head>
<body>
<div id='contextmenutarget'>Trigger context menu in this box.</div>
<div id="log"></div>
<script type="text/javascript">
var t = async_test('contextmenu event generated from user action is MouseEvent');
document.querySelector("#contextmenutarget").addEventListener('contextmenu', t.step_func(function (e) {
assert_equals(e.constructor, window.MouseEvent);
document.querySelector("#contextmenutarget").style.backgroundColor = "green";
t.done();
}));
</script>
</body>
</html>

View file

@ -0,0 +1,74 @@
<!DOCTYPE html>
<title>GlobalEventHandlers</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#globaleventhandlers">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#event-handler-idl-attributes">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#event-handler-content-attributes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script>
"use strict";
setup({ explicit_done: true });
fetch("/interfaces/html.idl").then(res => res.text()).then(htmlIDL => {
const parsedHTMLIDL = WebIDL2.parse(htmlIDL);
const globalEventHandlers = parsedHTMLIDL.find(idl => idl.name === "GlobalEventHandlers");
// onerror is too special
const names = globalEventHandlers.members.map(member => member.name).filter(name => name !== "onerror");
for (const name of names) {
const withoutOn = name.substring(2);
test(() => {
for (const location of [window, HTMLElement.prototype, SVGElement.prototype, Document.prototype]) {
assert_true(location.hasOwnProperty(name),
`${location.constructor.name} 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("http://www.w3.org/2000/svg", "g");
for (var location of [window, htmlElement, svgElement, document]) {
assert_equals(location[name], null,
`The default value of the property is null for a ${location.constructor.name} 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`);
compiledHandler();
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;`);
el.dispatchEvent(new Event(withoutOn));
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}`);
}
done();
});
</script>

View file

@ -1,58 +0,0 @@
<!DOCTYPE html>
<title>onauxclick</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#handler-onauxclick">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="auxclickme1" onauxclick="window.auxClick1Happened = true;"></div>
<div id="auxclickme2" onauxclick="window.auxClick2Happened = true;"></div>
<script>
"use strict";
window.auxClick1Happened = false;
window.auxClick2Happened = false;
test(() => {
for (var location of [window, HTMLElement.prototype, SVGElement.prototype, Document.prototype]) {
assert_true(location.hasOwnProperty("onauxclick"),
`${location.constructor.name} has an own property named "onauxclick"`);
}
}, "onauxclick is on the appropriate locations for GlobalEventHandlers");
test(() => {
const htmlElement = document.createElement("span");
const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
for (var location of [window, htmlElement, svgElement, document]) {
assert_equals(location.onauxclick, null,
`The default value of the property is null for a ${location.constructor.name} instance`);
}
}, "The default value of onauxclick is always null");
test(() => {
const element = document.querySelector("#auxclickme1");
const compiledHandler = element.onauxclick;
assert_equals(typeof compiledHandler, "function", "The onauxclick property must be a function");
compiledHandler();
assert_true(window.auxClick1Happened, "Calling the handler must run the code");
}, "The onauxclick content attribute must be compiled into the onauxclick property");
test(() => {
const element = document.querySelector("#auxclickme2");
element.dispatchEvent(new Event("auxclick"));
assert_true(window.auxClick2Happened, "Dispatching the event must run the code");
}, "The onauxclick content attribute must execute when an event is dispatched");
test(() => {
const element = document.createElement("meta");
element.onauxclick = e => {
assert_equals(e.currentTarget, element, "The event must be fired at the <meta> element");
};
element.dispatchEvent(new Event("auxclick"));
}, "dispatching an auxclick event must trigger element.onauxclick");
</script>

View file

@ -5,6 +5,7 @@
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
setup({ allow_uncaught_exception: true });
var events = [];
test(function() {

View file

@ -10,7 +10,7 @@ setup({ allow_uncaught_exception: true });
test(function() {
var events = [];
window.onerror = function() {
events.push("Error");
events.push("error");
};
var div = document.createElement("div");