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

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

Issue 2117543003: [InputEvent] Fill |data| field for 'input' event InsertText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed |dataFromCommand()| helper function Created 4 years, 5 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
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 29a7b6b8a670aca9a87eee86260d11f1b46411bc..08dfe815b970f8a0188b5dafef4a55893c77c6b2 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -349,7 +349,7 @@ TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentN
EXPECT_EQ(24u, controller().getSelectionOffsets().end());
}
-TEST_F(InputMethodControllerTest, CompositionFireBeforeInput)
+TEST_F(InputMethodControllerTest, CompositionInputEventIsComposing)
{
document().settings()->setScriptEnabled(true);
Element* editable = insertHTMLElement("<div id='sample' contentEditable='true'></div>", "sample");
@@ -376,8 +376,42 @@ TEST_F(InputMethodControllerTest, CompositionFireBeforeInput)
document().setTitle(emptyString());
controller().confirmComposition();
- // Last 'beforeinput' should also be inside composition scope.
+ // Last pair of InputEvent should also be inside composition scope.
EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", document().title().utf8().data());
}
+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', function(event) {"
+ " document.title = `beforeinput.data:${event.data};`;"
+ "});"
+ "document.getElementById('sample').addEventListener('input', function(event) {"
+ " document.title += `input.data:${event.data};`;"
+ "});",
+ ASSERT_NO_EXCEPTION);
+ document().body()->appendChild(script, ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ // Simulate composition in the |contentEditable|.
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
+ editable->focus();
+
+ 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("ni", underlines, 0, 1);
+ EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8().data());
+
+ document().setTitle(emptyString());
+ controller().confirmComposition();
+ EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8().data());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/editing/commands/EditCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698