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

Side by Side Diff: LayoutTests/editing/spelling/spellcheck-async-mutation.html

Issue 21024004: Add/remove spell checking markers in text inputs depending on focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up in the test & the new expected file. Created 7 years, 4 months 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
« no previous file with comments | « LayoutTests/editing/spelling/resources/util.js ('k') | Source/core/editing/Editor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> 4 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
5 <script src="../../fast/js/resources/js-test-pre.js"></script> 5 <script src="../../fast/js/resources/js-test-pre.js"></script>
6 <script src="../editing.js"></script> 6 <script src="../editing.js"></script>
7 <script src="resources/util.js"></script>
7 <style> 8 <style>
8 .editing { 9 .editing {
9 border: 2px solid red; 10 border: 2px solid red;
10 padding: 6px; 11 padding: 6px;
11 font-size: 18px; 12 font-size: 18px;
12 } 13 }
13 </style> 14 </style>
14 </head> 15 </head>
15 <body> 16 <body>
16 <pre id="description"></pre> 17 <pre id="description"></pre>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 174
174 if (verifyExistenceOfMarkers(destination, tweakKind)) { 175 if (verifyExistenceOfMarkers(destination, tweakKind)) {
175 testPassed('Request has been processed.'); 176 testPassed('Request has been processed.');
176 } else { 177 } else {
177 testFailed('Request has been processed but we detected unexpected marker location.'); 178 testFailed('Request has been processed but we detected unexpected marker location.');
178 } 179 }
179 180
180 setTimeout(doTestIfAny, 0); 181 setTimeout(doTestIfAny, 0);
181 } 182 }
182 183
183 function findFirstTextNode(node)
184 {
185 function iterToFindFirstTextNode(node)
186 {
187 if (node instanceof Text)
188 return node;
189
190 var childNodes = node.childNodes;
191 for (var i = 0; i < childNodes.length; ++i) {
192 var n = iterToFindFirstTextNode(childNodes[i]);
193 if (n)
194 return n;
195 }
196
197 return null;
198 }
199
200 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)
201 return iterToFindFirstTextNode(internals.shadowRoot(node));
202 else
203 return iterToFindFirstTextNode(node);
204 }
205
206 function verifyExistenceOfMarkers(elem, tweakKind) { 184 function verifyExistenceOfMarkers(elem, tweakKind) {
207 if (!window.internals) 185 if (!window.internals)
208 return true; 186 return true;
209 187
210 switch (tweakKind) { 188 switch (tweakKind) {
211 case 'delete': 189 case 'delete':
212 return true; 190 return true;
213 case 'move': 191 case 'move':
214 // In move, marker should be there. 192 // In move, marker should be there. However since markers are removed wh en unfocusing
193 // an input if it's the input what's moved and it's not focused return t rue right away.
194 if (elem instanceof HTMLInputElement && elem != document.activeElement)
195 return true;
215 var markerNum = internals.markerCountForNode(findFirstTextNode(elem), "s pelling"); 196 var markerNum = internals.markerCountForNode(findFirstTextNode(elem), "s pelling");
216 if (markerNum != 3) 197 if (markerNum != 3)
217 return false; 198 return false;
218 for (var i = 0; i < 3; ++i) { 199 for (var i = 0; i < 3; ++i) {
219 var range = internals.markerRangeForNode(findFirstTextNode(elem), "s pelling", i); 200 var range = internals.markerRangeForNode(findFirstTextNode(elem), "s pelling", i);
220 if (range.toString() != "zz") 201 if (range.toString() != "zz")
221 return false; 202 return false;
222 } 203 }
223 return true; 204 return true;
224 case 'mutate': 205 case 'mutate':
225 // In mutation, there aren't markers. 206 // In mutation, there aren't markers.
226 return internals.markerCountForNode(findFirstTextNode(elem), "spelling") == 0; 207 return internals.markerCountForNode(findFirstTextNode(elem), "spelling") == 0;
227 default: 208 default:
228 testFailed('Unknown kind of tweak'); 209 testFailed('Unknown kind of tweak');
229 return true; 210 return true;
230 } 211 }
231 } 212 }
232 213
233 doTestIfAny(); 214 doTestIfAny();
234 215
235 var successfullyParsed = true; 216 var successfullyParsed = true;
236 </script> 217 </script>
237 <script src="../../fast/js/resources/js-test-post.js"></script> 218 <script src="../../fast/js/resources/js-test-post.js"></script>
238 </body> 219 </body>
239 </html> 220 </html>
OLDNEW
« no previous file with comments | « LayoutTests/editing/spelling/resources/util.js ('k') | Source/core/editing/Editor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698