| 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 shows sample usage of spellcheck_test.js | 8 // This file shows sample usage of spellcheck_test.js |
| 9 | 9 |
| 10 spellcheck_test( | 10 spellcheck_test( |
| 11 '<div contenteditable>|</div>', | 11 '<div contenteditable>|</div>', |
| 12 'insertText zz.', | 12 'insertText zz.', |
| 13 '<div contenteditable>_zz_.</div>', | 13 '<div contenteditable>#zz#.</div>', |
| 14 'Mark misspellings after typing.'); | 14 'Mark misspellings after typing.'); |
| 15 | 15 |
| 16 spellcheck_test( | 16 spellcheck_test( |
| 17 '<div contenteditable>|</div>', | 17 '<div contenteditable>|</div>', |
| 18 'insertText You has the right.', | 18 'insertText You has the right.', |
| 19 '<div contenteditable>You ~has~ the right.</div>', | 19 '<div contenteditable>You ~has~ the right.</div>', |
| 20 'Mark ungrammatical phrases after typing.'); | 20 'Mark ungrammatical phrases after typing.'); |
| 21 | 21 |
| 22 spellcheck_test( | 22 spellcheck_test( |
| 23 '<div contenteditable>|</div>', | 23 '<div contenteditable>|</div>', |
| 24 'insertText orange,zz,apple.', | 24 'insertText orange,zz,apple.', |
| 25 // Grammar marker under the whole sentence, and spelling marker under 'zz'. | 25 // Grammar marker under the whole sentence, and spelling marker under 'zz'. |
| 26 '<div contenteditable>~orange,_zz_,apple.~</div>', | 26 '<div contenteditable>~orange,#zz#,apple.~</div>', |
| 27 'Mark overlapping grammer and spelling errors.'); | 27 'Mark overlapping grammer and spelling errors.'); |
| 28 | 28 |
| 29 spellcheck_test( | 29 spellcheck_test( |
| 30 '<textarea>|</textarea>', | 30 '<textarea>|</textarea>', |
| 31 document => { | 31 document => { |
| 32 document.querySelector('textarea').focus(); | 32 document.querySelector('textarea').focus(); |
| 33 document.execCommand('insertText', false, 'zz.'); | 33 document.execCommand('insertText', false, 'zz.'); |
| 34 }, | 34 }, |
| 35 '<textarea>_zz_.</textarea>', | 35 '<textarea>#zz#.</textarea>', |
| 36 'Mark misspellings in <textarea>.'); | 36 'Mark misspellings in <textarea>.'); |
| 37 | 37 |
| 38 spellcheck_test( | 38 spellcheck_test( |
| 39 '<input type="text">|', | 39 '<input type="text">|', |
| 40 document => { | 40 document => { |
| 41 document.querySelector('input').focus(); | 41 document.querySelector('input').focus(); |
| 42 document.execCommand('insertText', false, 'asd.'); | 42 document.execCommand('insertText', false, 'asd.'); |
| 43 }, | 43 }, |
| 44 '<input type="text" value="_asd_.">', | 44 '<input type="text" value="#asd#.">', |
| 45 'Mark misspellings in <input>.'); | 45 'Mark misspellings in <input>.'); |
| 46 | 46 |
| 47 spellcheck_test( | 47 spellcheck_test( |
| 48 '<div contenteditable spellcheck="false">zz.|</div>', | 48 '<div contenteditable spellcheck="false">zz.|</div>', |
| 49 '', | 49 '', |
| 50 '<div contenteditable spellcheck="false">zz.</div>', | 50 '<div contenteditable spellcheck="false">zz.</div>', |
| 51 { | 51 { |
| 52 title: 'No marker on misspelled word when spellcheck=false.', | 52 title: 'No marker on misspelled word when spellcheck=false.', |
| 53 callback: sample => spellcheck_test( | 53 callback: sample => spellcheck_test( |
| 54 sample, | 54 sample, |
| 55 document => { | 55 document => { |
| 56 const div = document.querySelector('div'); | 56 const div = document.querySelector('div'); |
| 57 div.setAttribute('spellcheck', 'true'); | 57 div.setAttribute('spellcheck', 'true'); |
| 58 // Trigger spellchecker by selection change. | 58 // Trigger spellchecker by selection change. |
| 59 document.getSelection().collapse(div, 0); | 59 document.getSelection().collapse(div, 0); |
| 60 }, | 60 }, |
| 61 '<div contenteditable spellcheck="true">_zz_.</div>', | 61 '<div contenteditable spellcheck="true">#zz#.</div>', |
| 62 'Marker appears after setting spellcheck=true.' | 62 'Marker appears after setting spellcheck=true.' |
| 63 ) | 63 ) |
| 64 }); | 64 }); |
| 65 | 65 |
| 66 // TODO(xiaochengh): Design interface for checking marker description. | 66 // TODO(xiaochengh): Design interface for checking marker description. |
| 67 </script> | 67 </script> |
| OLD | NEW |