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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win_browsertest.cc

Issue 11753009: Simplify ExecuteJavaScript* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update prerender_browsertest.cc. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/win/metro.h" 6 #include "base/win/metro.h"
7 #include "content/public/browser/web_contents.h" 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/common/content_switches.h" 8 #include "content/public/common/content_switches.h"
9 #include "content/public/test/test_utils.h" 9 #include "content/public/test/test_utils.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 22 matching lines...) Expand all
33 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 33 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
34 34
35 NavigateToURL(shell(), test_url); 35 NavigateToURL(shell(), test_url);
36 WaitForLoadStop(shell()->web_contents()); 36 WaitForLoadStop(shell()->web_contents());
37 RunAllPendingInMessageLoop(); 37 RunAllPendingInMessageLoop();
38 38
39 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 39 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
40 40
41 // Focus to the text field, the IME should be enabled. 41 // Focus to the text field, the IME should be enabled.
42 bool success = false; 42 bool success = false;
43 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 43 EXPECT_TRUE(ExecuteScriptAndExtractBool(
44 shell()->web_contents()->GetRenderViewHost(), 44 shell()->web_contents(),
45 "",
46 "window.domAutomationController.send(text01_focus());", 45 "window.domAutomationController.send(text01_focus());",
47 &success)); 46 &success));
48 EXPECT_TRUE(success); 47 EXPECT_TRUE(success);
49 WaitForLoadStop(shell()->web_contents()); 48 WaitForLoadStop(shell()->web_contents());
50 RunAllPendingInMessageLoop(); 49 RunAllPendingInMessageLoop();
51 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); 50 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
52 51
53 // Focus to the password field, the IME should be disabled. 52 // Focus to the password field, the IME should be disabled.
54 success = false; 53 success = false;
55 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 54 EXPECT_TRUE(ExecuteScriptAndExtractBool(
56 shell()->web_contents()->GetRenderViewHost(), 55 shell()->web_contents(),
57 "",
58 "window.domAutomationController.send(password02_focus());", 56 "window.domAutomationController.send(password02_focus());",
59 &success)); 57 &success));
60 EXPECT_TRUE(success); 58 EXPECT_TRUE(success);
61 WaitForLoadStop(shell()->web_contents()); 59 WaitForLoadStop(shell()->web_contents());
62 RunAllPendingInMessageLoop(); 60 RunAllPendingInMessageLoop();
63 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); 61 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
64 62
65 ui::TSFBridge::ReplaceForTesting(old_bridge); 63 ui::TSFBridge::ReplaceForTesting(old_bridge);
66 } 64 }
67 65
68 // crbug.com/151798 66 // crbug.com/151798
69 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, 67 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest,
70 DISABLED_SwitchToSameField) { 68 DISABLED_SwitchToSameField) {
71 ui::MockTSFBridge mock_bridge; 69 ui::MockTSFBridge mock_bridge;
72 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); 70 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
73 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 71 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
74 72
75 NavigateToURL(shell(), test_url); 73 NavigateToURL(shell(), test_url);
76 WaitForLoadStop(shell()->web_contents()); 74 WaitForLoadStop(shell()->web_contents());
77 RunAllPendingInMessageLoop(); 75 RunAllPendingInMessageLoop();
78 76
79 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 77 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
80 78
81 // Focus to the text field, the IME should be enabled. 79 // Focus to the text field, the IME should be enabled.
82 bool success = false; 80 bool success = false;
83 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 81 EXPECT_TRUE(ExecuteScriptAndExtractBool(
84 shell()->web_contents()->GetRenderViewHost(), 82 shell()->web_contents(),
85 "",
86 "window.domAutomationController.send(text01_focus());", 83 "window.domAutomationController.send(text01_focus());",
87 &success)); 84 &success));
88 EXPECT_TRUE(success); 85 EXPECT_TRUE(success);
89 WaitForLoadStop(shell()->web_contents()); 86 WaitForLoadStop(shell()->web_contents());
90 RunAllPendingInMessageLoop(); 87 RunAllPendingInMessageLoop();
91 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); 88 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
92 89
93 // Focus to another text field, the IME should be enabled. 90 // Focus to another text field, the IME should be enabled.
94 success = false; 91 success = false;
95 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 92 EXPECT_TRUE(ExecuteScriptAndExtractBool(
96 shell()->web_contents()->GetRenderViewHost(), 93 shell()->web_contents(),
97 "",
98 "window.domAutomationController.send(text02_focus());", 94 "window.domAutomationController.send(text02_focus());",
99 &success)); 95 &success));
100 EXPECT_TRUE(success); 96 EXPECT_TRUE(success);
101 WaitForLoadStop(shell()->web_contents()); 97 WaitForLoadStop(shell()->web_contents());
102 RunAllPendingInMessageLoop(); 98 RunAllPendingInMessageLoop();
103 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); 99 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
104 100
105 ui::TSFBridge::ReplaceForTesting(old_bridge); 101 ui::TSFBridge::ReplaceForTesting(old_bridge);
106 } 102 }
107 103
108 // crbug.com/151798 104 // crbug.com/151798
109 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, 105 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest,
110 DISABLED_SwitchToSamePasswordField) { 106 DISABLED_SwitchToSamePasswordField) {
111 ui::MockTSFBridge mock_bridge; 107 ui::MockTSFBridge mock_bridge;
112 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); 108 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
113 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 109 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
114 110
115 NavigateToURL(shell(), test_url); 111 NavigateToURL(shell(), test_url);
116 WaitForLoadStop(shell()->web_contents()); 112 WaitForLoadStop(shell()->web_contents());
117 RunAllPendingInMessageLoop(); 113 RunAllPendingInMessageLoop();
118 114
119 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 115 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
120 116
121 // Focus to the password field, the IME should be disabled. 117 // Focus to the password field, the IME should be disabled.
122 bool success = false; 118 bool success = false;
123 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 119 EXPECT_TRUE(ExecuteScriptAndExtractBool(
124 shell()->web_contents()->GetRenderViewHost(), 120 shell()->web_contents(),
125 "",
126 "window.domAutomationController.send(password01_focus());", 121 "window.domAutomationController.send(password01_focus());",
127 &success)); 122 &success));
128 EXPECT_TRUE(success); 123 EXPECT_TRUE(success);
129 WaitForLoadStop(shell()->web_contents()); 124 WaitForLoadStop(shell()->web_contents());
130 RunAllPendingInMessageLoop(); 125 RunAllPendingInMessageLoop();
131 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); 126 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
132 127
133 // Focus to the another password field, the IME should be disabled. 128 // Focus to the another password field, the IME should be disabled.
134 success = false; 129 success = false;
135 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( 130 EXPECT_TRUE(ExecuteScriptAndExtractBool(
136 shell()->web_contents()->GetRenderViewHost(), 131 shell()->web_contents(),
137 "",
138 "window.domAutomationController.send(password02_focus());", 132 "window.domAutomationController.send(password02_focus());",
139 &success)); 133 &success));
140 EXPECT_TRUE(success); 134 EXPECT_TRUE(success);
141 WaitForLoadStop(shell()->web_contents()); 135 WaitForLoadStop(shell()->web_contents());
142 RunAllPendingInMessageLoop(); 136 RunAllPendingInMessageLoop();
143 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); 137 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
144 138
145 ui::TSFBridge::ReplaceForTesting(old_bridge); 139 ui::TSFBridge::ReplaceForTesting(old_bridge);
146 } 140 }
147 141
148 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_manager_browsertest.cc ('k') | content/browser/session_history_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698