Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focusgroup - grid behavior token defaults</title>
<meta name="assert" content="grid enables row/column navigation with no wrapping by default.">
<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>
<table focusgroup="grid">
<tr>
<td id=g1 tabindex=0>g1</td>
<td id=g2 tabindex=0>g2</td>
</tr>
<tr>
<td id=g3 tabindex=0>g3</td>
<td id=g4 tabindex=0>g4</td>
</tr>
</table>
<script>
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g1'), kRight);
assert_equals(document.activeElement.id, 'g2');
}, "grid: Right moves to next column");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g2'), kLeft);
assert_equals(document.activeElement.id, 'g1');
}, "grid: Left moves to previous column");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g1'), kDown);
assert_equals(document.activeElement.id, 'g3');
}, "grid: Down moves to same column next row");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g3'), kUp);
assert_equals(document.activeElement.id, 'g1');
}, "grid: Up moves to same column previous row");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g2'), kRight);
assert_equals(document.activeElement.id, 'g2');
}, "grid: Right does not wrap at row end");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g1'), kLeft);
assert_equals(document.activeElement.id, 'g1');
}, "grid: Left does not wrap at row start");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g3'), kDown);
assert_equals(document.activeElement.id, 'g3');
}, "grid: Down does not wrap at column end");
promise_test(async t => {
await focusAndSendDirectionalInput(document.getElementById('g1'), kUp);
assert_equals(document.activeElement.id, 'g1');
}, "grid: Up does not wrap at column start");
</script>