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

Side by Side Diff: LayoutTests/editing/spelling/grammar-markers-hidpi.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 var retryCount = 10; 18 function verifyGrammarMarker(destination, ungrammaticalPhrase)
19 var sleepPeriod = 1; 19 {
20 var ungrammaticalPhrase = 'has'; 20 if (internals.hasGrammarMarker(document, destination.innerHTML.indexOf(ungra mmaticalPhrase), ungrammaticalPhrase.length)) {
21 var hasMarker; 21 testPassed("ungrammatical phrase '" + ungrammaticalPhrase + "' on '" + d estination.innerHTML + "'");
22 function verifyMarker() { 22 return true;
23 hasMarker = internals.hasGrammarMarker(document, target.innerHTML.indexOf(un grammaticalPhrase), ungrammaticalPhrase.length); 23 } else
24 if (!hasMarker && --retryCount > 0) { 24 return false;
25 sleepPeriod *= 2; 25 }
26 window.setTimeout(verifyMarker, sleepPeriod);
27 return;
28 }
29
30 shouldBeTrue('hasMarker');
31 finishJSTest();
32 };
33 26
34 if (window.testRunner) { 27 if (window.testRunner) {
35 testRunner.dumpAsText(true); 28 testRunner.dumpAsText(true);
36 testRunner.setBackingScaleFactor(2, function () { 29 testRunner.setBackingScaleFactor(2, function () {
37 verifyMarker(); 30 shouldBecomeEqual('verifyGrammarMarker(target, "has")', 'true', finishJS Test);
38 }); 31 });
39 } 32 }
40 33
41 var source = document.getElementById('source'); 34 var source = document.getElementById('source');
42 window.getSelection().selectAllChildren(source); 35 window.getSelection().selectAllChildren(source);
43 document.execCommand('Copy'); 36 document.execCommand('Copy');
44 var target = document.getElementById('target'); 37 var target = document.getElementById('target');
45 window.getSelection().selectAllChildren(target); 38 window.getSelection().selectAllChildren(target);
46 document.execCommand('Paste'); 39 document.execCommand('Paste');
47 40
48 </script> 41 </script>
49 <script src="../../fast/js/resources/js-test-post.js"></script> 42 <script src="../../fast/js/resources/js-test-post.js"></script>
50 </body> 43 </body>
51 </html> 44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698