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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: fix for nit from Yosi_UTC9, Xiaocheng Created 4 years, 2 months 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..df4b6381692faa07609ea9f44ab96807daef7c39
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-spellcheck.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+
+<div id="editable" contenteditable="true">appla</div>
+<input id="input" type="text" value="oranga"/>
+
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+
+<script>
+function assert_selection(expected) {
yosin_UTC9 2016/11/02 09:14:34 Please use editing/assert_selection.js
+ assert_equals(window.getSelection().toString(), expected);
+}
+
+if (window.internals)
+ internals.setSpellCheckingEnabled(true);
yosin_UTC9 2016/11/02 09:14:34 Move this inside after checking |windows.internals
+
+test(function () {
+ assert_not_equals(window.eventSender,
+ undefined,
+ 'This test requires eventSender.');
+ assert_not_equals(window.internals,
+ undefined,
+ 'This test requires internals.');
+
+ var editable = document.getElementById("editable");
+
+ var handler = function(event) {
+ assert_equals(event.inputType, "insertReplacementText");
+ assert_equals(event.dataTransfer.getData("text/plain"), "apple");
+ assert_equals(event.getTargetRanges().length, 1);
+ editable.removeEventListener('beforeinput', handler);
+ };
+ editable.addEventListener('beforeinput', handler);
+
+ eventSender.mouseMoveTo(editable.offsetLeft+5, editable.offsetTop+5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ assert_selection("appla");
+ internals.setSpellingMarker(document);
+ assert_equals(internals.hasSpellingMarker(
+ document, 0, 5), true);
+ internals.replaceMisspelled(document, "apple");
+ assert_equals(editable.innerText, "apple");
+ assert_equals(window.getSelection().isCollapsed, true);
+ assert_equals(window.getSelection().focusOffset , 5);
+}, "spellcheck-replace-in-contenteditable");
+
+test(function () {
+ assert_not_equals(window.eventSender,
+ undefined,
+ 'This test requires eventSender.');
+ assert_not_equals(window.internals,
+ undefined,
+ 'This test requires internals.');
+
+ var input = document.getElementById("input");
+
+ var handler = function(event) {
+ assert_equals(event.inputType, "insertReplacementText");
+ assert_equals(event.data, "orange");
+ assert_equals(event.getTargetRanges().length, 0);
+ input.removeEventListener('beforeinput', handler);
+ };
+ input.addEventListener('beforeinput', handler);
+
+ eventSender.mouseMoveTo(input.offsetLeft+5, input.offsetTop+5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ assert_selection("oranga");
+ internals.setSpellingMarker(document);
+ internals.replaceMisspelled(document, "orange");
+ assert_equals(input.value, "orange");
+ assert_equals(window.getSelection().isCollapsed, true);
+}, "spellcheck-replace-in-input");
+
+</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