Update web-platform-tests to revision e710d1d6bbe007a6a9344f79e17b445cf97cc623

This commit is contained in:
WPT Sync Bot 2019-10-09 10:23:00 +00:00
parent ec408e9a57
commit 5a5336aaf0
1981 changed files with 64719 additions and 2377 deletions

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<script>
'use strict';
promise_test(async () => {
let doc = document.cloneNode(false);
doc.appendChild(doc.createElement('html'))
doc.firstChild.innerHTML = '<body><input autofocus/></body>';
await waitUntilStableAutofocusState();
assert_equals(doc.activeElement, doc.body);
}, 'Autofocus element in not-fully-active document should not be queued.');
</script>

View file

@ -1,21 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<body>
<script>
'use strict';
promise_test(async t => {
await waitForLoad(window);
await timeOut(t, 1000);
let element = document.createElement('input');
element.autofocus = true;
document.body.appendChild(element);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, element);
}, 'Autofocus should work if an element with autofocus is inserted into a ' +
'document which was loaded some time ago.');
</script>
</body>

View file

@ -1,22 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<input autofocus id="i1">
<input autofocus id="i2">
<script>
"use strict";
promise_test(async () => {
const input1 = document.querySelector("#i1");
const input2 = document.querySelector("#i2");
input1.remove();
input2.parentNode.insertBefore(input1, input2);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input2);
}, 'The second autofocus element wins if the first autofocus element was ' +
'disconnected and reconnected before flushing the autofocus candidates.');
</script>

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The temporally first autofocus in the document wins, even if an element is inserted later that is previous in the document tree</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
<link rel="author" title="Domenic Denicola" href="d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<input autofocus>
<script>
"use strict";
promise_test(async () => {
const input1 = document.querySelector("input");
const input2 = document.createElement("input");
input2.autofocus = true;
document.body.prepend(input2);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input1);
assert_not_equals(document.activeElement, input2);
}, 'The temporally first autofocus in the document wins, even if an element is inserted later that is previous in the document tree.');
</script>

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The first autofocus in the document wins, even if elements are inserted later</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
<link rel="author" title="Domenic Denicola" href="d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<input autofocus>
<script>
"use strict";
promise_test(async () => {
const input1 = document.querySelector("input");
const input2 = document.createElement("input");
input2.autofocus = true;
document.body.appendChild(input2);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input1);
assert_not_equals(document.activeElement, input2);
}, 'The first autofocus in the document wins, even if elements are inserted later.');
</script>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The first autofocus in the document wins</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
<link rel="author" title="Domenic Denicola" href="d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<input autofocus>
<input autofocus>
<script>
"use strict";
promise_test(async () => {
const [input1, input2] = document.querySelectorAll("input");
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input1);
assert_not_equals(document.activeElement, input2);
}, 'The first autofocus element in the document should win.');
</script>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<iframe srcdoc="<input><script>document.querySelector('input').focus();</script>"></iframe>
<script>
'use strict';
promise_test(async () => {
await waitForLoad(window);
let iframe = document.querySelector('iframe');
assert_equals(document.activeElement, iframe, 'Prereq: IFRAME should be focused');
let input = document.createElement('input');
input.autofocus = true;
document.body.appendChild(input);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, iframe, 'activeElement should not be changed');
assert_not_equals(document.activeElement, input);
}, 'If topDocument\'s focused area is not topDocument, autofocus is not processed.');
</script>

View file

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<h1>Autofocus shouldn't work in cross-origin iframe.</h1>
<iframe id="child" width="200" height="100"></iframe>
<script>
let parent_loaded = false;
let child_loaded = false;
async_test(function(t) {
function pingChildIfBothFramesLoaded() {
if (parent_loaded && child_loaded)
frames[0].postMessage("report_focus_state", "*");
}
window.addEventListener("load", t.step_func(event => {
parent_loaded = true;
pingChildIfBothFramesLoaded();
}));
window.addEventListener("message", t.step_func(event => {
if (event.data == "child_loaded") {
child_loaded = true;
pingChildIfBothFramesLoaded();
} else if (event.data == "child_is_focused") {
assert_unreached("The iframe shouldn't get focus");
} else if (event.data == "child_is_not_focused") {
t.done();
}
}));
document.getElementById("child").src =
get_host_info().HTTP_REMOTE_ORIGIN + "/html/semantics/forms/autofocus/resources/child-autofocus.html";
}, "Autofocus shouldn't work in cross-origin iframe");
</script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<iframe sandbox srcdoc="<input autofocus>"></iframe>
<script>
'use strict';
promise_test(async () => {
await waitForLoad(window);
await waitUntilStableAutofocusState();
assert_not_equals(document.activeElement, document.querySelector('iframe'));
}, 'If the sandboxed automatic features browsing context flag is set, ' +
'autofocus in the browsing context should not be handled.');
</script>

