Update web-platform-tests to revision 9a5d71b326166e12784bdd9d161772e20f87c1fd

This commit is contained in:
WPT Sync Bot 2018-09-07 21:37:42 -04:00
parent f7630dad87
commit 4ae3d09ff3
86 changed files with 2739 additions and 640 deletions

View file

@ -1,16 +0,0 @@
async_test(t => {
const input = document.body.appendChild(document.createElement("input"));
let happened = false;
input.onfocus = t.step_func(e => {
happened = true;
assert_equals(e.type, "focus");
assert_true(e.composed);
});
input.focus();
input.onblur = t.step_func_done(e => {
assert_true(happened);
assert_equals(e.type, "blur");
assert_true(e.composed);
});
input.blur();
}, "Focus events are composed");

View file

@ -1,34 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - document-level APIs</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document-level-focus-apis">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<input id="test">
<script>
test(function () {
assert_equals(document.activeElement, document.body, "The active element should be the body element.");
}, "The body element must be the active element if no element is focused");
test(function () {
document.getElementById("test").focus();
assert_equals(document.activeElement, document.getElementById("test"), "The active element should be the input element.");
}, "The element must be the active element if it is focused");
function frame_load () {
test(function () {
document.getElementById("fr").contentDocument.getElementById("ipt").focus();
assert_equals(document.activeElement, document.getElementById("fr"), "The active element should be the iframe element.");
}, "When a child browsing context is focused, its browsing context container is also focused");
}
test(function () {
var doc = document.implementation.createHTMLDocument("test");
assert_false(doc.hasFocus(), "The hasFocus() method should return false.");
}, "The hasFocus() method must return false if the Document has no browsing context");
</script>
<iframe id="fr" src="test.html" onload="frame_load()"></iframe>

View file

@ -1,5 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - document-level APIs</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<input id="ipt">

View file

@ -1,44 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - key events</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#focus">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check if the key events received by document are targeted at the element when it is focused">
<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>
<div id="log"></div>
<input id="test">
<script>
var t1 = async_test("The keydown event must be targeted at the input element"),
t2 = async_test("The keypress event must be targeted at the input element"),
t3 = async_test("The keyup event must be targeted at the input element"),
testEle;
setup(function () {
testEle = document.getElementById("test");
testEle.focus();
}, {timeout: 10000});
document.onkeydown = t1.step_func_done(function(evt){
assert_equals(evt.target, testEle, "The keydown events must be targeted at the input element.");
});
document.onkeypress = t2.step_func_done(function(evt){
assert_equals(evt.target, testEle, "The keypress events must be targeted at the input element.");
});
document.onkeyup = t3.step_func_done(function(evt){
assert_equals(evt.target, testEle, "The keyup events must be targeted at the input element.");
});
var input_element = document.getElementById("test");
t1.step(function() {
test_driver.send_keys(input_element, "a");
});
</script>

View file

@ -1,37 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - key events</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#focus">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check if the key events received by document are targeted at the element when no element is focused">
<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>
<div id="log"></div>
<script>
var t1 = async_test("The keydown event must be targeted at the body element"),
t2 = async_test("The keypress event must be targeted at the body element"),
t3 = async_test("The keyup event must be targeted at the body element");
setup({timeout: 10000});
document.onkeydown = t1.step_func_done(function(evt){
assert_equals(evt.target, document.body, "The keydown events must be targeted at the document's body.");
});
document.onkeypress = t2.step_func_done(function(evt){
assert_equals(evt.target, document.body, "The keypress events must be targeted at the document's body.");
});
document.onkeyup = t3.step_func_done(function(evt){
assert_equals(evt.target, document.body, "The keyup events must be targeted at the document's body.");
});
t1.step(function() {
test_driver.send_keys(document.body, "a");
});
</script>

