Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: LayoutTests/editing/spelling/inline_spelling_markers.html

Issue 49613006: Refactoring inline_spelling_markers.html to use async path for spellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../fast/js/resources/js-test-pre.js"></script>
3 <style> 4 <style>
4 .testDiv { 5 .testDiv {
5 width: 200px; 6 width: 200px;
6 height: 20px; 7 height: 20px;
7 border: 1px solid black; 8 border: 1px solid black;
8 white-space: nowrap; 9 white-space: nowrap;
9 overflow: hidden; 10 overflow: hidden;
10 } 11 }
11 12
12 .forcertl { 13 .forcertl {
13 direction: rtl; 14 direction: rtl;
14 unicode-bidi: bidi-override; 15 unicode-bidi: bidi-override;
15 } 16 }
16 17
17 .ellipses { 18 .ellipses {
18 text-overflow:ellipsis; 19 text-overflow:ellipsis;
19 } 20 }
20 21
21 </style> 22 </style>
22 23
24 </head>
25 <body>
23 <script> 26 <script>
24 function moveCursorOverAllWords(divName, numWords) { 27 description("This tests the correct placement of inline spelling and grammar "
25 div = document.getElementById(divName); 28 + "markers in text. Spelling markers should line up exactly under misspelled "
26 div.focus(); 29 + "words in all cases.");
27 var selection = window.getSelection(); 30
28 // Move to start of text 31 jsTestIsAsync = true;
29 selection.modify("move", "backward", "line"); 32
30 // Move cursor over all words so inline spellchecking is activated for all 33 if (window.internals) {
31 for (var i = 0; i < 100; i++ ) { 34 internals.settings.setUnifiedTextCheckerEnabled(true);
32 selection.modify("move", "forward", "word"); 35 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 } 36 }
37 37
38 function startTest() { 38 if (window.testRunner)
39 moveCursorOverAllWords('testLTR'); 39 testRunner.dumpAsTextWithPixelResults();
40 moveCursorOverAllWords('testRTL');
41 moveCursorOverAllWords('testLTREllipses');
42 moveCursorOverAllWords('testRTLEllipses');
43 40
44 }
45 </script> 41 </script>
46 </head>
47 <body onload="startTest()">
48 <p id="explanation">
49 This tests the correct placement of inline spelling and grammar markers in text. <br>
50 Spelling markers should line up exactly under misspelled words in all cases.
51 </p>
52 42
53 LTR 43 LTR
54 <div id="testLTR" class="testDiv" contenteditable="true"> 44 <div id="testLTR" class="testDiv" contenteditable="true">the the adlj adaasj sdk lj. there there</div>
55 the the adlj adaasj sdklj. there there
56 </div>
57 45
58 RTL 46 RTL
59 <div id="testRTL" class="testDiv forcertl" contenteditable="true"> 47 <div id="testRTL" class="testDiv forcertl" contenteditable="true">the the adlj a daasj sdklj. there there</div>
60 the the adlj adaasj sdklj. there there
61 </div>
62
63 48
64 LTR (text-overflow:ellipses): 49 LTR (text-overflow:ellipses):
65 <div id="testLTREllipses" class="testDiv ellipses" contenteditable="true"> 50 <div id="testLTREllipses" class="testDiv ellipses" contenteditable="true">the th e adlj adaasj sdklj. there there</div>
66 the the adlj adaasj sdklj. there there
67 </div>
68 51
69 RTL (text-overflow:ellipses): 52 RTL (text-overflow:ellipses):
70 <div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="tru e"> 53 <div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="tru e">the the adlj adaasj sdklj. there there</div>
71 the the adlj adaasj sdklj. there there
72 </div>
73 54
55 <script>
56
57 function moveCursorOverAllCharacters(id)
58 {
59 if (!window.internals)
60 return;
61
62 div = document.getElementById(id);
63 div.focus();
64
65 debug(id + ":");
66
67 var selection = window.getSelection();
68 // Move to start of text.
69 selection.modify("move", "backward", "line");
70 /* Move cursor over all characters so underline for misspellings is drawn.
71 This is only needed to show misspelling in pixel tests. */
72 for (var i = 0; i < div.innerHTML.length; i++ )
groby-ooo-7-16 2013/10/29 17:19:05 Moving over words should be enough - does the test
grzegorz 2013/10/30 15:47:47 You're right. Moving over the words is enough. I'l
73 selection.modify("move", "forward", "character");
74
75 verifyMarkers();
76 }
77
78 function verifyMarkers()
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, 32, 5)', 'tr ue', function() { // Verifies second 'there'.
90 div.blur();
groby-ooo-7-16 2013/10/29 17:19:05 Is the blur still needed?
grzegorz 2013/10/30 15:47:47 Good point, hasGrammarMarker/hasSpellingMarker fai
91 done();
92 })
93 });
94 }
95 }
96
97 var tests = [ function() { moveCursorOverAllCharacters('testLTR'); },
98 function() { moveCursorOverAllCharacters('testRTL'); },
99 function() { moveCursorOverAllCharacters('testLTREllipses'); },
100 function() { moveCursorOverAllCharacters('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
111 done();
112
113 </script>
114
115 <script src="../../fast/js/resources/js-test-post.js"></script>
74 </body> 116 </body>
75 </html> 117 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698