View file

@ -1,22 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The element is not focused during the initial parsing task</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
<link rel="author" title="Domenic Denicola" href="d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<input autofocus>
<input autofocus>
<script>
"use strict";
const input = document.querySelector("input");
assert_equals(document.activeElement, document.body);
assert_not_equals(document.activeElement, input);
done();
</script>

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<textarea autofocus disabled></textarea>
<select autofocus></select>
<script>
'use strict';
promise_test(async () => {
const [textarea, select] = document.querySelectorAll('[autofocus]');
textarea.disabled = false;
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, textarea);
assert_not_equals(document.activeElement, select);
}, 'If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused.');
</script>

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<input id="target" value="This should be unfocused!" autofocus></input>
<script>
let got_focus = false;
document.getElementById("target").addEventListener("focus", () => {
got_focus = true;
});
window.addEventListener("load", () => {
parent.postMessage("child_loaded", "*");
});
window.addEventListener("message", event => {
if (event.data == "report_focus_state") {
let msg = got_focus ? "child_is_focused" : "child_is_not_focused";
parent.postMessage(msg, "*");
}
});
</script>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<script src="/common/get-host-info.sub.js"></script>
<iframe id="iframe" width="200" height="100"></iframe>
<script>
iframe.src =
get_host_info().ORIGIN + "/html/semantics/forms/autofocus/resources/grand-child-autofocus.html";
window.addEventListener("message", event => {
if (event.data == "grand_child_loaded") {
parent.postMessage("ready", "*");
} else if (event.data == "report_focus_state") {
frames[0].postMessage("report_focus_state", "*");
} else if (event.data == "grand_child_is_focused" ||
event.data == "grand_child_is_not_focused") {
parent.postMessage(event.data, "*");
}
});
</script>

View file

@ -1,5 +0,0 @@
<!DOCTYPE html>
<body>
<div id="anchor1"></div>
<input autofocus>
</body>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<input id="target" value="This should be focused!" autofocus></input>
<script>
let got_focus = false;
target.addEventListener("focus", () => got_focus = true);
window.addEventListener("load", () => {
parent.postMessage("grand_child_loaded", "*");
});
window.addEventListener("message", event => {
if (event.data == "report_focus_state") {
let msg = got_focus ? "grand_child_is_focused" : "grand_child_is_not_focused";
parent.postMessage(msg, "*");
}
});
</script>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<body>
<script>
const input = document.createElement('input');
input.autofocus = true;
document.body.appendChild(input);
input.autofocus = false;
window.opener.document.body.appendChild(input);
</script>
</body>

View file

@ -1,42 +0,0 @@
'use strict';
function waitForEvent(target, type, options) {
return new Promise((resolve, reject) => {
target.addEventListener(type, resolve, options);
});
}
function waitForAnimationFrame(w) {
let targetWindow = w || window;
return new Promise((resolve, reject) => {
targetWindow.requestAnimationFrame(resolve);
});
}
function waitForEvent(target, type, options) {
return new Promise((resolve, reject) => {
target.addEventListener(type, resolve, options);
});
}
function waitForLoad(target) {
return waitForEvent(target, 'load');
}
function timeOut(test, ms) {
return new Promise((resolve, reject) => {
test.step_timeout(resolve, ms);
});
}
// If an element with autofocus is connected to a document and this function
// is called, the autofocus result is deterministic after returning from the
// function.
// Exception: If the document has script-blocking style sheets, this function
// doesn't work well.
async function waitUntilStableAutofocusState(w) {
let targetWindow = w || window;
// Awaiting two animation frames is an easy way to determine autofocus state.
await waitForAnimationFrame(targetWindow);
await waitForAnimationFrame(targetWindow);
}

View file

@ -1,46 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta name="assert" content="`autofocus` should work in the same origin iframe even if there is a cross-origin iframe between the parent and the same origin iframe">
<title>autofocus in the same origin grand child iframe</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<h1>Autofocus should work in the same origin grand child iframe.</h1>
<iframe id="child" width="200" height="100"></iframe>
<script>
let parent_loaded = false;
let grand_child_loaded = false;
async_test(function(t) {
function pingChildIfBothFramesLoaded() {
if (parent_loaded && grand_child_loaded)
frames[0].postMessage("report_focus_state", "*");
}
window.addEventListener("load", t.step_func(event => {
parent_loaded = true;
pingChildIfBothFramesLoaded();
}));
window.addEventListener("message", t.step_func(event => {
if (event.data == "ready") {
grand_child_loaded = true;
pingChildIfBothFramesLoaded();
} else if (event.data == "grand_child_is_focused") {
t.done();
} else if (event.data == "grand_child_is_not_focused") {
assert_unreached("The iframe shouldn't get focus");
}
}));
document.getElementById("child").src =
get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/semantics/forms/autofocus/resources/child-iframe.html";
}, "Autofocus should work in the same origin grand child iframe");
</script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<script>
'use strict';
promise_test(async () => {
let w = window.open('resources/moving-autofocus-to-parent.html');
await waitForLoad(w);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement, w.document.body);
assert_equals(document.activeElement, document.body);
w.close();
}, 'Autofocus elements queued in another top-level browsing context\'s ' +
'documents should be skipped.');
</script>

