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 // This file tests the functionality of spellcheck_test.js | 8 // This file shows sample usage of spellcheck_test.js |
9 | |
10 test( | |
11 () => spellingMarker(0, 1, 'description').assertValid(), | |
12 'spellingMarker returns valid Marker.'); | |
13 | |
14 test( | |
15 () => grammarMarker(0, 1, 'description').assertValid(), | |
16 'grammarMarker returns valid Marker.'); | |
17 | 9 |
18 spellcheck_test( | 10 spellcheck_test( |
19 '<div contentEditable>|</div>', | 11 '<div contenteditable>|</div>', |
20 'insertText wellcome.', | 12 'insertText zz.', |
21 spellingMarker(0, 8, 'welcome'), // 'wellcome' | 13 '<div contenteditable>_zz_.</div>', |
22 'Mark misspellings and give replacement suggestions after typing.'); | 14 'Mark misspellings after typing.'); |
23 | 15 |
24 spellcheck_test( | 16 spellcheck_test( |
25 '<div contentEditable>|</div>', | 17 '<div contenteditable>|</div>', |
26 'insertText zz zz.', | 18 'insertText You has the right.', |
27 [spellingMarker(0, 2), spellingMarker(3, 2)], // Both 'zz's | 19 '<div contenteditable>You ~has~ the right.</div>', |
28 'Mark multiple misspellings after typing.'); | 20 'Mark ungrammatical phrases after typing.'); |
29 | 21 |
30 spellcheck_test( | 22 spellcheck_test( |
31 '<div contentEditable>|</div>', | 23 '<div contenteditable>|</div>', |
32 'insertText You has the right.', | 24 'insertText orange,zz,apple.', |
33 grammarMarker(4, 3), // 'has' | 25 // Grammar marker under the whole sentence, and spelling marker under 'zz'. |
34 'Mark ungrammatical phrases after typing.'); | 26 '<div contenteditable>~orange,_zz_,apple.~</div>', |
| 27 'Mark overlapping grammer and spelling errors.'); |
| 28 |
| 29 spellcheck_test( |
| 30 '<textarea>|</textarea>', |
| 31 document => { |
| 32 document.querySelector('textarea').focus(); |
| 33 document.execCommand('insertText', false, 'zz.'); |
| 34 }, |
| 35 '<textarea>_zz_.</textarea>', |
| 36 'Mark misspellings in <textarea>.'); |
| 37 |
| 38 spellcheck_test( |
| 39 '<input type="text">|', |
| 40 document => { |
| 41 document.querySelector('input').focus(); |
| 42 document.execCommand('insertText', false, 'asd.'); |
| 43 }, |
| 44 '<input type="text" value="_asd_.">', |
| 45 'Mark misspellings in <input>.'); |
| 46 |
| 47 // TODO(xiaochengh): Design interface for checking marker description. |
35 </script> | 48 </script> |
OLD | NEW |