Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5dcdf7ca941d6d9d85d138477635d0ebc08e9e22 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html |
| @@ -0,0 +1,61 @@ |
| +<!DOCTYPE html> |
| +<script src='../../../resources/testharness.js'></script> |
| +<script src='../../../resources/testharnessreport.js'></script> |
| +<script src='../../../editing/assert_selection.js'></script> |
| + |
| +<script> |
| +test(function () { |
|
yosin_UTC9
2016/11/17 04:06:48
nit: s/function ()/() =>/
|
| + assert_not_equals(window.internals, |
| + undefined, |
| + 'This test requires internals.'); |
| + |
| + assert_selection( |
| + '<div contenteditable id="editable">|appla^ </div>', |
| + selection => { |
| + const document = selection.document; |
| + internals.setMarker(document, selection.getRangeAt(0), 'Spelling'); |
| + const editable = document.getElementById('editable'); |
| + |
| + function handler(event) { |
|
yosin_UTC9
2016/11/17 04:06:47
Since we refer |handler| once, it should be an clo
|
| + assert_equals(event.inputType, 'insertReplacementText'); |
| + assert_equals(event.dataTransfer.getData('text/plain'), 'apple'); |
| + assert_equals(event.getTargetRanges().length, 1); |
| + }; |
|
yosin_UTC9
2016/11/17 04:06:48
nit: no need to have semi-colon(;)
|
| + editable.addEventListener('beforeinput', handler); |
| + |
| + internals.replaceMisspelled(document, 'apple'); |
| + }, |
| + '<div contenteditable id="editable">apple| </div>' |
| + ); |
|
yosin_UTC9
2016/11/17 04:06:48
nit: Should be at end of L28.
|
| +}, 'spellcheck-replace-in-contenteditable'); |
| + |
| +test(function () { |
|
yosin_UTC9
2016/11/17 04:06:47
nit: s/function ()/() =>/
|
| + assert_not_equals(window.internals, |
| + undefined, |
| + 'This test requires internals.'); |
| + |
| + assert_selection( |
| + '<textarea id="ta">^appla| </textarea>', |
| + selection => { |
| + const document = selection.document; |
| + const textarea = document.getElementById('ta'); |
|
yosin_UTC9
2016/11/17 04:06:48
Since there is only one element, how about removin
|
| + |
| + const shadowRoot = internals.shadowRoot(textarea); |
| + const selection1 = shadowRoot.getSelection(); |
| + const range = selection1.getRangeAt(0); |
| + internals.setMarker(document, range, 'Spelling'); |
| + |
| + function handler(event) { |
|
yosin_UTC9
2016/11/17 04:06:47
Since we refer |handler| once, it should be an clo
|
| + assert_equals(event.inputType, 'insertReplacementText'); |
| + assert_equals(event.data, 'apple'); |
| + assert_equals(event.getTargetRanges().length, 0); |
| + }; |
|
yosin_UTC9
2016/11/17 04:06:48
nit: no need to have semi-colon(;)
|
| + textarea.addEventListener('beforeinput', handler); |
| + |
| + internals.replaceMisspelled(document, 'apple'); |
| + }, |
| + '<textarea id="ta">apple| </textarea>' |
| + ); |
|
yosin_UTC9
2016/11/17 04:06:47
nit: Should be at end of L57
|
| +}, 'spellcheck-replace-in-textarea'); |
| + |
|
yosin_UTC9
2016/11/17 04:06:47
nit: Get rid of an extra blank line.
|
| +</script> |