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

Side by Side Diff: LayoutTests/editing/spelling/grammar-markers.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="source" contenteditable="true" spellcheck="false">You has the right.</d iv> 7 <div id="source" contenteditable="true" spellcheck="false">You has the right.</d iv>
8 <div id="target" contenteditable="true" spellcheck="true"></div> 8 <div id="target" contenteditable="true" spellcheck="true"></div>
9 9
10 <script> 10 <script>
11 description('This tests whether WebKit can render grammar markers when pasting t ext if it has a grammar-checker. To test manually, copy the text in the first di v element and paste it to the second div element. This test succeeds when WebKit renders a grammar marker under a word "has".'); 11 description('This tests whether WebKit can render grammar markers when pasting t ext if it has a grammar-checker. To test manually, copy the text in the first di v element and paste it to the second div element. This test succeeds when WebKit renders a grammar marker under a word "has".');
12 12
13 jsTestIsAsync = true; 13 jsTestIsAsync = true;
14 14
15 if (window.internals) 15 if (window.internals)
16 internals.settings.setAsynchronousSpellCheckingEnabled(true); 16 internals.settings.setAsynchronousSpellCheckingEnabled(true);
17 17
18 if (window.testRunner) 18 if (window.testRunner)
19 testRunner.dumpAsText(true); 19 testRunner.dumpAsText(true);
20 20
21 function verifyGrammarMarker(destination, ungrammaticalPhrase)
22 {
23 if (window.internals && internals.hasGrammarMarker(document, destination.inn erHTML.indexOf(ungrammaticalPhrase), ungrammaticalPhrase.length)) {
24 testPassed("ungrammatical phrase '" + ungrammaticalPhrase + "' on '" + d estination.innerHTML + "'");
25 return true;
26 } else
27 return false;
28 }
29
21 var source = document.getElementById('source'); 30 var source = document.getElementById('source');
22 window.getSelection().selectAllChildren(source); 31 window.getSelection().selectAllChildren(source);
23 document.execCommand('Copy'); 32 document.execCommand('Copy');
24 var target = document.getElementById('target'); 33 var target = document.getElementById('target');
25 window.getSelection().selectAllChildren(target); 34 window.getSelection().selectAllChildren(target);
26 document.execCommand('Paste'); 35 document.execCommand('Paste');
27 36
28 var retryCount = 10; 37 shouldBecomeEqual('verifyGrammarMarker(target, "has")', 'true', finishJSTest);
29 var sleepPeriod = 1;
30 var ungrammaticalPhrase = 'has';
31 var hasMarker;
32 function verifyMarker() {
33 hasMarker = internals.hasGrammarMarker(document, target.innerHTML.indexOf(un grammaticalPhrase), ungrammaticalPhrase.length);
34 if (!hasMarker && --retryCount > 0) {
35 sleepPeriod *= 2;
36 window.setTimeout(verifyMarker, sleepPeriod);
37 return;
38 }
39
40 shouldBeTrue('hasMarker');
41 finishJSTest();
42 };
43
44 window.setTimeout(verifyMarker, sleepPeriod);
45 38
46 </script> 39 </script>
47 <script src="../../fast/js/resources/js-test-post.js"></script> 40 <script src="../../fast/js/resources/js-test-post.js"></script>
48 </body> 41 </body>
49 </html> 42 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698