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

@ -5,12 +5,14 @@
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
let option = {timeout: 50};
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
var counter = 0;
function f(c) {
assert_equals(counter, c);
if (counter === 99) {
if (counter === 49) {
t.done();
}
@ -18,7 +20,7 @@
}
for (var i = 0; i < 100; ++i) {
let j = i;
window.requestIdleCallback(t.step_func(function () { f(j) }));
window.requestIdleCallback(t.step_func(function () { f(j) }), option);
}
}, "requestIdleCallback callbacks should be invoked in order (called iteratively)");
@ -28,14 +30,17 @@
function f(c) {
assert_equals(counter, c);
if (counter === 99) {
if (counter === 49) {
t.done();
}
++counter;
window.requestIdleCallback(t.step_func(function () { f(c + 1) }));
window.requestIdleCallback(t.step_func(function () { f(c + 1) }), option);
}
window.requestIdleCallback(t.step_func(function () { f(0) }));
window.requestIdleCallback(t.step_func(function () { f(0) }), option);
}, "requestIdleCallback callbacks should be invoked in order (called recursively)");
let generateIdlePeriods = _ => requestAnimationFrame(generateIdlePeriods);
generateIdlePeriods();
</script>

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");

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a dedicated worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dedicated-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
fetch_tests_from_worker(new Worker("worker-that-requires-success.js"));
</script>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a service worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#service-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
<script>
"use strict";
service_worker_test("worker-that-requires-failure.js", "Service worker test setup");
</script>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a shared worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#shared-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
fetch_tests_from_worker(new SharedWorker("worker-that-requires-success.js"));
</script>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a similar-origin window agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#similar-origin-window-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);
assert_throws(new TypeError(), () => {
Atomics.wait(ta, 0, 0, 10);
}, "Atomics.wait must throw in a window context");
done();
</script>

View file

@ -0,0 +1,13 @@
"use strict";
importScripts("/resources/testharness.js");
test(() => {
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);
assert_throws(new TypeError(), () => {
Atomics.wait(ta, 0, 0, 10);
});
}, `[[CanBlock]] in a ${self.constructor.name}`);
done();

View file

@ -0,0 +1,11 @@
"use strict";
importScripts("/resources/testharness.js");
test(() => {
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);
assert_equals(Atomics.wait(ta, 0, 0, 10), "timed-out");
}, `[[CanBlock]] in a ${self.constructor.name}`);
done();

View file

@ -1,10 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>NavigatorID</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=NavigatorID.js></script>
<div id="log"></div>
<script>
run_test();
</script>

View file

@ -1,4 +0,0 @@
importScripts("/resources/testharness.js")
importScripts("NavigatorID.js")
run_test();
done();

View file

@ -0,0 +1,55 @@
<!doctype html>
<html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
test(function () {
for (var i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
var name = plugin.name;
assert_equals(plugin, navigator.plugins[i]);
assert_equals(plugin, navigator.plugins[name]);
}
for (var i = 0; i < navigator.mimeTypes.length; i++) {
var mime_type = navigator.mimeTypes[i];
var type = mime_type.type;
assert_equals(mime_type, navigator.mimeTypes[i]);
assert_equals(mime_type, navigator.mimeTypes[type]);
assert_equals(mime_type.enabledPlugin, navigator.plugins[mime_type.enabledPlugin.name]);
}
}, "Tests that navigator.plugins and navigator.mimeTypes returns the same object when queried multiple times.");
test(function () {
var iframe = document.createElement("iframe");
iframe.src = "about:blank";
document.body.appendChild(iframe);
assert_equals(navigator.plugins.length, iframe.contentWindow.navigator.plugins.length);
assert_equals(navigator.mimeTypes.length, iframe.contentWindow.navigator.mimeTypes.length);
for (var i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
var name = plugin.name;
assert_not_equals(plugin, iframe.contentWindow.navigator.plugins[i]);
assert_not_equals(plugin, iframe.contentWindow.navigator.plugins[name]);
}
for (var i = 0; i < navigator.mimeTypes.length; i++) {
var mime_type = navigator.mimeTypes[i];
var type = mime_type.type;
assert_not_equals(mime_type, iframe.contentWindow.navigator.mimeTypes[i]);
assert_not_equals(mime_type, iframe.contentWindow.navigator.mimeTypes[type]);
assert_not_equals(mime_type.enabledPlugin, iframe.contentWindow.navigator.plugins[mime_type.enabledPlugin.name]);
}
iframe.remove();
}, "Tests that navigator.plugins and navigator.mimeTypes does not return the same object on different frames.");
test(function () {
for (var i = 1; i < navigator.plugins.length; i++) {
assert_less_than_equal(navigator.plugins[i-1].name.localeCompare(navigator.plugins[i].name), 0);
}
for (var i = 1; i < navigator.mimeTypes.length; i++) {
assert_less_than_equal(navigator.mimeTypes[i-1].type.localeCompare(navigator.mimeTypes[i].type), 0);
}
}, "Tests that navigator.plugins and navigator.mimeTypes returns plugins sorted in alphabetical order by plugin name.");
</script>
</body>
</html>

View file

@ -1,4 +1,3 @@
function run_test() {
var compatibilityMode;
if (navigator.userAgent.includes("Chrome")) {
compatibilityMode = "Chrome";
@ -50,7 +49,7 @@ function run_test() {
async_test(function() {
var request = new XMLHttpRequest();
request.onload = this.step_func_done(function() {
assert_equals("user-agent: " + navigator.userAgent + "\n",
assert_equals("User-Agent: " + navigator.userAgent + "\n",
request.response,
"userAgent should return the value sent in the " +
"User-Agent header");
@ -103,4 +102,5 @@ function run_test() {
assert_false("oscpu" in navigator);
}
}, "oscpu");
}
done()