blob: b4eb3dda1251c83fc265e247e75fd1bdd77f8633 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<title>Select Text</title>
</head>
<body>
<p contenteditable="true" id="text">The quick brown fox <span id="target">jumps</span> over the lazy dog. </p>
<p contenteditable="true" id="text2">TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</p>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests the ability to select and replace text with respect to selection.");
function selectedText() {
return window.getSelection().toString();
}
function selectElementText(element) {
var range = document.createRange();
range.selectNodeContents(element);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
if (window.accessibilityController) {
var text = accessibilityController.accessibleElementById("text");
var result = 0;
var selection = 0;
var target = document.getElementById("target");
// Select text after selection (multiple search strings).
selectElementText(target);
result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestAfterSelection", ["lazy", "over"]);
shouldBe("result", "'over'");
selection = selectedText();
shouldBe("selection", "'over'");
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>