OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <script src="../assert_selection.js"></script> | 4 <script src="../assert_selection.js"></script> |
5 <script src="spellcheck_test.js"></script> | 5 <script src="spellcheck_test.js"></script> |
6 | 6 |
7 <script> | 7 <script> |
8 function pasteToAllChildren(text, container) { | 8 function pasteToAllChildren(text, container) { |
9 const document = container.ownerDocument; | 9 const document = container.ownerDocument; |
10 const selection = document.getSelection(); | 10 const selection = document.getSelection(); |
11 selection.setClipboardData(text); | 11 selection.setClipboardData(text); |
12 container.childNodes.forEach(child => { | 12 container.childNodes.forEach(child => { |
13 if (child.nodeName === 'DIV') { | 13 if (child.nodeName === 'DIV') { |
14 selection.selectAllChildren(child); | 14 selection.selectAllChildren(child); |
15 } else { | 15 } else { |
16 child.value = ''; | 16 child.value = ''; |
17 child.focus(); | 17 child.focus(); |
18 } | 18 } |
19 document.execCommand('paste'); | 19 document.execCommand('paste'); |
20 }); | 20 }); |
21 } | 21 } |
22 | 22 |
23 spellcheck_test( | 23 spellcheck_test( |
24 [ | 24 [ |
25 '<div id="container">', | 25 '<div id="container">', |
26 '<input>', | |
27 '<textarea></textarea>', | 26 '<textarea></textarea>', |
28 '<div contenteditable></div>', | 27 '<div contenteditable></div>', |
29 '<input>', | 28 '<input>', |
30 '<textarea></textarea>', | |
31 '<div contenteditable></div>', | |
32 '<input>', | |
33 '<textarea></textarea>', | |
34 '<div contenteditable></div>', | |
35 '</div>' | 29 '</div>' |
36 ].join(''), | 30 ].join(''), |
37 document => { | 31 document => { |
38 const container = document.getElementById('container'); | 32 const container = document.getElementById('container'); |
39 pasteToAllChildren('foo bar', container); | 33 pasteToAllChildren('foo bar', container); |
40 pasteToAllChildren('zz apple orange', container); | 34 pasteToAllChildren('zz apple orange', container); |
41 }, | 35 }, |
42 [ | 36 [ |
43 '<div id="container">', | 37 '<div id="container">', |
44 '<input value="#zz# apple orange">', | |
45 '<textarea>#zz# apple orange</textarea>', | 38 '<textarea>#zz# apple orange</textarea>', |
46 '<div contenteditable>#zz# apple orange</div>', | 39 '<div contenteditable>#zz# apple orange</div>', |
47 '<input value="#zz# apple orange">', | 40 '<input value="#zz# apple orange">', |
48 '<textarea>#zz# apple orange</textarea>', | |
49 '<div contenteditable>#zz# apple orange</div>', | |
50 '<input value="#zz# apple orange">', | |
51 '<textarea>#zz# apple orange</textarea>', | |
52 '<div contenteditable>#zz# apple orange</div>', | |
53 '</div>' | 41 '</div>' |
54 ].join(''), | 42 ].join(''), |
55 'Spellchecker handles multiple requests.'); | 43 'Spellchecker handles multiple requests.'); |
56 </script> | 44 </script> |
OLD | NEW |