OLD | NEW |
---|---|
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; | |
tony
2013/09/20 17:10:24
Nit: Looks like the indent is off by one.
| |
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> |
OLD | NEW |