View file

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Focus events fire at correct targets in correct order in simple case</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/#focus-update-steps">
<link rel="help" href="https://html.spec.whatwg.org/#focus-chain">
<meta name="flags" content="dom">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<input type="text" id="a">
<script>
// Record all the focus event targets in an array.
// Modulo special cases in the "focus update steps" algorithm,
// this should be the same as the new focus chain, except in reverse order.
var newFocusChainReversedNotQuite = [];
var pushTarget = function (e) {
newFocusChainReversedNotQuite.push(e.target);
};
// Window is the root node for event dispatch per https://html.spec.whatwg.org/multipage/webappapis.html#events-and-the-window-object
window.addEventListener('focus', pushTarget, true);// Use event capturing since focus event doesn't bubble
var input = document.getElementById('a');
input.focus();
window.removeEventListener('focus', pushTarget, true);
test(function() {
assert_array_equals(newFocusChainReversedNotQuite, [input], "Exactly 1 focus event should fire and its target should be the input");
}, "Focus events fire at correct targets in correct order in simple case");
</script>
</body>
</html>

View file

@ -1,32 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Focus management</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#focus-management">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<input type=text id=i1>
<input type=text id=i2>
<script>
var i1 = document.getElementById('i1'),
i2 = document.getElementById('i2'),
t1 = async_test("focusing on a focusable element fires a focus event at the element"),
t2 = async_test("focusing on a focusable element fires a blur event at the previous focussed element");
i2.onfocus = t1.step_func_done(function(e){
assert_true(e.isTrusted, "focus event is trusted");
assert_false(e.bubbles, "focus event doesn't bubble");
assert_false(e.cancelable, "focus event is not cancelable");
assert_equals(document.activeElement, i2);
});
i1.onblur = t2.step_func_done(function(e){
assert_true(e.isTrusted, "blur event is trusted");
assert_false(e.bubbles, "blur event doesn't bubble");
assert_false(e.cancelable, "blur event is not cancelable");
});
i1.focus();
i2.focus();
</script>

View file

@ -1,109 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Focus fixup rule one (no &lt;dialog>s involved)</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule-one">
<link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#attr-fieldset-disabled">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div>
<button id="button1">Button 1</button>
<button id="button2">Button 2</button>
<button id="button3">Button 3</button>
<fieldset id="fieldset1"><button id="button4">Button 4</button></fieldset>
<fieldset id="fieldset2" disabled><legend><button id="button5">Button 5</button></legend></fieldset>
<div id="div" tabindex="0">Div</div>
<div id="editable" contenteditable=true>editor</div>
</div>
<script>
"use strict";
test(() => {
const button = document.querySelector("#button1");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
button.disabled = true;
assert_not_equals(document.activeElement, button, "After disabling, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling, the body must be focused");
}, "Disabling the active element (making it expressly inert)");
test(() => {
const button = document.querySelector("#button2");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
button.hidden = true;
assert_not_equals(document.activeElement, button, "After hiding, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After hiding, the body must be focused");
}, "Hiding the active element");
test(() => {
const button = document.querySelector("#button3");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
button.remove();
assert_not_equals(document.activeElement, button, "After removing, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After removing, the body must be focused");
}, "Removing the active element from the DOM");
test(() => {
const fieldset = document.querySelector("#fieldset1");
const button = document.querySelector("#button4");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
fieldset.disabled = true;
assert_not_equals(document.activeElement, button, "After disabling ancestor fieldset, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling ancestor fieldset, the body must be focused");
}, "Disabling <fieldset> affects its descendants");
test(() => {
const fieldset = document.querySelector("#fieldset2");
const button = document.querySelector("#button5");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
fieldset.insertBefore(document.createElement("legend"), fieldset.firstChild);
assert_not_equals(document.activeElement, button, "After changing a legend element, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After changing a legend element, the body must be focused");
}, "Changing the first legend element in disabled <fieldset>");
test(() => {
const div = document.querySelector("#div");
div.focus();
assert_equals(document.activeElement, div, "Sanity check: the div must start focused");
div.removeAttribute("tabindex");
assert_not_equals(document.activeElement, div, "After removing tabindex, the div must no longer be focused");
assert_equals(document.activeElement, document.body, "After removing tabindex, the body must be focused");
}, "Removing the tabindex attribute from a div");
test(() => {
const div = document.querySelector("#editable");
div.focus();
assert_equals(document.activeElement, div, "Sanity check: the div must start focused");
div.contentEditable = false;
assert_not_equals(document.activeElement, div, "After disabling contentEditable, the div must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling contentEditable, the body must be focused");
}, "Disabling contenteditable");
</script>

View file

