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

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: Use resources/js-test.js and remove js-test-post.js 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="../../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 } 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>
22 24
25 </head>
26 <body>
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 moveCursorOverAllWords('testLTR'); 40 testRunner.dumpAsTextWithPixelResults();
40 moveCursorOverAllWords('testRTL');
41 moveCursorOverAllWords('testLTREllipses');
42 moveCursorOverAllWords('testRTLEllipses');
43 41
44 }
45 </script> 42 </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 43
53 LTR 44 LTR
54 <div id="testLTR" class="testDiv" contenteditable="true"> 45 <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 46
58 RTL 47 RTL
59 <div id="testRTL" class="testDiv forcertl" contenteditable="true"> 48 <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 49
64 LTR (text-overflow:ellipses): 50 LTR (text-overflow:ellipses):
65 <div id="testLTREllipses" class="testDiv ellipses" contenteditable="true"> 51 <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 52
69 RTL (text-overflow:ellipses): 53 RTL (text-overflow:ellipses):
70 <div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="tru e"> 54 <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 55
56 <script>
57 function moveCursorOverAllWords(id)
58 {
59 div = document.getElementById(id);
60 div.focus();
61
62 debug(id + ":");
63 // Move cursor over all words so inline spellchecking is activated for all.
64 for (var i = 0; i < div.innerHTML.length; i++)
65 moveSelectionForwardByWordCommand();
66
67 verifyMarkers();
68 }
69
70 function verifyMarkers()
71 {
72 if (!window.internals)
73 return done();
74
75 // Take care of spelling markers first.
76 shouldBecomeEqual('internals.hasSpellingMarker(document, 8, 4)', 'true', fun ction() { // Verifies 'adlj'.
77 shouldBecomeEqual('internals.hasSpellingMarker(document, 13, 6)', 'true' , function() { // Verifies 'adaasj'.
78 shouldBecomeEqual('internals.hasSpellingMarker(document, 20, 5)', 't rue', verifyGrammarMarkers) // Verifies 'sdklj'.
79 })
80 });
81
82 function verifyGrammarMarkers() {
83 shouldBecomeEqual('internals.hasGrammarMarker(document, 4, 3)', 'true', function() { // Verifies second 'the'.
84 shouldBecomeEqual('internals.hasGrammarMarker(document, 33, 5)', 'tr ue', function() { // Verifies second 'there'.
85 // Markers of next element can not be found after modification s election without blur event.
86 div.blur();
87 done();
88 })
89 });
90 }
91 }
92
93 var tests = [ function() { moveCursorOverAllWords('testLTR'); },
94 function() { moveCursorOverAllWords('testRTL'); },
95 function() { moveCursorOverAllWords('testLTREllipses'); },
96 function() { moveCursorOverAllWords('testRTLEllipses'); } ];
97
98 function done()
99 {
100 var next = tests.shift();
101 if (next)
102 return window.setTimeout(next, 0);
103
104 finishJSTest();
105 }
106 done();
107 </script>
74 </body> 108 </body>
75 </html> 109 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/editing/spelling/inline_spelling_markers-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698