AX: Support solution to handle invalid ax text marker
[WebKit-https.git] / LayoutTests / platform / mac / accessibility / textmarker-routines.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <script src="../../../fast/js/resources/js-test-pre.js"></script>
4 <body id="body" tabindex="0">
5
6 <div tabindex="0" id="text1">text</div>
7
8 text
9
10 <div tabindex="0" id="text2">text</div>
11
12 <p id="description"></p>
13 <div id="console"></div>
14
15 <script>
16
17     description("This verifies usage of isTextMarkerValid, indexForTextMarker and textMarkerForIndex.");
18
19     if (window.accessibilityController) {
20         document.getElementById("text1").focus();
21         var item1 = accessibilityController.focusedElement;
22         var markerRange = item1.textMarkerRangeForElement(item1);
23         var firstTextMarker = item1.startTextMarkerForTextMarkerRange(markerRange);
24
25         shouldBeTrue("item1.isTextMarkerValid(firstTextMarker)");
26         shouldBe("item1.indexForTextMarker(firstTextMarker)", "0");
27         shouldBeTrue("item1.textMarkerForIndex(0).isEqual(firstTextMarker)");       
28
29         document.getElementById("body").removeChild(document.getElementById("text1"));
30
31         shouldBeFalse("item1.isTextMarkerValid(firstTextMarker)");
32
33         document.getElementById("text2").focus();
34         var item2 = accessibilityController.focusedElement;
35         markerRange = item2.textMarkerRangeForElement(item2);
36         var secondTextMarker = item2.startTextMarkerForTextMarkerRange(markerRange);
37
38         shouldBeTrue("item2.isTextMarkerValid(secondTextMarker)");
39         shouldBe("item2.indexForTextMarker(secondTextMarker)", "5");
40         shouldBeTrue("item2.textMarkerForIndex(item2.indexForTextMarker(secondTextMarker)).isEqual(secondTextMarker)");       
41     }
42
43 </script>
44
45 <script src="../../../fast/js/resources/js-test-post.js"></script>
46
47 </body>
48 </html>
49