OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="resources/util.js"></script> |
5 </head> | 7 </head> |
6 <body> | 8 <body> |
7 <div> | 9 <div> |
8 <div id="src" contenteditable="true" spellcheck="true"></div><br/> | 10 <div id="src" contenteditable></div><br/> |
9 <div id="dst" contenteditable="true" spellcheck="false"></div> | 11 <div id="dst" contenteditable spellcheck="false"></div> |
10 </div> | 12 </div> |
11 <script language="javascript"> | 13 <script> |
12 description('Test if WebKit does not spellcheck text when pasting text to an ele
ment having spellchecking disabled. ' + | 14 var srcNode = document.getElementById('src'); |
13 'To test manually, copy the text "zz apple" and paste it to the text
area. ' + | 15 var dstNode = document.getElementById('dst'); |
14 'When "zz" is not marked as misspelled, this test succeeds.'); | |
15 | 16 |
16 jsTestIsAsync = true; | 17 steps = [ |
| 18 // Insert a misspelled word to initialize a spellchecker. |
| 19 // Break the insertion of 'zz apple' into two parts to wait for the spelling |
| 20 // markers under 'zz' to appear. |
| 21 function() { |
| 22 srcNode.focus(); |
| 23 document.execCommand('InsertText', false, 'z'); |
| 24 document.execCommand('InsertText', false, 'z'); |
| 25 document.execCommand('InsertText', false, ' '); |
| 26 }, |
| 27 function() { |
| 28 document.execCommand('InsertText', false, 'a'); |
| 29 document.execCommand('InsertText', false, 'p'); |
| 30 document.execCommand('InsertText', false, 'p'); |
| 31 document.execCommand('InsertText', false, 'l'); |
| 32 document.execCommand('InsertText', false, 'e'); |
| 33 }, |
| 34 function() { |
| 35 window.getSelection().selectAllChildren(srcNode); |
| 36 document.execCommand('Copy'); |
| 37 dstNode.focus(); |
| 38 document.execCommand('Paste'); |
| 39 } |
| 40 ]; |
17 | 41 |
18 // Insert a misspelled word to initialize a spellchecker. | 42 assertions = [ |
19 var srcNode = document.getElementById('src'); | 43 () => {}, |
20 srcNode.focus(); | 44 () => assert_true(internals.hasSpellingMarker(document, 0, 2)), |
21 document.execCommand("InsertText", false, 'z'); | 45 () => assert_false(internals.hasSpellingMarker(document, 0, 2)) |
22 document.execCommand("InsertText", false, 'z'); | 46 ]; |
23 document.execCommand("InsertText", false, ' '); | |
24 document.execCommand("InsertText", false, 'a'); | |
25 document.execCommand("InsertText", false, 'p'); | |
26 document.execCommand("InsertText", false, 'p'); | |
27 document.execCommand("InsertText", false, 'l'); | |
28 document.execCommand("InsertText", false, 'e'); | |
29 shouldBecomeEqual('internals.hasSpellingMarker(document, 0, 2)', 'true', functio
n(){}); | |
30 window.getSelection().selectAllChildren(srcNode); | |
31 document.execCommand('Copy'); | |
32 | 47 |
33 var dstNode = document.getElementById('dst'); | 48 runSpellingTest(steps, assertions, 'Blink does not spellcheck text when pasting
text to an element having spellchecking disabled.') |
34 dstNode.focus(); | |
35 document.execCommand('Paste'); | |
36 shouldBecomeDifferent('internals.hasSpellingMarker(document, 0, 2)', 'true', fin
ishJSTest); | |
37 | |
38 </script> | 49 </script> |
39 </body> | 50 </body> |
40 </html> | 51 </html> |
OLD | NEW |