Chromium Code Reviews| 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..36173dffdac7706ed41e0eaf65f62c354365a5ed 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,55 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| } |
| } |
| +// This test verifies that committing text works as expected for all the frames |
| +// on the page. Specifically, the test sends an IPC to the RenderWidget |
| +// corresponding to a focused frame with a focused <input> to commit some text. |
| +// Then, it verifies that the <input>'s value matches the committed text |
| +// (https://crbug.com/688842). |
| +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) |
|
sky
2017/02/08 16:36:53
Do you need an assertion that the RenderFrameHosts
EhsanK
2017/02/09 00:50:34
I believe not since it should be inferred from lin
|
| + AddInputFieldToFrame(frames[i], "text", "", true); |
| + |
| + auto focus_input_in_frame = [](content::RenderFrameHost* frame) { |
|
sky
2017/02/08 16:36:53
Why are you using closures here and 814? Closures
EhsanK
2017/02/09 00:50:34
Thanks and Done. I usually use lambdas to avoid re
|
| + 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[4U] = {"main", "child_b", "child_c", "child_a"}; |
| + |
|
sky
2017/02/08 16:36:53
Assert the size of sample_text is the same as fram
EhsanK
2017/02/09 00:50:34
Done.
|
| + for (size_t index = 0; index < frames.size(); ++index) { |
| + // Focus the frame and the <input> inside it. |
| + focus_input_in_frame(frames[index]); |
|
sky
2017/02/08 16:36:53
If this fails, is it really worth continuing? I'm
EhsanK
2017/02/09 00:50:34
Done. We should not continue if any of these scrip
|
| + |
| + // 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. |
|
sky
2017/02/08 16:36:53
How do you know the SendImeCommitTextToWidget is c
EhsanK
2017/02/09 00:50:34
Thanks for pointing this out. Without this line th
|
| + 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). |