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

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2493703002: Make "compositionend" event fired after setting caret position (Closed)
Patch Set: Not able to listen to selectionchange event 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 | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
index 1d1eaf64d0da2b65835dd646f456a9ec1104c2e7..b258ea96587c53dfb6b0b3d8af6066454fd78d6e 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -843,6 +843,7 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) {
document().settings()->setScriptEnabled(true);
Element* editable = insertHTMLElement(
"<div id='sample' contentEditable='true'></div>", "sample");
+
Element* script = document().createElement("script", ASSERT_NO_EXCEPTION);
script->setInnerHTML(
"document.getElementById('sample').addEventListener('beforeinput', "
@@ -852,6 +853,14 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) {
"document.getElementById('sample').addEventListener('input', "
"function(event) {"
" document.title += `input.data:${event.data};`;"
+ "});"
+ "document.getElementById('sample').addEventListener('compositionend', "
+ "function(event) {"
+ " document.title += `compositionend.data:${event.data};`;"
+ "});"
yabinh 2016/11/10 07:57:41 It seems that selectionchange doesn't work here. (
+ "document.addEventListener('selectionchange', "
+ "function() {"
+ " document.title += 'selectionchange;';"
"});",
ASSERT_NO_EXCEPTION);
document().body()->appendChild(script, ASSERT_NO_EXCEPTION);
@@ -862,19 +871,49 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) {
underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
editable->focus();
+ // Create new composition.
document().setTitle(emptyString());
controller().setComposition("n", underlines, 0, 1);
EXPECT_STREQ("beforeinput.data:n;input.data:n;",
document().title().utf8().data());
+ // Update the existing composition.
+ // TODO(yabinh): should be "beforeinput.data:ni;input.data:ni;".
document().setTitle(emptyString());
- controller().setComposition("ni", underlines, 0, 1);
+ controller().setComposition("ni", underlines, 0, 2);
EXPECT_STREQ("beforeinput.data:i;input.data:i;",
document().title().utf8().data());
+ // Confirm the ongoing composition.
document().setTitle(emptyString());
controller().finishComposingText(InputMethodController::KeepSelection);
- EXPECT_STREQ("beforeinput.data:ni;input.data:ni;",
+ EXPECT_STREQ("beforeinput.data:ni;input.data:ni;compositionend.data:ni;",
+ document().title().utf8().data());
+
+ // Delete the existing composition.
+ document().setTitle(emptyString());
+ controller().setComposition("n", underlines, 0, 1);
+ EXPECT_STREQ("beforeinput.data:n;input.data:n;",
+ document().title().utf8().data());
+ document().setTitle(emptyString());
+ controller().setComposition("", underlines, 0, 0);
+ EXPECT_STREQ("beforeinput.data:;compositionend.data:;",
+ document().title().utf8().data());
+
+ // Insert new text without previous composition.
+ document().setTitle(emptyString());
+ controller().commitText("hello", 0);
+ EXPECT_STREQ("beforeinput.data:hello;input.data:hello;",
+ document().title().utf8().data());
+
+ // Insert new text with previous composition.
+ document().setTitle(emptyString());
+ controller().setComposition("n", underlines, 0, 1);
+ EXPECT_STREQ("beforeinput.data:n;input.data:n;",
+ document().title().utf8().data());
+ document().setTitle(emptyString());
+ controller().commitText("abc", 0);
+ EXPECT_STREQ("beforeinput.data:abc;input.data:abc;compositionend.data:abc;",
document().title().utf8().data());
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698