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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: yosin@ comment addressed 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='../../../editing/assert_selection.js'></script>
5
6 <script>
7 test(function () {
yosin_UTC9 2016/11/17 04:06:48 nit: s/function ()/() =>/
8 assert_not_equals(window.internals,
9 undefined,
10 'This test requires internals.');
11
12 assert_selection(
13 '<div contenteditable id="editable">|appla^ </div>',
14 selection => {
15 const document = selection.document;
16 internals.setMarker(document, selection.getRangeAt(0), 'Spelling');
17 const editable = document.getElementById('editable');
18
19 function handler(event) {
yosin_UTC9 2016/11/17 04:06:47 Since we refer |handler| once, it should be an clo
20 assert_equals(event.inputType, 'insertReplacementText');
21 assert_equals(event.dataTransfer.getData('text/plain'), 'apple');
22 assert_equals(event.getTargetRanges().length, 1);
23 };
yosin_UTC9 2016/11/17 04:06:48 nit: no need to have semi-colon(;)
24 editable.addEventListener('beforeinput', handler);
25
26 internals.replaceMisspelled(document, 'apple');
27 },
28 '<div contenteditable id="editable">apple| </div>'
29 );
yosin_UTC9 2016/11/17 04:06:48 nit: Should be at end of L28.
30 }, 'spellcheck-replace-in-contenteditable');
31
32 test(function () {
yosin_UTC9 2016/11/17 04:06:47 nit: s/function ()/() =>/
33 assert_not_equals(window.internals,
34 undefined,
35 'This test requires internals.');
36
37 assert_selection(
38 '<textarea id="ta">^appla| </textarea>',
39 selection => {
40 const document = selection.document;
41 const textarea = document.getElementById('ta');
yosin_UTC9 2016/11/17 04:06:48 Since there is only one element, how about removin
42
43 const shadowRoot = internals.shadowRoot(textarea);
44 const selection1 = shadowRoot.getSelection();
45 const range = selection1.getRangeAt(0);
46 internals.setMarker(document, range, 'Spelling');
47
48 function handler(event) {
yosin_UTC9 2016/11/17 04:06:47 Since we refer |handler| once, it should be an clo
49 assert_equals(event.inputType, 'insertReplacementText');
50 assert_equals(event.data, 'apple');
51 assert_equals(event.getTargetRanges().length, 0);
52 };
yosin_UTC9 2016/11/17 04:06:48 nit: no need to have semi-colon(;)
53 textarea.addEventListener('beforeinput', handler);
54
55 internals.replaceMisspelled(document, 'apple');
56 },
57 '<textarea id="ta">apple| </textarea>'
58 );
yosin_UTC9 2016/11/17 04:06:47 nit: Should be at end of L57
59 }, 'spellcheck-replace-in-textarea');
60
yosin_UTC9 2016/11/17 04:06:47 nit: Get rid of an extra blank line.
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698