blob: acb7e0c1192e799c998d7435adf139b5a5608c3e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body id="body">
<div role="textbox" tabindex=0 id="textbox" contenteditable=true>
<p>one two three. four five six.</p>
</div>
<p id="description"></p>
<div id="console"></div>
<div id="notifications"></div>
<script>
description("This tests that selection changes originating from accessibility API include AXTextStateSync=true.");
var AXTextStateChangeTypeSelectionMove = 2;
var AXTextStateChangeTypeSelectionExtend = AXTextStateChangeTypeSelectionMove + 1;
var AXTextSelectionDirectionDiscontiguous = 5;
var webArea = 0;
var count = 0;
var results = [];
var resultIndex = 0;
function notificationCallback(notification, userInfo) {
if (notification == "AXSelectedTextChanged") {
count++;
if (userInfo)
results.push(userInfo);
if (count == 5) {
shouldBe("results[resultIndex][\"AXTextStateChangeType\"]", "AXTextStateChangeTypeSelectionMove");
shouldBe("results[resultIndex][\"AXTextSelectionDirection\"]", "AXTextSelectionDirectionDiscontiguous");
shouldBe("results[resultIndex][\"AXTextStateSync\"]", "true");
resultIndex++;
shouldBe("results[resultIndex][\"AXTextStateChangeType\"]", "AXTextStateChangeTypeSelectionMove");
shouldBe("results[resultIndex][\"AXTextSelectionDirection\"]", "AXTextSelectionDirectionDiscontiguous");
shouldBe("results[resultIndex][\"AXTextStateSync\"]", "true");
resultIndex++;
shouldBe("results[resultIndex][\"AXTextStateChangeType\"]", "AXTextStateChangeTypeSelectionExtend");
shouldBe("results[resultIndex][\"AXTextSelectionDirection\"]", "AXTextSelectionDirectionDiscontiguous");
shouldBe("results[resultIndex][\"AXTextStateSync\"]", "true");
resultIndex++;
shouldBe("results[resultIndex][\"AXTextStateChangeType\"]", "AXTextStateChangeTypeSelectionMove");
shouldBe("results[resultIndex][\"AXTextSelectionDirection\"]", "AXTextSelectionDirectionDiscontiguous");
shouldBe("results[resultIndex][\"AXTextStateSync\"]", "true");
resultIndex++;
shouldBe("results[resultIndex][\"AXTextStateChangeType\"]", "AXTextStateChangeTypeSelectionExtend");
shouldBe("results[resultIndex][\"AXTextSelectionDirection\"]", "AXTextSelectionDirectionDiscontiguous");
shouldBe("results[resultIndex][\"AXTextStateSync\"]", "true");
webArea.removeNotificationListener();
finishJSTest();
}
}
}
if (window.accessibilityController) {
window.jsTestIsAsync = true;
accessibilityController.enableEnhancedAccessibility(true);
webArea = accessibilityController.rootElement.childAtIndex(0);
var addedNotification = webArea.addNotificationListener(notificationCallback);
shouldBe("addedNotification", "true");
textbox = document.getElementById("textbox");
var axTextbox = accessibilityController.accessibleElementById("textbox");
axTextbox.takeFocus();
axTextbox.setSelectedTextRange(4,0);
axTextbox.setSelectedTextRange(0,3);
var markerThree = axTextbox.textMarkerForIndex(3);
var markerFour = axTextbox.textMarkerForIndex(4);
var moveRange = axTextbox.textMarkerRangeForMarkers(markerThree, markerThree);
var extendRange = axTextbox.textMarkerRangeForMarkers(markerThree, markerFour);
webArea.setSelectedVisibleTextRange(moveRange);
webArea.setSelectedVisibleTextRange(extendRange);
} else
debug("window.accessibilityController is not present");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>