View file

@ -1,32 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<iframe src="resources/frame-with-autofocus-element.html#anchor1"></iframe>
<iframe src="resources/frame-with-autofocus-element.html#non-existent-anchor"></iframe>
<script>
'use strict';
promise_test(async () => {
await waitForLoad(window);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, document.body,
'Autofocus elements in iframes should not be focused.');
let input = document.createElement('input');
input.autofocus = true;
document.body.appendChild(input);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input);
}, 'Autofocus elements in iframed documents with URL fragments should be skipped.');
promise_test(async () => {
let w = window.open('resources/frame-with-autofocus-element.html#xpointer(//body)');
await waitForLoad(w);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement, w.document.body);
w.close();
}, 'Autofocus elements in top-level browsing context\'s documents with URI fragments should be skipped.');
</script>

View file

@ -1,19 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<textarea autofocus disabled></textarea>
<select autofocus></select>
<script>
'use strict';
promise_test(async () => {
const [textarea, select] = document.querySelectorAll('[autofocus]');
await waitUntilStableAutofocusState();
assert_not_equals(document.activeElement, textarea);
assert_equals(document.activeElement, select);
}, 'Non-focusable autofocus element is skipped.');
</script>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<iframe srcdoc="<input autofocus><script>window.frameElement.remove();</script>"></iframe>
<script>
'use strict';
promise_test(async () => {
let iframe = document.querySelector('iframe');
let iframeDocument = iframe.contentDocument;
await waitForLoad(window);
assert_not_equals(document.activeElement, iframe);
assert_equals(iframeDocument.activeElement, iframeDocument.body);
}, 'Autofocus element in not-fully-active document should be skipped while flusing.');
</script>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<link rel="stylesheet" href="resources/erase-first.css?pipe=trickle(d1)">
<input id="first" autofocus>
<input id="second" autofocus>
<script>
'use strict';
promise_test(async () => {
await waitForEvent(document.body, 'focus', {capture:true});
assert_equals(document.activeElement.id, 'second');
}, 'Script-blocking style sheet should pause flushing autofocus candidates.');
</script>

View file

@ -1,37 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<script>
"use strict";
promise_test(async t => {
let w = window.open('/common/blank.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
w.document.body.innerHTML = '<div contenteditable=true autofocus></div>';
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement.tagName, 'DIV');
}, 'Contenteditable element should support autofocus');
promise_test(async t => {
let w = window.open('/common/blank.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
w.document.body.innerHTML = '<span tabindex=0 autofocus></span>';
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement.tagName, 'SPAN');
}, 'Element with tabindex should support autofocus');
promise_test(async t => {
let w = window.open('/common/blank.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
let element = w.document.createElementNS('uri1', 'prefix:local');
element.setAttribute('autofocus', '');
w.document.body.appendChild(element);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement.tagName, 'BODY');
}, 'Non-HTMLElement should not support autofocus');
</script>

View file

@ -1,41 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/C/#update-the-rendering">
<body>
<script>
'use strict';
async_test(t => {
t.events = [];
let iframe = document.createElement('iframe');
iframe.addEventListener('load', t.step_func(() => {
let w = iframe.contentWindow;
w.requestAnimationFrame(t.step_func(() => {
t.events.push('animationFrame');
w.requestAnimationFrame(t.step_func(() => {
t.events.push('animationFrame-should-not-be-recorded');
}));
}));
let element = w.document.createElement('input');
element.autofocus = true;
element.addEventListener('focus', t.step_func(() => {
t.events.push('autofocus');
iframe.style.width = '71px';
}));
w.addEventListener('resize', t.step_func_done(() => {
t.events.push('resize');
assert_array_equals(t.events, ['animationFrame', 'autofocus', 'resize']);
}));
w.document.body.appendChild(element);
}));
document.body.appendChild(iframe);
}, '"Flush autofocus candidates" should be happen after the first animation ' +
'frame callbacks, and before a resize event in the next iteration of ' +
'window event loop.');
</script>
</body>