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

Unified Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 2681473002: Fix a recent regression in IME inside OOPIFs (Closed)
Patch Set: Created 3 years, 10 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: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
diff --git a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
index dc71dce007b1342a5dcc0cff1e41e7e4e749ce3b..3f4b98d67e07b3630facf1427ebcba75311964c2 100644
--- a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
+++ b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
@@ -792,6 +792,54 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
}
}
+// This test verifies that commit text by sending the IPC works for all frames
alexmos 2017/02/08 02:16:23 nit: commit text -> committing text?
EhsanK 2017/02/08 02:35:49 Acknowledged.
+// on the page. Specifically, the test commits given text to a frame which
+// current has focus and a focused <input> and then verifies that the <input>
alexmos 2017/02/08 02:16:23 nit: s/current/currently/
EhsanK 2017/02/08 02:35:49 Acknowledged. I redid this paragraph. Sorry for th
+// value equals to the text to commit.
alexmos 2017/02/08 02:16:23 Might be useful to reference https://crbug.com/688
EhsanK 2017/02/08 02:35:49 Acknowledged.
+IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
+ ImeCommitTextForAllFrames) {
+ CreateIframePage("a(b,c(a))");
+ std::vector<content::RenderFrameHost*> frames{
+ GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
+ GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0})};
+ for (size_t i = 0; i < frames.size(); ++i)
+ AddInputFieldToFrame(frames[i], "text", "", true);
+
+ auto focus_input_in_frame = [](content::RenderFrameHost* frame) {
+ EXPECT_TRUE(ExecuteScript(
+ frame, "window.focus(); document.querySelector('input').focus();"));
+ };
+
+ auto get_input_value_from_frame = [](content::RenderFrameHost* frame) {
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(frame,
+ "window.domAutomationController."
+ "send(document.querySelector('"
+ "input').value);",
+ &result));
+ return result;
+ };
+
+ std::string sample_text[4] = {"main", "child_b", "child_c", "child_a"};
+
+ for (size_t index = 0; index < 1U; ++index) {
alexmos 2017/02/08 02:16:23 Should 1U be frames.size() instead?
EhsanK 2017/02/08 02:35:49 Yes. good catch! left over from testing my test :)
+ // Focus the frame and the <input> inside it.
+ focus_input_in_frame(frames[index]);
+
+ // Commit some text.
+ content::SendImeCommitTextToWidget(
+ frames[index]->GetView()->GetRenderWidgetHost(),
+ base::UTF8ToUTF16(sample_text[index]),
+ std::vector<ui::CompositionUnderline>(), gfx::Range(), 0);
+
+ // Running a NOP js code to make sure the <input> text is updated.
+ EXPECT_TRUE(ExecuteScript(frames[index], "var nop = true;"));
+
+ // Query <input>.value and make sure it matches the text we sent to commit.
+ EXPECT_EQ(sample_text[index], get_input_value_from_frame(frames[index]));
+ }
+}
+
// TODO(ekaramad): Some of the following tests should be active on Android as
// well. Enable them when the corresponding feature is implemented for Android
// (https://crbug.com/602723).
« no previous file with comments | « no previous file | content/public/test/text_input_test_utils.h » ('j') | content/public/test/text_input_test_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698