| <!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"); |
| |
| document.getElementById("text2").focus(); |
| var windowSelection = window.getSelection(); |
| windowSelection.removeAllRanges(); |
| |
| // [https://bugs.webkit.org/show_bug.cgi?id=135575] |
| // When an existing range is already selected, we should not ignore that when searching for future activities. |
| // First find the range before the current selection. |
| var range = document.createRange(); |
| range.setStart(document.getElementById("text2").firstChild, 7); |
| range.setEnd(document.getElementById("text2").firstChild, 10); |
| windowSelection.removeAllRanges(); |
| windowSelection.addRange(range); |
| shouldBe("windowSelection.getRangeAt(0).toString()", "'The'"); |
| |
| var text2 = accessibilityController.accessibleElementById("text2"); |
| result = text2.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "the", null, "AXSelectTextActivityFindAndUppercase"); |
| shouldBe("result", "'THE'"); |
| shouldBe("windowSelection.getRangeAt(0).toString()", "'THE'"); |
| shouldBe("windowSelection.getRangeAt(0).startOffset", "7"); |
| shouldBe("windowSelection.getRangeAt(0).endOffset", "10"); |
| } |
| </script> |
| |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |