| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <script src="../../resources/js-test.js"></script> |
| <script src="../../resources/accessibility-helper.js"></script> |
| <body id="body" tabindex="0"> |
| |
| <div tabindex="0" id="text1">text</div> |
| |
| text |
| |
| <div tabindex="0" id="text2">text</div> |
| |
| <script> |
| var output = "This verifies usage of isTextMarkerValid, indexForTextMarker and textMarkerForIndex.\n\n"; |
| var item1, item2, markerRange, firstTextMarker, secondTextMarker; |
| |
| if (window.accessibilityController) { |
| window.jsTestIsAsync = true; |
| item1 = accessibilityController.accessibleElementById("text1"); |
| markerRange = item1.textMarkerRangeForElement(item1); |
| firstTextMarker = item1.startTextMarkerForTextMarkerRange(markerRange); |
| |
| output += expect("item1.isTextMarkerValid(firstTextMarker)", "true"); |
| output += expect("item1.indexForTextMarker(firstTextMarker)", "0"); |
| output += expect("item1.textMarkerForIndex(0).isEqual(firstTextMarker)", "true"); |
| |
| document.getElementById("body").removeChild(document.getElementById("text1")); |
| |
| setTimeout(async function() { |
| output += await expectAsync("item1.isTextMarkerValid(firstTextMarker)", "false"); |
| |
| item2 = accessibilityController.accessibleElementById("text2"); |
| markerRange = item2.textMarkerRangeForElement(item2); |
| secondTextMarker = item2.startTextMarkerForTextMarkerRange(markerRange); |
| |
| output += await expectAsync("item2.isTextMarkerValid(secondTextMarker)", "true"); |
| output += await expectAsync("item2.indexForTextMarker(secondTextMarker)", "5"); |
| output += await expectAsync("item2.textMarkerForIndex(item2.indexForTextMarker(secondTextMarker)).isEqual(secondTextMarker)", "true"); |
| |
| debug(output); |
| finishJSTest(); |
| }, 0); |
| } |
| </script> |
| </body> |
| </html> |