@ -1,76 +0,0 @@
<!doctype html>
<title>focus(options) - preventScroll</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style>
#iframe { width: 500px; height: 500px; border: none }
</style>
<iframe id=iframe src="support/preventScroll-helper.html"></iframe>
<script>
function isEntirelyInView(elm, win) {
const inViewHorizontal = (elm.offsetLeft >= win.scrollX) &&
((elm.offsetLeft + elm.clientWidth) <= (win.scrollX + win.innerWidth));
const inViewVertical = (elm.offsetTop >= win.scrollY) &&
((elm.offsetTop + elm.clientHeight) <= (win.scrollY + win.innerHeight));
return inViewHorizontal && inViewVertical;
}
setup({explicit_done: true});
function resetState(win) {
win.scrollTo(0, 0);
win.document.activeElement.blur();
}
onload = () => {
const win = document.getElementById('iframe').contentWindow;
const elm = win.document.getElementById('button');
test(() => {
assert_false(isEntirelyInView(elm, win), 'initial state');
elm.scrollIntoView();
assert_true(isEntirelyInView(elm, win), 'after elm.scrollIntoView()');
resetState(win);
assert_false(isEntirelyInView(elm, win), 'after resetScrollPosition(win)');
}, 'Sanity test');
test(() => {
resetState(win);
elm.focus();
assert_true(isEntirelyInView(elm, win));
}, 'elm.focus() without arguments');
test(() => {
resetState(win);
elm.focus(undefined);
assert_true(isEntirelyInView(elm, win));
}, 'elm.focus(undefined)');
test(() => {
resetState(win);
elm.focus(null);
assert_true(isEntirelyInView(elm, win));
}, 'elm.focus(null)');
test(() => {
resetState(win);
elm.focus({});
assert_true(isEntirelyInView(elm, win));
}, 'elm.focus({})');
test(() => {
resetState(win);
elm.focus({preventScroll: false});
assert_true(isEntirelyInView(elm, win));
}, 'elm.focus({preventScroll: false})');
test(() => {
resetState(win);
elm.focus({preventScroll: true});
assert_equals(win.scrollX, 0);
assert_equals(win.scrollY, 0);
}, 'elm.focus({preventScroll: true})');
done();
}
</script>

View file

@ -1,6 +0,0 @@
<!doctype html>
<title>Helper document for preventScroll test</title>
<style>
body { padding: 2000px }
</style>
<button id=button>X</button>

View file

@ -1,21 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - default value of tabindex</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<button id="test1">TEST1</button>
<div id="test2">TEST2</div>
<script>
test(function() {
assert_equals(document.getElementById("test1").tabIndex, 0, "The value of tabIndex attribute should be 0.");
}, "The default value of tabIndex attribute must be 0 for elements that are focusable");
test(function() {
assert_equals(document.getElementById("test2").tabIndex, -1, "The value of tabIndex attribute should be -1.");
}, "The default value of tabIndex attribute must be -1 for elements that are not focusable");
</script>

View file

@ -1,44 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - negative tabindex</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<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>
<div id="log"></div>
<form id="fm">
<input id="test1" tabindex="-1">
<input id="test2" tabindex="0">
</form>
<script>
var t = async_test("The element with a negative tabindex must not be focused by press 'Tab' key");
setup({timeout: 10000});
document.forms.fm.addEventListener("focus", function (evt) {
t.step(function () {
var testEle = document.getElementById("test1");
assert_equals(testEle.tabIndex, -1, "The tabIndex attribute of the first input element should be -1.");
assert_not_equals(evt.target, testEle, "The second input element must be focused.");
assert_equals(document.activeElement, document.getElementById("test2"), "The second input element must be activated.");
});
t.done();
}, true);
document.addEventListener("keydown", function (evt) {
t.step(function () {
assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
});
}, true);
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
</script>

View file

