Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: third_party/WebKit/LayoutTests/editing/spelling/context_click_on_selected_misspelling.html

Issue 2459553002: Convert editing/spelling/spelling-*-selection.html with spellcheck_test (Closed)
Patch Set: Also convert spelling-{subword,multiword}-selection.html Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/spelling-multiword-selection.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 const x = document.offsetLeft + rect.left + rect.width / 2; 25 const x = document.offsetLeft + rect.left + rect.width / 2;
26 const y = document.offsetTop + rect.top + rect.height / 2; 26 const y = document.offsetTop + rect.top + rect.height / 2;
27 eventSender.mouseMoveTo(x, y); 27 eventSender.mouseMoveTo(x, y);
28 const contextMenuElements = eventSender.contextClick(); 28 const contextMenuElements = eventSender.contextClick();
29 // Esc key to hide the context menu. 29 // Esc key to hide the context menu.
30 eventSender.keyDown('Escape', null); 30 eventSender.keyDown('Escape', null);
31 return contextMenuElements; 31 return contextMenuElements;
32 } 32 }
33 33
34 function assertContextMenuSuggestion(sample, expected) { 34 function assertContextMenuSuggestion(sample, expected) {
35 var title = `Context clicking on selected "${sample.selection.toString()}" ` +
36 (expected ? `gives suggestion "${expected}".` : 'does not give a ny suggestion.');
35 test(() => { 37 test(() => {
36 const suggestions = contextClickOnSelection(sample.selection); 38 const suggestions = contextClickOnSelection(sample.selection);
37 assert_equals(suggestions[suggestions.length - 1], expected); 39 assert_equals(suggestions[suggestions.length - 1], expected || '<separator>' );
38 }, `Context clicking on exactly-selected "${sample.selection.toString()}" give s suggestions "${expected}".`); 40 }, title);
39 sample.remove(); 41 sample.remove();
40 42
41 if (++testHolder.finishedCount == 2) 43 if (++testHolder.finishedCount == 7)
42 testHolder.done(); 44 testHolder.done();
43 } 45 }
44 46
45 spellcheck_test( 47 spellcheck_test(
46 '<div contenteditable>^wellcome| home.</div>', 48 '<div contenteditable>^wellcome| home.</div>',
47 '', 49 '',
48 '<div contenteditable>#wellcome# home.</div>', 50 '<div contenteditable>#wellcome# home.</div>',
49 { 51 {
50 title: 'Has marker on initial misspelling.', 52 title: 'Has marker on initial misspelling in "wellcome home.".',
51 callback: sample => assertContextMenuSuggestion(sample, 'welcome') 53 callback: sample => assertContextMenuSuggestion(sample, 'welcome')
52 }); 54 });
53 55
54 spellcheck_test( 56 spellcheck_test(
55 '<div contenteditable>It should be ^upper case|.</div>', 57 '<div contenteditable>It should be ^upper case|.</div>',
56 '', 58 '',
57 '<div contenteditable>It should be #upper case#.</div>', 59 '<div contenteditable>It should be #upper case#.</div>',
58 { 60 {
59 title: 'Has marker on initial multi-word misspelling.', 61 title: 'Has marker on initial multi-word misspelling in "It should be uppe r case.".',
60 callback: sample => assertContextMenuSuggestion(sample, 'uppercase') 62 callback: sample => assertContextMenuSuggestion(sample, 'uppercase')
61 }); 63 });
64
65 spellcheck_test(
66 '<div contenteditable>hello,^ wellcome |home.</div>',
67 '',
68 '<div contenteditable>hello, #wellcome# home.</div>',
69 {
70 title: 'Has marker on initial misspelling in "hello, wellcome home.".',
71 callback: sample => assertContextMenuSuggestion(sample, 'welcome')
72 });
73
74 spellcheck_test(
75 '<div contenteditable>Hi, ^_wellcome_| home.</div>',
76 '',
77 '<div contenteditable>Hi, _#wellcome#_ home.</div>',
78 {
79 title: 'Has marker on initial misspelling in "Hi, wellcome home.".',
80 callback: sample => assertContextMenuSuggestion(sample, 'welcome')
81 });
82
83 spellcheck_test(
84 '<div contenteditable>^wellcome!|</div>',
85 '',
86 '<div contenteditable>#wellcome#!</div>',
87 {
88 title: 'Has marker on initial misspelling in "wellcome!".',
89 callback: sample => assertContextMenuSuggestion(sample, 'welcome')
90 });
91
92 spellcheck_test(
93 '<div contenteditable>we^llco|me home.</div>',
94 '',
95 '<div contenteditable>#wellcome# home.</div>',
96 {
97 title: 'Has marker on initial misspelling in "wellcome home." with "llco" selected.',
98 callback: sample => assertContextMenuSuggestion(sample)
99 });
100
101 spellcheck_test(
102 '<div contenteditable>^wellcome home|.</div>',
103 '',
104 '<div contenteditable>#wellcome# home.</div>',
105 {
106 title: 'Has marker on initial misspelling in "wellcome home." with "wellco me home" selected.',
107 callback: sample => assertContextMenuSuggestion(sample)
108 });
62 </script> 109 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/spelling-multiword-selection.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698