|
1 | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
2 | 2 | <html>
|
3 | 3 | <head>
|
4 |
| -<script src="../resources/js-test-pre.js"></script> |
5 |
| -<script> |
6 |
| -if (window.testRunner) |
7 |
| - testRunner.dumpAsText(); |
8 |
| -</script> |
| 4 | +<script src="../resources/accessibility-helper.js"></script> |
| 5 | +<script src="../resources/js-test.js"></script> |
9 | 6 | </head>
|
10 | 7 | <body>
|
11 | 8 |
|
12 | 9 | <div contenteditable=true id="content" role="textbox">
|
13 | 10 | wrods is misspelled aab lotsi nowadays. euep.
|
14 | 11 | </div>
|
15 | 12 |
|
16 |
| -<p id="description"></p> |
17 |
| -<div id="console"></div> |
18 |
| - |
19 | 13 | <script>
|
20 |
| - description("This tests that misspelling ranges are properly retrieved in the fashion that a spell checker would."); |
21 |
| - |
22 |
| - if (window.accessibilityController) { |
23 |
| - var content = document.getElementById("content"); |
24 |
| - content.focus(); |
| 14 | +let output = "This tests that misspelling ranges are properly retrieved in the fashion that a spell checker would.\n\n"; |
| 15 | +jsTestIsAsync = true; |
25 | 16 |
|
26 |
| - var text = accessibilityController.focusedElement; |
| 17 | +if (window.accessibilityController && window.internals) { |
| 18 | + var content = document.getElementById("content"); |
| 19 | + content.focus(); |
| 20 | + var text = accessibilityController.focusedElement; |
27 | 21 |
|
28 |
| - var textMarkerRange = text.textMarkerRangeForElement(text); |
29 |
| - var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange); |
30 |
| - debug("textMarkerRange start: " + text.indexForTextMarker(startMarker)); |
31 |
| - var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange); |
32 |
| - debug("textMarkerRange end: " + text.indexForTextMarker(endMarker)); |
| 22 | + var textMarkerRange = text.textMarkerRangeForElement(text); |
| 23 | + var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange); |
| 24 | + output += `textMarkerRange start: ${text.indexForTextMarker(startMarker)}\n`; |
| 25 | + var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange); |
| 26 | + output += `textMarkerRange end: ${text.indexForTextMarker(endMarker)}\n`; |
33 | 27 |
|
34 |
| - // Find the first misspelling, "wrods". |
35 |
| - var startRange = text.textMarkerRangeForMarkers(startMarker, startMarker); |
36 |
| - startMarker = text.startTextMarkerForTextMarkerRange(startRange); |
37 |
| - debug("startRange start: " + text.indexForTextMarker(startMarker)); |
38 |
| - endMarker = text.endTextMarkerForTextMarkerRange(startRange); |
39 |
| - debug("startRange end: " + text.indexForTextMarker(endMarker)); |
| 28 | + // Find the first misspelling, "wrods". |
| 29 | + var startRange = text.textMarkerRangeForMarkers(startMarker, startMarker); |
| 30 | + startMarker = text.startTextMarkerForTextMarkerRange(startRange); |
| 31 | + output += `startRange start: ${text.indexForTextMarker(startMarker)}\n`; |
| 32 | + endMarker = text.endTextMarkerForTextMarkerRange(startRange); |
| 33 | + output += `startRange end: ${text.indexForTextMarker(endMarker)}\n`; |
40 | 34 |
|
41 |
| - var misspellingRange = text.misspellingTextMarkerRange(startRange, true); |
42 |
| - startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange); |
43 |
| - debug("misspelling start: " + text.indexForTextMarker(startMarker)); |
| 35 | + setTimeout(async () => { |
| 36 | + misspellingRange = null; |
| 37 | + startMarker = null; |
| 38 | + await waitFor(() => { |
| 39 | + misspellingRange = text.misspellingTextMarkerRange(startRange, true); |
| 40 | + startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange); |
| 41 | + return text.indexForTextMarker(startMarker) >= 0; |
| 42 | + }); |
| 43 | + output += `misspelling start: ${text.indexForTextMarker(startMarker)}\n`; |
44 | 44 | endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
|
45 |
| - debug("misspelling end: " + text.indexForTextMarker(endMarker)); |
46 |
| - shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'wrods'"); |
| 45 | + output += `misspelling end: ${text.indexForTextMarker(endMarker)}\n`; |
| 46 | + output += expect("text.stringForTextMarkerRange(misspellingRange)", "'wrods'"); |
47 | 47 |
|
48 | 48 | // Find the next one, "aab".
|
49 | 49 | startRange = misspellingRange;
|
50 | 50 | misspellingRange = text.misspellingTextMarkerRange(startRange, true);
|
51 | 51 | startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
|
52 |
| - debug("misspelling start: " + text.indexForTextMarker(startMarker)); |
| 52 | + output += `misspelling start: ${text.indexForTextMarker(startMarker)}\n`; |
53 | 53 | endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
|
54 |
| - debug("misspelling end: " + text.indexForTextMarker(endMarker)); |
55 |
| - shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'aab'"); |
| 54 | + output += `misspelling end: ${text.indexForTextMarker(endMarker)}\n`; |
| 55 | + output += expect("text.stringForTextMarkerRange(misspellingRange)", "'aab'"); |
56 | 56 |
|
57 | 57 | // Find the next one, "lotsi".
|
58 | 58 | startRange = misspellingRange;
|
59 | 59 | misspellingRange = text.misspellingTextMarkerRange(startRange, true);
|
60 | 60 | startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
|
61 |
| - debug("misspelling start: " + text.indexForTextMarker(startMarker)); |
| 61 | + output += `misspelling start: ${text.indexForTextMarker(startMarker)}\n`; |
62 | 62 | endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
|
63 |
| - debug("misspelling end: " + text.indexForTextMarker(endMarker)); |
64 |
| - shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'"); |
| 63 | + output += `misspelling end: ${text.indexForTextMarker(endMarker)}\n`; |
| 64 | + output += expect("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'"); |
65 | 65 |
|
66 | 66 | // Find the next one, "euep".
|
67 | 67 | startRange = misspellingRange;
|
68 | 68 | misspellingRange = text.misspellingTextMarkerRange(startRange, true);
|
69 | 69 | startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
|
70 |
| - debug("misspelling start: " + text.indexForTextMarker(startMarker)); |
| 70 | + output += `misspelling start: ${text.indexForTextMarker(startMarker)}\n`; |
71 | 71 | endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
|
72 |
| - debug("misspelling end: " + text.indexForTextMarker(endMarker)); |
73 |
| - shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'euep'"); |
| 72 | + output += `misspelling end: ${text.indexForTextMarker(endMarker)}\n`; |
| 73 | + output += expect("text.stringForTextMarkerRange(misspellingRange)", "'euep'"); |
74 | 74 |
|
75 | 75 | // Find the previous one, "lotsi".
|
76 | 76 | startRange = misspellingRange;
|
77 | 77 | misspellingRange = text.misspellingTextMarkerRange(startRange, false);
|
78 | 78 | startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
|
79 |
| - debug("misspelling start: " + text.indexForTextMarker(startMarker)); |
| 79 | + output += `misspelling start: ${text.indexForTextMarker(startMarker)}\n`; |
80 | 80 | endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
|
81 |
| - debug("misspelling end: " + text.indexForTextMarker(endMarker)); |
82 |
| - shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'"); |
83 |
| - } |
84 |
| -</script> |
| 81 | + output += `misspelling end: ${text.indexForTextMarker(endMarker)}\n`; |
| 82 | + output += expect("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'"); |
85 | 83 |
|
86 |
| -<script src="../resources/js-test-post.js"></script> |
| 84 | + debug(output); |
| 85 | + finishJSTest(); |
| 86 | + }, 0); |
| 87 | +} |
| 88 | +</script> |
87 | 89 | </body>
|
88 | 90 | </html>
|
89 |
| - |
|
0 commit comments