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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: fix range 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/clipboard/DataObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4ba34624fe6361a6489e73c304d67da7f41f0665
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../editing/assert_selection.js"></script>
+
+<script>
+test(function () {
+ assert_not_equals(window.eventSender,
yosin_UTC9 2016/11/16 04:14:45 Please get rid of this statement since this test c
+ undefined,
+ 'This test requires eventSender.');
+ 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");
+
+ const handler = function(event) {
yosin_UTC9 2016/11/16 04:14:45 nit: s/const handler/function handler(event)/
+ assert_equals(event.inputType, "insertReplacementText");
yosin_UTC9 2016/11/16 04:14:45 nit: Please use single-quote since other parts of
+ assert_equals(event.dataTransfer.getData("text/plain"), "apple");
+ assert_equals(event.getTargetRanges().length, 1);
+ editable.removeEventListener('beforeinput', handler);
yosin_UTC9 2016/11/16 04:14:45 Q: Do we really need to remove event listener?
+ };
+ editable.addEventListener('beforeinput', handler);
+
+ internals.replaceMisspelled(document, 'apple');
+ },
+ '<div contenteditable id="editable">apple| </div>'
+ );
+}, "spellcheck-replace-in-contenteditable");
+
+test(function () {
+ assert_not_equals(window.eventSender,
yosin_UTC9 2016/11/16 04:14:46 Please get rid of this statement since this test c
+ undefined,
+ 'This test requires eventSender.');
+ 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");
+
+ const shadowRoot = internals.shadowRoot(textarea);
+ const selection1 = shadowRoot.getSelection();
+ const range = selection1.getRangeAt(0);
+ internals.setMarker(document, range, 'Spelling');
+
+ const handler = function(event) {
yosin_UTC9 2016/11/16 04:14:45 nit: s/const handler/function handler(event)/
+ assert_equals(event.inputType, "insertReplacementText");
+ assert_equals(event.data, "apple");
+ assert_equals(event.getTargetRanges().length, 0);
+ textarea.removeEventListener('beforeinput', handler);
yosin_UTC9 2016/11/16 04:14:46 Q: Do we really need to remove event listener?
+ };
+ textarea.addEventListener('beforeinput', handler);
+
+ internals.replaceMisspelled(document, 'apple');
+ },
+ '<textarea id="ta">apple| </textarea>'
+ );
+}, "spellcheck-replace-in-textarea");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/clipboard/DataObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698