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

Side by Side Diff: LayoutTests/editing/spelling/spelling-marker-description.html

Issue 23534071: Use shouldBecomeEqual in asynchronous spellchecking tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Apply Tony's review and use asynchronous spellchecking in two tests Created 7 years, 3 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../fast/js/resources/js-test-pre.js"></script> 4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div id="container"> 7 <div id="container">
8 <div id="destination" contentEditable></div> 8 <div id="destination" contentEditable></div>
9 </div> 9 </div>
10 10
11 <script> 11 <script>
12 12
13 function verify(nretry)
14 {
15 if (!nretry) {
16 finishJSTest()
17 return;
18 }
19
20 var texts = destination.childNodes;
21 markedText = null;
22 for (var i = 0; i < texts.length; ++i) {
23 if (internals.markerCountForNode(texts[i], "spelling")) {
24 markedText = internals.markerRangeForNode(texts[i], "spelling", 0).t oString();
25 markerDescription = internals.markerDescriptionForNode(texts[i], "sp elling", 0);
26 break;
27 }
28 }
29
30 if (markedText != null) {
31 shouldBeEqualToString("markedText", "wellcome");
32 shouldBeEqualToString("markerDescription", "welcome");
33 finishJSTest();
34 }
35
36 // Wait until the async spellchecking is done.
37 window.setTimeout(function() { verify(nretry - 1); }, 0);
38 }
39
40 function test() 13 function test()
41 { 14 {
42 jsTestIsAsync = true; 15 jsTestIsAsync = true;
43 internals.settings.setUnifiedTextCheckerEnabled(true); 16 internals.settings.setUnifiedTextCheckerEnabled(true);
44 internals.settings.setAsynchronousSpellCheckingEnabled(true); 17 internals.settings.setAsynchronousSpellCheckingEnabled(true);
45 18
46 var sel = window.getSelection(); 19 var sel = window.getSelection();
47 var destination = document.getElementById("destination"); 20 var destination = document.getElementById("destination");
48 destination.focus(); 21 destination.focus();
49 document.execCommand("InsertHTML", false, "wellcome"); 22 document.execCommand("InsertHTML", false, "wellcome");
50 document.execCommand("InsertText", false, "."); 23 document.execCommand("InsertText", false, ".");
51 24
52 window.setTimeout(function() { verify(10); }, 0); 25 shouldBecomeEqualToString('internals.markerDescriptionForNode(destination.fi rstChild, "spelling", 0)', 'welcome', finishJSTest);
53 } 26 }
54 27
55 description("The spellchecker should store replacement text in each marker."); 28 description("The spellchecker should store replacement text in each marker.");
56 if (window.internals) 29 if (window.internals)
57 test(); 30 test();
58 31
59 </script> 32 </script>
60 <script src="../../fast/js/resources/js-test-post.js"></script> 33 <script src="../../fast/js/resources/js-test-post.js"></script>
61 </body> 34 </body>
62 </html> 35 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698