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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 80583002: [FYI] All-in-one OnCandidateWindow{Show,Update,Hide} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 4ff66839ef6ebbdf92e2a4b128ab4b2fc6b75cfa..2fc654216fee3435815a621476dd053358752638 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -126,11 +126,10 @@ class RenderViewImplTest : public RenderViewTest {
virtual void SetUp() OVERRIDE {
RenderViewTest::SetUp();
- // This test depends on Blink flag InputModeAttribute, which is enabled
- // under only test. Content browser test doesn't enable the feature so we
- // need enable it manually.
- // TODO(yoichio): Remove this if InputMode feature is enabled by default.
- WebRuntimeFeatures::enableInputModeAttribute(true);
+ // Enable Blink's experimental and test only features so that test code
+ // does not have to bother enabling each feature.
+ WebRuntimeFeatures::enableExperimentalFeatures(true);
+ WebRuntimeFeatures::enableTestOnlyFeatures(true);
}
RenderViewImpl* view() {
@@ -2080,4 +2079,42 @@ TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
}
+// Tests if IME API's candidatewindow* events sent from browser are handled
+// in renderer.
+TEST_F(RenderViewImplTest, SendCandidateWindowEvents) {
+ // Sends an HTML with an <input> element and scripts to the renderer.
+ // The script handles all 3 of candidatewindow* events for an
+ // InputMethodContext object and once it received 'show', 'update', 'hide'
+ // should appear in the result div.
+ LoadHTML("<input id='test'>"
+ "<div id='result'>Result: </div>"
+ "<script>"
+ "window.onload = function() {"
+ " var result = document.getElementById('result');"
+ " var test = document.getElementById('test');"
+ " test.focus();"
+ " var context = test.inputMethodContext;"
+ " if (context) {"
+ " context.oncandidatewindowshow = function() {"
+ " result.innerText += 'show'; };"
+ " context.oncandidatewindowupdate = function(){"
+ " result.innerText += 'update'; };"
+ " context.oncandidatewindowhide = function(){"
+ " result.innerText += 'hide'; };"
+ " }"
+ "};"
+ "</script>");
+
+ // Fire candidatewindow events.
+ view()->OnCandidateWindowShow();
+ view()->OnCandidateWindowUpdate();
+ view()->OnCandidateWindowHide();
+
+ // Retrieve the content and check if it is expected.
+ const int kMaxOutputCharacters = 50;
+ std::string output = UTF16ToUTF8(
+ GetMainFrame()->contentAsText(kMaxOutputCharacters));
+ EXPECT_EQ(output, "\nResult:showupdatehide");
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698