@ -1,64 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - the sequential focus navigation order</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check the sequential focus navigation order">
<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>
<div id="log"></div>
<form id="fm">
<button id="btn0">tabindex(omitted)</button>
<button id="btn1" tabindex="">tabindex(empty)</button>
<button id="btn2" tabindex="a">tabindex(a)</button>
<button id="btn3" tabindex="-1">tabindex(-1)</button>
<button id="btn4" tabindex="0">tabindex(0)</button>
<button id="btn5" tabindex="3">tabindex(3)</button>
<button id="btn6" tabindex="2">tabindex(2)</button>
<button id="btn7" tabindex="2">tabindex(2)</button>
<button id="btn8" tabindex="2">tabindex(2)</button>
<button id="btn9" tabindex="1">tabindex(1)</button>
</form>
<script>
var i = 0,
expectation = ["btn9", "btn6", "btn7", "btn8", "btn5", "btn0", "btn1", "btn2", "btn4"],
results = [],
t = async_test("Elements with different tabindex must be focused sequentially when pressing 'Tab' keys");
setup(function () {
document.body.focus();
}, {timeout: 20000});
document.forms.fm.addEventListener("focus", function (evt) {
results.push(evt.target.id);
if (i >= 8) {
t.step(function () {
assert_array_equals(results, expectation);
});
t.done();
} else {
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
}
i++;
}, true);
document.addEventListener("keydown", function (evt) {
t.step(function () {
assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
});
}, true);
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
</script>

View file

@ -1,43 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focus - positive tabindex</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<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>
<div id="log"></div>
<form id="fm">
<input id="test" tabindex="1">
</form>
<script>
var t = async_test("The element with a positive tabindex must be focused by press 'Tab' key");
setup({timeout: 10000});
document.forms.fm.addEventListener("focus", function (evt) {
t.step(function () {
var testEle = document.getElementById("test");
assert_equals(testEle.tabIndex, 1, "The tabIndex attribute of the input element should be 1.");
assert_equals(evt.target, testEle, "The input element must be focused.");
assert_equals(document.activeElement, testEle, "The input element must be activated.");
});
t.done();
}, true);
document.addEventListener("keydown", function (evt) {
t.step(function () {
assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
});
}, true);
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
</script>

View file

@ -1,45 +0,0 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>HTML Test: focus - zero tabindex</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<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>
</head>
<div id="log"></div>
<form id="fm">
<input id="test" tabindex="0">
</form>
<script>
var t = async_test("The element with a zero tabindex must be focused by press 'Tab' key");
setup({timeout: 10000});
document.forms.fm.addEventListener("focus", function (evt) {
t.step(function () {
var testEle = document.getElementById("test");
assert_equals(testEle.tabIndex, 0, "The tabIndex attribute of the input element should be 0.");
assert_equals(evt.target, testEle, "The input element must be focused.");
assert_equals(document.activeElement, testEle, "The input element must be activated.");
});
t.done();
}, true);
document.addEventListener("keydown", function (evt) {
t.step(function () {
assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
});
}, true);
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
</script>

View file

@ -1,62 +0,0 @@
<!DOCTYPE html>
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#specially-focusable">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="default-samples">
<a></a>
<a href=""></a>
<button></button>
<input type="hidden">
<input type="button">
<select><option>abc</option></select>
<textarea></textarea>
<summary id="summary-out"></summary>
<details open><summary id="summary-first"></summary><summary id="summary-second"></summary></details>
<div contenteditable="true"></div>
<iframe></iframe>
</div>
<script>
const defaultList = [
['a', false],
['a[href]', true],
['button', true],
['input[type="hidden"]', false],
['input[type="button"]', true],
['select', true],
['textarea', true],
['#summary-out', false],
['#summary-first', true],
['#summary-second', false],
['[contenteditable]', true],
['iframe', true],
];
for (entry of defaultList) {
test(() => {
var element = document.querySelector('#default-samples ' + entry[0]);
element.focus();
if (entry[1])
assert_equals(document.activeElement, element);
else
assert_not_equals(document.activeElement, element);
}, entry[0] + ' should ' + (entry[1] ? '' : 'not ') + 'be focusable by default.');
}
</script>
<div id="tabindex-0">
<a tabindex="0"></a>
<summary tabindex="0" id="summary-out-tabindex0"></summary>
<details open><summary id="summary-first"></summary><summary tabindex="0" id="summary-second-tabindex0"></summary></details>
</div>
<script>
for (element of document.querySelectorAll('#tabindex-0 [tabindex]')) {
var elementDesc = element.tagName;
if (element.id)
elementDesc += '#' + element.id;
test(() => {
element.focus();
assert_equals(document.activeElement, element);
}, elementDesc + ' with tabindex=0 should be focusable.');
}
</script>
</body>