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

@ -0,0 +1,109 @@
<!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

@ -0,0 +1,17 @@
<!doctype html>
<title>legend focusable</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
const t = async_test();
</script>
<fieldset>
<legend tabindex=0 onfocus="t.step(() => { t.done(); })">
legend
<input onfocus="t.unreached_func('input in legend was focused')();">
</legend>
<input onfocus="t.unreached_func('input after legend was focused')();">
</fieldset>
<script>
document.querySelector('legend').focus();
</script>

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>legend</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
const t = async_test();
</script>
<fieldset>
<legend onfocus="t.unreached_func('legend was focused')()">
legend
<input onfocus="t.unreached_func('input in legend was focused')();">
</legend>
<input onfocus="t.unreached_func('input after legend was focused')();">
</fieldset>
<script>
document.querySelector('legend').focus();
t.step_timeout(() => {
t.done();
}, 500);
</script>

View file

@ -0,0 +1,76 @@
<!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

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