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

Side by Side 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: Fixed a comment 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/public/test/text_input_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_content_browser_client.h" 9 #include "chrome/browser/chrome_content_browser_client.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 for (size_t i = 0; i < views.size(); ++i) { 785 for (size_t i = 0; i < views.size(); ++i) {
786 // First focus the <input>. 786 // First focus the <input>.
787 send_tab_and_wait_for_value(values[i]); 787 send_tab_and_wait_for_value(values[i]);
788 788
789 // Send a sequence of |count| 'E' keys and wait until the view receives a 789 // Send a sequence of |count| 'E' keys and wait until the view receives a
790 // selection change update for a text of the corresponding size, |count|. 790 // selection change update for a text of the corresponding size, |count|.
791 send_keys_select_all_wait_for_selection_change(views[i], count++); 791 send_keys_select_all_wait_for_selection_change(views[i], count++);
792 } 792 }
793 } 793 }
794 794
795 // This test verifies that committing text works as expected for all the frames
796 // on the page. Specifically, the test sends an IPC to the RenderWidget
797 // corresponding to a focused frame with a focused <input> to commit some text.
798 // Then, it verifies that the <input>'s value matches the committed text
799 // (https://crbug.com/688842).
800 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
801 ImeCommitTextForAllFrames) {
802 CreateIframePage("a(b,c(a))");
803 std::vector<content::RenderFrameHost*> frames{
804 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
805 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0})};
806 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
807 AddInputFieldToFrame(frames[i], "text", "", true);
808
809 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
810 EXPECT_TRUE(ExecuteScript(
811 frame, "window.focus(); document.querySelector('input').focus();"));
812 };
813
814 auto get_input_value_from_frame = [](content::RenderFrameHost* frame) {
815 std::string result;
816 EXPECT_TRUE(ExecuteScriptAndExtractString(frame,
817 "window.domAutomationController."
818 "send(document.querySelector('"
819 "input').value);",
820 &result));
821 return result;
822 };
823
824 std::string sample_text[4U] = {"main", "child_b", "child_c", "child_a"};
825
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.
826 for (size_t index = 0; index < frames.size(); ++index) {
827 // Focus the frame and the <input> inside it.
828 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
829
830 // Commit some text.
831 content::SendImeCommitTextToWidget(
832 frames[index]->GetView()->GetRenderWidgetHost(),
833 base::UTF8ToUTF16(sample_text[index]),
834 std::vector<ui::CompositionUnderline>(), gfx::Range(), 0);
835
836 // 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
837 EXPECT_TRUE(ExecuteScript(frames[index], "var nop = true;"));
838
839 // Query <input>.value and make sure it matches the text we sent to commit.
840 EXPECT_EQ(sample_text[index], get_input_value_from_frame(frames[index]));
841 }
842 }
843
795 // TODO(ekaramad): Some of the following tests should be active on Android as 844 // TODO(ekaramad): Some of the following tests should be active on Android as
796 // well. Enable them when the corresponding feature is implemented for Android 845 // well. Enable them when the corresponding feature is implemented for Android
797 // (https://crbug.com/602723). 846 // (https://crbug.com/602723).
798 #if !defined(OS_ANDROID) 847 #if !defined(OS_ANDROID)
799 // This test creates a page with multiple child frames and adds an <input> to 848 // This test creates a page with multiple child frames and adds an <input> to
800 // each frame. Then, sequentially, each <input> is focused by sending a tab key. 849 // each frame. Then, sequentially, each <input> is focused by sending a tab key.
801 // Then, after |TextInputState.type| for a view is changed to text, another key 850 // Then, after |TextInputState.type| for a view is changed to text, another key
802 // is pressed (a character) and then the test verifies that TextInputManager 851 // is pressed (a character) and then the test verifies that TextInputManager
803 // receives the corresponding update on the change in selection bounds on the 852 // receives the corresponding update on the change in selection bounds on the
804 // browser side. 853 // browser side.
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1403
1355 // Closing this WebContents while we still hold on to our TestBrowserClient. 1404 // Closing this WebContents while we still hold on to our TestBrowserClient.
1356 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( 1405 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt(
1357 1, TabStripModel::CLOSE_USER_GESTURE)); 1406 1, TabStripModel::CLOSE_USER_GESTURE));
1358 1407
1359 // For the cleanup of the original WebContents in tab index 0. 1408 // For the cleanup of the original WebContents in tab index 0.
1360 content::SetBrowserClientForTesting(old_browser_client); 1409 content::SetBrowserClientForTesting(old_browser_client);
1361 } 1410 }
1362 #endif // defined(MAC_OSX) 1411 #endif // defined(MAC_OSX)
1363 #endif // !defined(OS_ANDROID) 1412 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | content/public/test/text_input_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698