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

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

Issue 2456473002: Convert input-type-text.html with spellcheck_test (Closed)
Patch Set: Rename and remove expected text 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../assert_selection.js"></script>
5 <script src="spellcheck_test.js"></script>
6
7 <script>
8 test(() => assert_not_equals(window.internals, undefined),
9 'This test requires internals to set editing behavior.');
10
11 test(() => assert_not_equals(window.eventSender, undefined),
12 'This test requires event sender to simulate keyboard and mouse actions.');
13
14 function assertContextClickSelection(input, offsetX, expected) {
15 const document = input.ownerDocument;
16 const x = document.offsetLeft + input.offsetLeft + offsetX;
17 const y = document.offsetTop + input.offsetTop + input.offsetHeight / 2;
18 eventSender.mouseMoveTo(x, y);
19 eventSender.contextClick();
20
21 // Esc key to hide the context menu.
22 eventSender.keyDown('Escape', null);
23
24 assert_equals(document.getSelection().toString(), expected);
25 }
26
27 function contextClickSelectionTests(input) {
28 // There seems to be some bug with testharness.js that, if the first test
29 // completes before the next two tests start, the whole testharness is
30 // considered as ran to complete and the next two tests are not evaluated.
31 // Hence, we use async_test and defer the completion as a workaround.
32 const platformIndependentTest = async_test(
33 () => assertContextClickSelection(input, 40, 'wellcome'),
yosin_UTC9 2016/10/27 01:44:46 We should avoid a magic number for coordinate, |in
34 'Context clicking "wellcome" selects the misspelled word');
35
36 ['Win', 'Unix', 'Android', 'Mac'].forEach(platform => {
37 internals.settings.setEditingBehavior(platform);
38 const shouldSelect = platform === 'Mac';
39 test(() => assertContextClickSelection(input, 80,
40 shouldSelect ? 'home' : ''),
41 'Context clicking "home" ' +
42 `${shouldSelect ? 'selects' : 'does not select'} ` +
43 `the correctly spelled word on ${platform}`);
44 })
45
46 platformIndependentTest.done();
47 }
48
49 spellcheck_test(
50 '<input type="text" value="wellcome home.">',
51 document => document.querySelector('input').focus(),
52 '<input type="text" value="_wellcome_ home.">',
53 {
54 title: 'Mark misspelling in the initial text of an input field.',
55 callback: sample => contextClickSelectionTests(
56 sample.document.querySelector('input'))
57 });
58 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698