| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body id="body" onload="runTest()"> |
| <fieldset> |
| <div> |
| <input id="1"> |
| <label for="1">1</label> |
| </div> |
| <div> |
| <input id="2"> |
| <label for="2">2</label> |
| </div> |
| </fieldset> |
| <script> |
| description("This tests that selection changes as a result of advancing focus."); |
| jsTestIsAsync = true; |
| |
| var webArea = 0; |
| var tabCharacter = "\t"; |
| |
| function notificationCallback(notification, userInfo) { |
| if (notification == "AXSelectedTextChanged" || notification == "AXFocusChanged") |
| window.promise.resolve(); |
| } |
| |
| function runTest() { |
| if (!window.accessibilityController) { |
| debug("window.accessibilityController is not present"); |
| finishJSTest(); |
| return; |
| } |
| |
| runFirstTabMoveTest(); |
| } |
| |
| function runFirstTabMoveTest() { |
| testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); |
| |
| accessibilityController.enableEnhancedAccessibility(true); |
| webArea = accessibilityController.rootElement.childAtIndex(0); |
| webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true) |
| |
| shouldBeTrue("webArea.addNotificationListener(notificationCallback)"); |
| evalAndLog("eventSender.keyDown(tabCharacter);"); |
| |
| window.promise = new Promise(function(resolve, reject) { |
| setTimeout(() => { |
| runTakeFocusTest(); |
| }, 0); |
| }); |
| } |
| |
| function runTakeFocusTest() { |
| debug(''); |
| shouldBeTrue("accessibilityController.accessibleElementById(\"1\").isFocusable"); |
| evalAndLog("accessibilityController.accessibleElementById(\"1\").takeFocus()"); |
| |
| window.promise = new Promise(function(resolve, reject) { |
| setTimeout(() => { |
| runSecondTabMoveTest(); |
| }, 0); |
| }); |
| } |
| |
| function runSecondTabMoveTest() { |
| debug(''); |
| evalAndLog("eventSender.keyDown(tabCharacter)"); |
| |
| window.promise = new Promise(function(resolve, reject) { |
| setTimeout(() => { |
| webArea.removeNotificationListener(); |
| finishJSTest(); |
| }, 0); |
| }); |
| } |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |