Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focusgroup - Guaranteed tab stop entry and exit</title>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/">
<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="/resources/testdriver-actions.js"></script>
<script src="/shadow-dom/focus-navigation/resources/focus-utils.js"></script>
<script src="../resources/focusgroup-utils.js"></script>
<!-- Basic focusgroup for entry/exit testing -->
<div id=before tabindex=0>Before focusgroup</div>
<div id=focusgroup1 focusgroup="toolbar no-memory">
<span id=item1 tabindex=0>Item 1</span>
<span id=item2 tabindex=0>Item 2</span>
<span id=item3 tabindex=0>Item 3</span>
</div>
<div id=after tabindex=0>After focusgroup</div>
<script>
promise_test(async t => {
var before = document.getElementById("before");
var item1 = document.getElementById("item1");
var after = document.getElementById("after");
before.focus();
await navigateFocusForward();
assert_equals(document.activeElement, item1, "Tab should enter focusgroup at first item in tree order");
await navigateFocusForward();
assert_equals(document.activeElement, after, "Tab should exit focusgroup to next focusable element");
}, "Tab enters focusgroup at first item in tree order and exits normally");
promise_test(async t => {
var after = document.getElementById("after");
var item1 = document.getElementById("item1");
var before = document.getElementById("before");
after.focus();
await navigateFocusBackward();
assert_equals(document.activeElement, item1, "Shift+Tab should enter focusgroup at first item in tree order");
await navigateFocusBackward();
assert_equals(document.activeElement, before, "Shift+Tab should exit focusgroup to previous focusable element");
}, "Shift+Tab enters focusgroup at first item in tree order and exits normally");
promise_test(async t => {
var item1 = document.getElementById("item1");
var item2 = document.getElementById("item2");
var item3 = document.getElementById("item3");
item1.focus();
await focusAndKeyPress(item1, kArrowRight);
assert_equals(document.activeElement, item2, "Arrow key navigation should work within focusgroup");
await focusAndKeyPress(item2, kArrowRight);
assert_equals(document.activeElement, item3, "Arrow key navigation should continue working");
}, "Arrow key navigation continues to work normally within focusgroup");
</script>