| <!DOCTYPE html> |
| <script src="../../../../../resources/testharness.js"></script> |
| <script src="../../../../../resources/testharnessreport.js"></script> |
| <script src="../../../../../fast/spatial-navigation/resources/snav-testharness.js"></script> |
| |
| <a id="link" href="#active">Activate</a> |
| |
| <script> |
| if (accessibilityController) { |
| accessibilityController.reset(); |
| } |
| |
| // This test checks that pressing enter over an unfocused but interested |
| // element will activate it. |
| let link = document.getElementById("link"); |
| |
| testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); |
| // We have to call this or overriding preferences will un-set spat-nav being |
| // enabled. |
| testRunner.overridePreference('WebKitSpatialNavigationEnabled', 1); |
| |
| test(() => { |
| assert_true(!!window.internals); |
| |
| // Move interest to 'link' |
| snav.triggerMove('Down'); |
| |
| assert_not_equals(document.activeElement, |
| link, |
| "'link' must not be focused"); |
| assert_equals(window.internals.interestedElement, |
| link, |
| "'link' must be interested"); |
| |
| // Press enter key. Ensure that the link was activated by making sure we |
| // navigated to the fragment. |
| eventSender.keyDown('Enter'); |
| assert_equals(window.location.hash, |
| "#active", |
| "Enter key over 'link' should cause navigation"); |
| }, "Enter key from unfocused element."); |
| </script> |