blob: f00d702dd1df0f20e776ba9418a416e8320c16d7 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<style>
div {
width: 100px;
height: 100px;
margin: 5px;
border: 1px solid black;
}
</style>
<div id="first" tabindex="0">First</div>
<div id="second" tabindex="0">Second</div>
<div id="third" tabindex="0">Third</div>
<script>
// This test checks that calling prevent default on key events doesn't
// prevent moving interest or entering/exiting focus.
let first = document.getElementById("first");
let second = document.getElementById("second");
let third = document.getElementById("third");
snav.assertSnavEnabledAndTestable(true /* focuslessSpatNav */ );
test(() => {
assert_true(!!window.internals);
// Move interest to 'second'
snav.triggerMove('Down');
snav.triggerMove('Down');
assert_equals(window.internals.interestedElement,
second,
"'second' should be interested");
// Send escape key, this should reset interest.
eventSender.keyDown('Escape');
// Send down arrow key. Since we reset interest, it should start from the
// top again.
snav.triggerMove('Down');
assert_equals(window.internals.interestedElement,
first,
"'first' should be interested after reset and down");
}, "Focusless navigation reset interest.");
</script>