Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 5 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/interaction/focus/focusgroup/tentative/behavior-tokens/toolbar.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focusgroup - toolbar behavior token defaults</title>
<meta name="assert" content="toolbar implies inline axis, no wrap. Explicit wrap adds wrapping.">
<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>
<div focusgroup="toolbar">
<button tabindex=0 id=tb1>tb1</button>
<button tabindex=0 id=tb2>tb2</button>
<button tabindex=0 id=tb3>tb3</button>
</div>
<!-- toolbar wrap: adds wrapping to non-wrapping default -->
<div focusgroup="toolbar wrap">
<button tabindex=0 id=tw1>tw1</button>
<button tabindex=0 id=tw2>tw2</button>
<button tabindex=0 id=tw3>tw3</button>
</div>
<script>
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb1'), kRight);
assert_equals(document.activeElement.id, 'tb2');
}, "toolbar: Right navigates to the next item");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb2'), kLeft);
assert_equals(document.activeElement.id, 'tb1');
}, "toolbar: Left navigates to the previous item");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb1'), kDown);
assert_equals(document.activeElement.id, 'tb1');
}, "toolbar: Down blocked");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb1'), kUp);
assert_equals(document.activeElement.id, 'tb1');
}, "toolbar: Up blocked");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb3'), kRight);
assert_equals(document.activeElement.id, 'tb3');
}, "toolbar: Right does not wrap at end");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tb1'), kLeft);
assert_equals(document.activeElement.id, 'tb1');
}, "toolbar: Left does not wrap at start");
// --- toolbar wrap: adds wrapping to non-wrapping default ---
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tw1'), kRight);
assert_equals(document.activeElement.id, 'tw2');
}, "toolbar wrap: Right navigates to the next item");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tw3'), kRight);
assert_equals(document.activeElement.id, 'tw1');
}, "toolbar wrap: Right wraps at end");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tw1'), kLeft);
assert_equals(document.activeElement.id, 'tw3');
}, "toolbar wrap: Left wraps at start");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('tw1'), kDown);
assert_equals(document.activeElement.id, 'tw1');
}, "toolbar wrap: Down still blocked");
</script>