OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../fast/js/resources/js-test-pre.js"></script> | |
4 <script src="../../editing/editing.js"></script> | |
3 <style> | 5 <style> |
4 .testDiv { | 6 .testDiv { |
5 width: 200px; | 7 width: 200px; |
6 height: 20px; | 8 height: 20px; |
7 border: 1px solid black; | 9 border: 1px solid black; |
8 white-space: nowrap; | 10 white-space: nowrap; |
9 overflow: hidden; | 11 overflow: hidden; |
10 } | 12 } |
11 | 13 |
12 .forcertl { | 14 .forcertl { |
13 direction: rtl; | 15 direction: rtl; |
14 unicode-bidi: bidi-override; | 16 unicode-bidi: bidi-override; |
15 } | 17 } |
16 | 18 |
17 .ellipses { | 19 .ellipses { |
18 text-overflow:ellipsis; | 20 text-overflow:ellipsis; |
19 } | 21 } |
20 | 22 |
21 </style> | 23 </style> |
24 </head> | |
25 <body> | |
22 | 26 |
23 <script> | 27 <script> |
24 function moveCursorOverAllWords(divName, numWords) { | 28 description("This tests the correct placement of inline spelling and grammar " |
25 div = document.getElementById(divName); | 29 + "markers in text. Spelling markers should line up exactly under misspelled " |
26 div.focus(); | 30 + "words in all cases."); |
27 var selection = window.getSelection(); | 31 |
28 // Move to start of text | 32 jsTestIsAsync = true; |
29 selection.modify("move", "backward", "line"); | 33 |
30 // Move cursor over all words so inline spellchecking is activated for all | 34 if (window.internals) { |
31 for (var i = 0; i < 100; i++ ) { | 35 internals.settings.setUnifiedTextCheckerEnabled(true); |
32 selection.modify("move", "forward", "word"); | 36 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
33 } | |
34 // Remove focus from the element, since the word under the cursor won't have a misspelling marker. | |
35 div.blur(); | |
36 } | 37 } |
37 | 38 |
38 function startTest() { | 39 if (window.testRunner) { |
39 if (!window.testRunner) | |
40 return; | |
41 testRunner.dumpAsTextWithPixelResults(); | 40 testRunner.dumpAsTextWithPixelResults(); |
42 testRunner.waitUntilDone(); | |
43 testRunner.setBackingScaleFactor(2, function () { | 41 testRunner.setBackingScaleFactor(2, function () { |
44 moveCursorOverAllWords('testLTR'); | 42 done(); |
45 moveCursorOverAllWords('testRTL'); | |
46 moveCursorOverAllWords('testLTREllipses'); | |
47 moveCursorOverAllWords('testRTLEllipses'); | |
48 testRunner.notifyDone(); | |
49 }); | 43 }); |
50 } | 44 } |
45 | |
51 </script> | 46 </script> |
52 </head> | |
53 <body onload="startTest()"> | |
54 <p id="explanation"> | |
55 This tests the correct placement of inline spelling and grammar markers in text. <br> | |
56 Spelling markers should line up exactly under misspelled words in all cases. | |
57 </p> | |
58 | 47 |
59 LTR | 48 LTR |
60 <div id="testLTR" class="testDiv" contenteditable="true"> | 49 <div id="testLTR" class="testDiv" contenteditable="true">the the adlj adaasj sdk lj. there there</div> |
61 the the adlj adaasj sdklj. there there | |
62 </div> | |
63 | 50 |
64 RTL | 51 RTL |
65 <div id="testRTL" class="testDiv forcertl" contenteditable="true"> | 52 <div id="testRTL" class="testDiv forcertl" contenteditable="true">the the adlj a daasj sdklj. there there</div> |
66 the the adlj adaasj sdklj. there there | |
67 </div> | |
68 | 53 |
54 LTR (text-overflow:ellipses) | |
55 <div id="testLTREllipses" class="testDiv ellipses" contenteditable="true">the th e adlj adaasj sdklj. there there</div> | |
69 | 56 |
70 LTR (text-overflow:ellipses): | 57 RTL (text-overflow:ellipses) |
71 <div id="testLTREllipses" class="testDiv ellipses" contenteditable="true"> | 58 <div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="tru e">the the adlj adaasj sdklj. there there</div> |
72 the the adlj adaasj sdklj. there there | |
73 </div> | |
74 | 59 |
75 RTL (text-overflow:ellipses): | 60 <script> |
76 <div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="tru e"> | 61 function moveCursorOverAllWords(id) |
77 the the adlj adaasj sdklj. there there | 62 { |
78 </div> | 63 div = document.getElementById(id); |
64 div.focus(); | |
79 | 65 |
66 debug(id + ":"); | |
67 // Move cursor over all words so inline spellchecking is activated for all. | |
68 for (var i = 0; i < div.innerHTML.length; i++) | |
69 moveSelectionForwardByWordCommand(); | |
70 | |
71 verifyMarkers(); | |
72 } | |
73 | |
74 function verifyMarkers() | |
75 { | |
76 if (!window.internals) | |
77 return done(); | |
78 | |
79 // Take care of spelling markers first. | |
80 shouldBecomeEqual('internals.hasSpellingMarker(document, 8, 4)', 'true', fun ction() { // Verifies 'adlj'. | |
81 shouldBecomeEqual('internals.hasSpellingMarker(document, 13, 6)', 'true' , function() { // Verifies 'adaasj'. | |
82 shouldBecomeEqual('internals.hasSpellingMarker(document, 20, 5)', 't rue', verifyGrammarMarkers) // Verifies 'sdklj'. | |
83 }) | |
84 }); | |
85 | |
86 function verifyGrammarMarkers() { | |
87 shouldBecomeEqual('internals.hasGrammarMarker(document, 4, 3)', 'true', function() { // Verifies second 'the'. | |
88 shouldBecomeEqual('internals.hasGrammarMarker(document, 33, 5)', 'tr ue', function() { // Verifies second 'there'. | |
89 // Markers of next element can not be found after modification s election without blur event. | |
90 div.blur(); | |
91 done(); | |
92 }) | |
93 }); | |
94 } | |
95 } | |
96 | |
97 var tests = [ function() { moveCursorOverAllWords('testLTR'); }, | |
98 function() { moveCursorOverAllWords('testRTL'); }, | |
99 function() { moveCursorOverAllWords('testLTREllipses'); }, | |
100 function() { moveCursorOverAllWords('testRTLEllipses'); } ]; | |
101 | |
102 function done() | |
103 { | |
104 var next = tests.shift(); | |
105 if (next) | |
106 return window.setTimeout(next, 0); | |
107 | |
108 finishJSTest(); | |
109 } | |
110 </script> | |
111 <script src="../../fast/js/resources/js-test-post.js"></script> | |
tony
2013/11/04 17:59:09
Remove this too.
grzegorz
2013/11/06 07:47:24
Done.
| |
80 </body> | 112 </body> |
81 </html> | 113 </html> |
OLD | NEW |