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

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: 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
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 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.
796 // on the page. Specifically, the test commits given text to a frame which
797 // 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
798 // 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.
799 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
800 ImeCommitTextForAllFrames) {
801 CreateIframePage("a(b,c(a))");
802 std::vector<content::RenderFrameHost*> frames{
803 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
804 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0})};
805 for (size_t i = 0; i < frames.size(); ++i)
806 AddInputFieldToFrame(frames[i], "text", "", true);
807
808 auto focus_input_in_frame = [](content::RenderFrameHost* frame) {
809 EXPECT_TRUE(ExecuteScript(
810 frame, "window.focus(); document.querySelector('input').focus();"));
811 };
812
813 auto get_input_value_from_frame = [](content::RenderFrameHost* frame) {
814 std::string result;
815 EXPECT_TRUE(ExecuteScriptAndExtractString(frame,
816 "window.domAutomationController."
817 "send(document.querySelector('"
818 "input').value);",
819 &result));
820 return result;
821 };
822
823 std::string sample_text[4] = {"main", "child_b", "child_c", "child_a"};
824
825 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 :)
826 // Focus the frame and the <input> inside it.
827 focus_input_in_frame(frames[index]);
828
829 // Commit some text.
830 content::SendImeCommitTextToWidget(
831 frames[index]->GetView()->GetRenderWidgetHost(),
832 base::UTF8ToUTF16(sample_text[index]),
833 std::vector<ui::CompositionUnderline>(), gfx::Range(), 0);
834
835 // Running a NOP js code to make sure the <input> text is updated.
836 EXPECT_TRUE(ExecuteScript(frames[index], "var nop = true;"));
837
838 // Query <input>.value and make sure it matches the text we sent to commit.
839 EXPECT_EQ(sample_text[index], get_input_value_from_frame(frames[index]));
840 }
841 }
842
795 // TODO(ekaramad): Some of the following tests should be active on Android as 843 // 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 844 // well. Enable them when the corresponding feature is implemented for Android
797 // (https://crbug.com/602723). 845 // (https://crbug.com/602723).
798 #if !defined(OS_ANDROID) 846 #if !defined(OS_ANDROID)
799 // This test creates a page with multiple child frames and adds an <input> to 847 // 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. 848 // 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 849 // 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 850 // is pressed (a character) and then the test verifies that TextInputManager
803 // receives the corresponding update on the change in selection bounds on the 851 // receives the corresponding update on the change in selection bounds on the
804 // browser side. 852 // browser side.
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1402
1355 // Closing this WebContents while we still hold on to our TestBrowserClient. 1403 // Closing this WebContents while we still hold on to our TestBrowserClient.
1356 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( 1404 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt(
1357 1, TabStripModel::CLOSE_USER_GESTURE)); 1405 1, TabStripModel::CLOSE_USER_GESTURE));
1358 1406
1359 // For the cleanup of the original WebContents in tab index 0. 1407 // For the cleanup of the original WebContents in tab index 0.
1360 content::SetBrowserClientForTesting(old_browser_client); 1408 content::SetBrowserClientForTesting(old_browser_client);
1361 } 1409 }
1362 #endif // defined(MAC_OSX) 1410 #endif // defined(MAC_OSX)
1363 #endif // !defined(OS_ANDROID) 1411 #endif // !defined(OS_ANDROID)
OLDNEW
« 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