blob: ba2d71ce9ba9c1b44cae598f27644774aa4d14ae [file] [log] [blame]
<!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 include AXTextSelectionChangedFocus flag.");
jsTestIsAsync = true;
var webArea = 0;
var axTextFocusChangeOne = 0;
var axTextFocusChangeTwo = 0;
var axTextFocusChangeThree = 0;
var axTextFocusChangeFour = 0;
var selectCount = 0;
var focusCount = 0;
// Notification ordering:
// The first tab will result in 2 selection change notifications and a focus notification selectCount=2, focusCount=1
// takeFocus() will result in a focus notification selectCount=2, focusCount=2
// The second tab will result in another 2 selection change notifications and a focus notification selectCount=1, focusCount=3
// (The 2 selection change notifications per tab is caused by caret browsing being enabled)
function notificationCallback(notification, userInfo) {
if (notification == "AXSelectedTextChanged") {
selectCount++;
if (selectCount == 1) {
axTextFocusChangeOne = userInfo["AXTextSelectionChangedFocus"];
shouldBeTrue("axTextFocusChangeOne");
} else if (selectCount == 2) {
axTextFocusChangeTwo = userInfo["AXTextSelectionChangedFocus"];
shouldBeTrue("axTextFocusChangeTwo");
shouldBeTrue("accessibilityController.accessibleElementById(\"1\").isFocusable");
accessibilityController.accessibleElementById("1").takeFocus();
} else if (selectCount == 3) {
axTextFocusChangeThree = userInfo["AXTextSelectionChangedFocus"];
shouldBeTrue("axTextFocusChangeThree");
} else if (selectCount == 4) {
axTextFocusChangeFour = userInfo["AXTextSelectionChangedFocus"];
shouldBeTrue("axTextFocusChangeFour");
}
} else if (notification == "AXFocusChanged") {
focusCount++;
if (focusCount == 2)
eventSender.scheduleAsynchronousKeyDown("\t");
}
if (selectCount == 4 && focusCount == 3) {
webArea.removeNotificationListener();
finishJSTest();
}
}
function runTest() {
if (window.accessibilityController) {
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
accessibilityController.enableEnhancedAccessibility(true);
webArea = accessibilityController.rootElement.childAtIndex(0);
webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true)
addedNotification = webArea.addNotificationListener(notificationCallback);
shouldBeTrue("addedNotification");
eventSender.keyDown("\t");
} else {
debug("window.accessibilityController is not present");
finishJSTest();
}
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>