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