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

Side by Side Diff: LayoutTests/editing/spelling/grammar-paste.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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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 <script src="resources/js-test-selection-shared.js"></script> 5 <script src="resources/js-test-selection-shared.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 <script> 10 <script>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 var textNode = findFirstTextNode(node); 85 var textNode = findFirstTextNode(node);
86 var num = internals.markerCountForNode(textNode, "grammar"); 86 var num = internals.markerCountForNode(textNode, "grammar");
87 if (num != expectedMarked.length) 87 if (num != expectedMarked.length)
88 return false; 88 return false;
89 for (var i = 0; i < num; ++i) { 89 for (var i = 0; i < num; ++i) {
90 var range = internals.markerRangeForNode(textNode, "grammar", i); 90 var range = internals.markerRangeForNode(textNode, "grammar", i);
91 if (range.toString() != expectedMarked[i]) 91 if (range.toString() != expectedMarked[i])
92 return false; 92 return false;
93 } 93 }
94 94
95 var nodeContent = node instanceof HTMLInputElement || node instanceof HTMLTe xtAreaElement ? node.value : node.innerHTML;
96 testPassed(node.tagName + " ungrammatical phrase '" + expectedMarked + "' on '" + nodeContent + "'");
97
95 return true; 98 return true;
96 } 99 }
97 100
101 var destination = null;
102 var expectedMarked = null;
98 function pasteAndVerify(source, dest, expectedMarked) 103 function pasteAndVerify(source, dest, expectedMarked)
99 { 104 {
100 sel.selectAllChildren(source); 105 sel.selectAllChildren(source);
101 document.execCommand("Copy"); 106 document.execCommand("Copy");
102 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) { 107 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) {
103 dest.value = ""; 108 dest.value = "";
104 dest.focus(); 109 dest.focus();
105 } else { 110 } else {
106 dest.innerHTML = ""; 111 dest.innerHTML = "";
107 sel.selectAllChildren(dest); 112 sel.selectAllChildren(dest);
108 } 113 }
109 document.execCommand("Paste"); 114 document.execCommand("Paste");
110 115
111 var nretry = 10; 116 if (window.internals) {
112 var nsleep = 4; 117 destination = dest;
113 function trial() { 118 ungrammaticalPhrase = expectedMarked;
114 var verified = verifyMarker(dest, expectedMarked); 119 shouldBecomeEqual('verifyMarker(destination, ungrammaticalPhrase)', 'tru e', done);
115 if (verified) { 120 }
116 testPassed(dest.tagName + " has a marker on '" + source.innerHTML + "'");
117 done();
118 return;
119 }
120
121 nretry--;
122 if (0 == nretry) {
123 testFailed(dest.tagName + " should have a marker on for '" + source. innerHTML + "'");
124 done();
125 return;
126 }
127
128 nsleep *= 2;
129 window.setTimeout(trial, nsleep);
130 };
131 trial();
132 }; 121 };
133 122
134 if (window.internals) 123 if (window.internals)
135 internals.settings.setAsynchronousSpellCheckingEnabled(true); 124 internals.settings.setAsynchronousSpellCheckingEnabled(true);
136 125
137 tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, ["has"]); }); 126 tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, ["has"]); });
138 tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, ["a"]) ; }); // Checks only 'a'. 127 tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, ["a"]) ; }); // Checks only 'a'.
139 tests.push(function() { pasteAndVerify(testSourceMulti, testEditable, ["an", "an "]); }); 128 tests.push(function() { pasteAndVerify(testSourceMulti, testEditable, ["an", "an "]); });
140 129
141 tests.push(function() { pasteAndVerify(testSourcePlain, testInput, ["has"]); }); 130 tests.push(function() { pasteAndVerify(testSourcePlain, testInput, ["has"]); });
142 tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, ["an"]); }); 131 tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, ["an"]); });
143 tests.push(function() { pasteAndVerify(testSourceMulti, testInput, ["an", "an"]) ; }); 132 tests.push(function() { pasteAndVerify(testSourceMulti, testInput, ["an", "an"]) ; });
144 133
145 tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, ["has"]); }); 134 tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, ["has"]); });
146 tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, ["an"] ); }); 135 tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, ["an"] ); });
147 tests.push(function() { pasteAndVerify(testSourceMulti, testTextArea, ["an", "an "]); }); 136 tests.push(function() { pasteAndVerify(testSourceMulti, testTextArea, ["an", "an "]); });
148 137
149 done(); 138 done();
150 139
151 var successfullyParsed = true; 140 var successfullyParsed = true;
152 </script> 141 </script>
153 <script src="../../fast/js/resources/js-test-post.js"></script> 142 <script src="../../fast/js/resources/js-test-post.js"></script>
154 </body> 143 </body>
155 </html> 144 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698