OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 NavigationObserver observer(WebContents()); | 169 NavigationObserver observer(WebContents()); |
170 std::string fill_and_submit = | 170 std::string fill_and_submit = |
171 "document.getElementById('username_field').value = 'temp';" | 171 "document.getElementById('username_field').value = 'temp';" |
172 "document.getElementById('password_field').value = 'random';" | 172 "document.getElementById('password_field').value = 'random';" |
173 "document.getElementById('submit_button').click()"; | 173 "document.getElementById('submit_button').click()"; |
174 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 174 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
175 observer.Wait(); | 175 observer.Wait(); |
176 EXPECT_TRUE(observer.infobar_shown()); | 176 EXPECT_TRUE(observer.infobar_shown()); |
177 } | 177 } |
178 | 178 |
179 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, | |
180 PromptForDynamicForm) { | |
181 ASSERT_TRUE(test_server()->Start()); | |
182 | |
183 GURL url = test_server()->GetURL("files/password/dynamic_password_form.html"); | |
184 ui_test_utils::NavigateToURL(browser(), url); | |
Garrett Casto
2013/09/13 18:30:05
Use NavigateToFile() for this or else the test is
guohui
2013/09/13 20:07:57
Done.
| |
185 | |
186 // Fill the dynamic password form and submit. | |
187 NavigationObserver observer(WebContents()); | |
188 std::string fill_and_submit = | |
189 "document.getElementById('create_form_button').click();" | |
190 "window.setTimeout(function() {" | |
Garrett Casto
2013/09/13 18:30:05
Out of curiosity, why do you need to use a setTime
guohui
2013/09/13 20:07:57
yes, because dynamic_form is inserted in click han
| |
191 " document.dynamic_form.username.value = 'temp';" | |
192 " document.dynamic_form.password.value = 'random';" | |
193 " document.dynamic_form.submit();" | |
194 "}, 0)"; | |
195 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | |
196 observer.Wait(); | |
197 EXPECT_TRUE(observer.infobar_shown()); | |
198 } | |
199 | |
179 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { | 200 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { |
180 NavigateToFile("/password/password_form.html"); | 201 NavigateToFile("/password/password_form.html"); |
181 | 202 |
182 // Don't fill the password form, just navigate away. Shouldn't prompt. | 203 // Don't fill the password form, just navigate away. Shouldn't prompt. |
183 NavigationObserver observer(WebContents()); | 204 NavigationObserver observer(WebContents()); |
184 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 205 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
185 "window.location.href = 'done.html';")); | 206 "window.location.href = 'done.html';")); |
186 observer.Wait(); | 207 observer.Wait(); |
187 EXPECT_FALSE(observer.infobar_shown()); | 208 EXPECT_FALSE(observer.infobar_shown()); |
188 } | 209 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 // cases where the element that users click on isn't a submit button. | 288 // cases where the element that users click on isn't a submit button. |
268 NavigationObserver observer(WebContents()); | 289 NavigationObserver observer(WebContents()); |
269 std::string fill_and_navigate = | 290 std::string fill_and_navigate = |
270 "document.getElementById('username_field').value = 'temp';" | 291 "document.getElementById('username_field').value = 'temp';" |
271 "document.getElementById('password_field').value = 'random';" | 292 "document.getElementById('password_field').value = 'random';" |
272 "send_xhr()"; | 293 "send_xhr()"; |
273 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 294 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
274 observer.Wait(); | 295 observer.Wait(); |
275 EXPECT_FALSE(observer.infobar_shown()); | 296 EXPECT_FALSE(observer.infobar_shown()); |
276 } | 297 } |
OLD | NEW |