Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/interaction/focus/focusgroup/tentative/sequential-navigation/directional-input-handler-with-explicit-optout.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focusgroup - Native directional input handler with explicit focusgroup=none</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="/resources/testdriver-actions.js"></script>
<script src="/shadow-dom/focus-navigation/resources/focus-utils.js"></script>
<script src="../resources/focusgroup-utils.js"></script>
<button tabindex=0 id="before">Before</button>
<div id="toolbar" focusgroup="toolbar">
<button tabindex=0 id="btn1">Button 1</button>
<input id="search" type="text" focusgroup="none" placeholder="Search">
<button tabindex=0 id="btn2">Button 2</button>
</div>
<button tabindex=0 id="after">After</button>
<script>
promise_test(async t => {
const btn1 = document.getElementById("btn1");
const search = document.getElementById("search");
const btn2 = document.getElementById("btn2");
// Element with focusgroup="none" is excluded from directional navigation entirely.
await assert_directional_navigation_bidirectional([btn1, btn2]);
}, "Explicit focusgroup=none excludes element from directional navigation");
promise_test(async t => {
const search = document.getElementById("search");
await focusAndWait(search);
assert_equals(document.activeElement, search, "Can manually focus opted-out element");
// Directional input should not trigger focusgroup navigation from opted-out element.
await assert_directional_input_does_not_move_focus(search);
}, "Directional input does not work from explicitly opted-out native directional input handler");
promise_test(async t => {
const before = document.getElementById("before");
const btn1 = document.getElementById("btn1");
const search = document.getElementById("search");
const btn2 = document.getElementById("btn2");
const after = document.getElementById("after");
// Explicit opt-out means element is in normal Tab order regardless of focus state.
// Native directional input handlers (without explicit opt-out) remain focusgroup items
// and use Tab escape to navigate to adjacent items when focused.
await assert_focusgroup_tab_navigation([before, btn1, search, btn2, after]);
}, "Explicit focusgroup=none includes element in Tab order even when not focused");
</script>