| 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 test(() => assert_not_equals(window.internals, undefined), | 8 test(() => assert_not_equals(window.internals, undefined), |
| 9 'This test requires internals to set editing behavior.'); | 9 'This test requires internals to set editing behavior.'); |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 function assertContextMenuSuggestion(sample, expected) { | 34 function assertContextMenuSuggestion(sample, expected) { |
| 35 var title = `Context clicking on selected "${sample.selection.toString()}" ` + | 35 var title = `Context clicking on selected "${sample.selection.toString()}" ` + |
| 36 (expected ? `gives suggestion "${expected}".` : 'does not give a
ny suggestion.'); | 36 (expected ? `gives suggestion "${expected}".` : 'does not give a
ny suggestion.'); |
| 37 test(() => { | 37 test(() => { |
| 38 const suggestions = contextClickOnSelection(sample.selection); | 38 const suggestions = contextClickOnSelection(sample.selection); |
| 39 assert_equals(suggestions[suggestions.length - 1], expected || '<separator>'
); | 39 assert_equals(suggestions[suggestions.length - 1], expected || '<separator>'
); |
| 40 }, title); | 40 }, title); |
| 41 sample.remove(); | 41 sample.remove(); |
| 42 | 42 |
| 43 if (++testHolder.finishedCount == 7) | 43 if (++testHolder.finishedCount == 9) |
| 44 testHolder.done(); | 44 testHolder.done(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 function doubleClickAt(node, offset) { |
| 48 const document = node.ownerDocument; |
| 49 const range = document.createRange(); |
| 50 range.setStart(node, offset); |
| 51 const rect = range.getClientRects()[0]; |
| 52 const x = document.offsetLeft + rect.left; |
| 53 const y = document.offsetTop + rect.top + rect.height / 2; |
| 54 eventSender.mouseMoveTo(x, y); |
| 55 eventSender.mouseDown(); |
| 56 eventSender.mouseUp(); |
| 57 eventSender.mouseDown(); |
| 58 eventSender.mouseUp(); |
| 59 } |
| 60 |
| 47 spellcheck_test( | 61 spellcheck_test( |
| 48 '<div contenteditable>^wellcome| home.</div>', | 62 '<div contenteditable>^wellcome| home.</div>', |
| 49 '', | 63 '', |
| 50 '<div contenteditable>#wellcome# home.</div>', | 64 '<div contenteditable>#wellcome# home.</div>', |
| 51 { | 65 { |
| 52 title: 'Has marker on initial misspelling in "wellcome home.".', | 66 title: 'Has marker on initial misspelling in "wellcome home.".', |
| 53 callback: sample => assertContextMenuSuggestion(sample, 'welcome') | 67 callback: sample => assertContextMenuSuggestion(sample, 'welcome') |
| 54 }); | 68 }); |
| 55 | 69 |
| 56 spellcheck_test( | 70 spellcheck_test( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }); | 113 }); |
| 100 | 114 |
| 101 spellcheck_test( | 115 spellcheck_test( |
| 102 '<div contenteditable>^wellcome home|.</div>', | 116 '<div contenteditable>^wellcome home|.</div>', |
| 103 '', | 117 '', |
| 104 '<div contenteditable>#wellcome# home.</div>', | 118 '<div contenteditable>#wellcome# home.</div>', |
| 105 { | 119 { |
| 106 title: 'Has marker on initial misspelling in "wellcome home." with "wellco
me home" selected.', | 120 title: 'Has marker on initial misspelling in "wellcome home." with "wellco
me home" selected.', |
| 107 callback: sample => assertContextMenuSuggestion(sample) | 121 callback: sample => assertContextMenuSuggestion(sample) |
| 108 }); | 122 }); |
| 123 |
| 124 // Note: for the following test cases related to double clicking, the selection |
| 125 // dependends on platform (Win selects a trailing space while other platforms do |
| 126 // not), which, however, do not affect the context menu spelling suggestions. |
| 127 |
| 128 spellcheck_test( |
| 129 '<div contenteditable>wellcome home.</div>', |
| 130 document => { |
| 131 var div = document.querySelector('div'); |
| 132 doubleClickAt(div.firstChild, 4); |
| 133 }, |
| 134 '<div contenteditable>#wellcome# home.</div>', |
| 135 { |
| 136 title: 'Has marker on misspelled word "wellcome" after selecting it with d
ouble-clicking', |
| 137 callback: sample => assertContextMenuSuggestion(sample, 'welcome') |
| 138 }); |
| 139 |
| 140 spellcheck_test( |
| 141 '<div contenteditable>wellcome_ home.</div>', |
| 142 document => { |
| 143 var div = document.querySelector('div'); |
| 144 doubleClickAt(div.firstChild, 4); |
| 145 }, |
| 146 '<div contenteditable>#wellcome#_ home.</div>', |
| 147 { |
| 148 title: 'Has marker on misspelled word "wellcome" after selecting it and it
s trailing underscore with double-clicking', |
| 149 callback: sample => assertContextMenuSuggestion(sample, 'welcome') |
| 150 }); |
| 109 </script> | 151 </script> |
| OLD | NEW |