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

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 322093003: Password bubble: The bots should run the bubble code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests. Created 6 years, 6 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
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
13 #include "chrome/browser/password_manager/password_store_factory.h" 14 #include "chrome/browser/password_manager/password_store_factory.h"
14 #include "chrome/browser/password_manager/test_password_store_service.h" 15 #include "chrome/browser/password_manager/test_password_store_service.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
18 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/test_switches.h" 21 #include "chrome/test/base/test_switches.h"
20 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/autofill/core/browser/autofill_test_utils.h" 23 #include "components/autofill/core/browser/autofill_test_utils.h"
22 #include "components/infobars/core/confirm_infobar_delegate.h" 24 #include "components/infobars/core/confirm_infobar_delegate.h"
23 #include "components/infobars/core/infobar.h" 25 #include "components/infobars/core/infobar.h"
24 #include "components/infobars/core/infobar_manager.h" 26 #include "components/infobars/core/infobar_manager.h"
25 #include "components/password_manager/core/browser/test_password_store.h" 27 #include "components/password_manager/core/browser/test_password_store.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 152
151 protected: 153 protected:
152 content::WebContents* WebContents() { 154 content::WebContents* WebContents() {
153 return browser()->tab_strip_model()->GetActiveWebContents(); 155 return browser()->tab_strip_model()->GetActiveWebContents();
154 } 156 }
155 157
156 content::RenderViewHost* RenderViewHost() { 158 content::RenderViewHost* RenderViewHost() {
157 return WebContents()->GetRenderViewHost(); 159 return WebContents()->GetRenderViewHost();
158 } 160 }
159 161
162 ManagePasswordsUIController* controller() {
163 return ManagePasswordsUIController::FromWebContents(WebContents());
164 }
165
160 // Wrapper around ui_test_utils::NavigateToURL that waits until 166 // Wrapper around ui_test_utils::NavigateToURL that waits until
161 // DidFinishLoad() fires. Normally this function returns after 167 // DidFinishLoad() fires. Normally this function returns after
162 // DidStopLoading(), which caused flakiness as the NavigationObserver 168 // DidStopLoading(), which caused flakiness as the NavigationObserver
163 // would sometimes see the DidFinishLoad event from a previous navigation and 169 // would sometimes see the DidFinishLoad event from a previous navigation and
164 // return immediately. 170 // return immediately.
165 void NavigateToFile(const std::string& path) { 171 void NavigateToFile(const std::string& path) {
166 if (!embedded_test_server()->Started()) 172 if (!embedded_test_server()->Started())
167 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 173 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
168 174
169 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( 175 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 266
261 // Fill a form and submit through a <input type="submit"> button. Nothing 267 // Fill a form and submit through a <input type="submit"> button. Nothing
262 // special. 268 // special.
263 NavigationObserver observer(WebContents()); 269 NavigationObserver observer(WebContents());
264 std::string fill_and_submit = 270 std::string fill_and_submit =
265 "document.getElementById('username_field').value = 'temp';" 271 "document.getElementById('username_field').value = 'temp';"
266 "document.getElementById('password_field').value = 'random';" 272 "document.getElementById('password_field').value = 'random';"
267 "document.getElementById('input_submit_button').click()"; 273 "document.getElementById('input_submit_button').click()";
268 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 274 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
269 observer.Wait(); 275 observer.Wait();
270 EXPECT_TRUE(observer.infobar_shown()); 276 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
277 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
278 } else {
279 EXPECT_TRUE(observer.infobar_shown());
280 }
271 } 281 }
272 282
273 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 283 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
274 PromptForSubmitWithInPageNavigation) { 284 PromptForSubmitWithInPageNavigation) {
275 NavigateToFile("/password/password_navigate_before_submit.html"); 285 NavigateToFile("/password/password_navigate_before_submit.html");
276 286
277 // Fill a form and submit through a <input type="submit"> button. Nothing 287 // Fill a form and submit through a <input type="submit"> button. Nothing
278 // special. The form does an in-page navigation before submitting. 288 // special. The form does an in-page navigation before submitting.
279 NavigationObserver observer(WebContents()); 289 NavigationObserver observer(WebContents());
280 std::string fill_and_submit = 290 std::string fill_and_submit =
281 "document.getElementById('username_field').value = 'temp';" 291 "document.getElementById('username_field').value = 'temp';"
282 "document.getElementById('password_field').value = 'random';" 292 "document.getElementById('password_field').value = 'random';"
283 "document.getElementById('input_submit_button').click()"; 293 "document.getElementById('input_submit_button').click()";
284 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 294 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
285 observer.Wait(); 295 observer.Wait();
286 EXPECT_TRUE(observer.infobar_shown()); 296 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
297 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
298 } else {
299 EXPECT_TRUE(observer.infobar_shown());
300 }
287 } 301 }
288 302
289 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 303 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
290 LoginSuccessWithUnrelatedForm) { 304 LoginSuccessWithUnrelatedForm) {
291 // Log in, see a form on the landing page. That form is not related to the 305 // Log in, see a form on the landing page. That form is not related to the
292 // login form (=has a different action), so we should offer saving the 306 // login form (=has a different action), so we should offer saving the
293 // password. 307 // password.
294 NavigateToFile("/password/password_form.html"); 308 NavigateToFile("/password/password_form.html");
295 309
296 NavigationObserver observer(WebContents()); 310 NavigationObserver observer(WebContents());
297 std::string fill_and_submit = 311 std::string fill_and_submit =
298 "document.getElementById('username_unrelated').value = 'temp';" 312 "document.getElementById('username_unrelated').value = 'temp';"
299 "document.getElementById('password_unrelated').value = 'random';" 313 "document.getElementById('password_unrelated').value = 'random';"
300 "document.getElementById('submit_unrelated').click()"; 314 "document.getElementById('submit_unrelated').click()";
301 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 315 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
302 observer.Wait(); 316 observer.Wait();
303 EXPECT_TRUE(observer.infobar_shown()); 317 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
318 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
319 } else {
320 EXPECT_TRUE(observer.infobar_shown());
321 }
304 } 322 }
305 323
306 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, LoginFailed) { 324 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, LoginFailed) {
307 // Log in, see a form on the landing page. That form is not related to the 325 // Log in, see a form on the landing page. That form is not related to the
308 // login form (=has a different action), so we should offer saving the 326 // login form (=has a different action), so we should offer saving the
309 // password. 327 // password.
310 NavigateToFile("/password/password_form.html"); 328 NavigateToFile("/password/password_form.html");
311 329
312 NavigationObserver observer(WebContents()); 330 NavigationObserver observer(WebContents());
313 std::string fill_and_submit = 331 std::string fill_and_submit =
314 "document.getElementById('username_failed').value = 'temp';" 332 "document.getElementById('username_failed').value = 'temp';"
315 "document.getElementById('password_failed').value = 'random';" 333 "document.getElementById('password_failed').value = 'random';"
316 "document.getElementById('submit_failed').click()"; 334 "document.getElementById('submit_failed').click()";
317 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 335 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
318 observer.Wait(); 336 observer.Wait();
319 EXPECT_FALSE(observer.infobar_shown()); 337 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
338 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
339 } else {
340 EXPECT_FALSE(observer.infobar_shown());
341 }
320 } 342 }
321 343
322 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, Redirects) { 344 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, Redirects) {
323 NavigateToFile("/password/password_form.html"); 345 NavigateToFile("/password/password_form.html");
324 346
325 // Fill a form and submit through a <input type="submit"> button. The form 347 // Fill a form and submit through a <input type="submit"> button. The form
326 // points to a redirection page. 348 // points to a redirection page.
327 NavigationObserver observer(WebContents()); 349 NavigationObserver observer(WebContents());
328 std::string fill_and_submit = 350 std::string fill_and_submit =
329 "document.getElementById('username_redirect').value = 'temp';" 351 "document.getElementById('username_redirect').value = 'temp';"
330 "document.getElementById('password_redirect').value = 'random';" 352 "document.getElementById('password_redirect').value = 'random';"
331 "document.getElementById('submit_redirect').click()"; 353 "document.getElementById('submit_redirect').click()";
332 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 354 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
333 observer.disable_should_automatically_accept_infobar(); 355 observer.disable_should_automatically_accept_infobar();
334 observer.Wait(); 356 observer.Wait();
335 EXPECT_TRUE(observer.infobar_shown()); 357 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
358 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
359 } else {
360 EXPECT_TRUE(observer.infobar_shown());
361 }
336 362
337 // The redirection page now redirects via Javascript. We check that the 363 // The redirection page now redirects via Javascript. We check that the
338 // infobar stays. 364 // infobar stays.
339 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), 365 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
340 "window.location.href = 'done.html';")); 366 "window.location.href = 'done.html';"));
341 observer.Wait(); 367 observer.Wait();
342 EXPECT_FALSE(observer.infobar_removed()); 368 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
369 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
370 } else {
371 EXPECT_FALSE(observer.infobar_removed());
372 }
343 } 373 }
344 374
345 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 375 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
346 PromptForSubmitUsingJavaScript) { 376 PromptForSubmitUsingJavaScript) {
347 NavigateToFile("/password/password_form.html"); 377 NavigateToFile("/password/password_form.html");
348 378
349 // Fill a form and submit using <button> that calls submit() on the form. 379 // Fill a form and submit using <button> that calls submit() on the form.
350 // This should work regardless of the type of element, as long as submit() is 380 // This should work regardless of the type of element, as long as submit() is
351 // called. 381 // called.
352 NavigationObserver observer(WebContents()); 382 NavigationObserver observer(WebContents());
353 std::string fill_and_submit = 383 std::string fill_and_submit =
354 "document.getElementById('username_field').value = 'temp';" 384 "document.getElementById('username_field').value = 'temp';"
355 "document.getElementById('password_field').value = 'random';" 385 "document.getElementById('password_field').value = 'random';"
356 "document.getElementById('submit_button').click()"; 386 "document.getElementById('submit_button').click()";
357 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 387 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
358 observer.Wait(); 388 observer.Wait();
359 EXPECT_TRUE(observer.infobar_shown()); 389 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
390 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
391 } else {
392 EXPECT_TRUE(observer.infobar_shown());
393 }
360 } 394 }
361 395
362 // Flaky: crbug.com/301547, observed on win and mac. Probably happens on all 396 // Flaky: crbug.com/301547, observed on win and mac. Probably happens on all
363 // platforms. 397 // platforms.
364 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 398 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
365 DISABLED_PromptForDynamicForm) { 399 DISABLED_PromptForDynamicForm) {
366 NavigateToFile("/password/dynamic_password_form.html"); 400 NavigateToFile("/password/dynamic_password_form.html");
367 401
368 // Fill the dynamic password form and submit. 402 // Fill the dynamic password form and submit.
369 NavigationObserver observer(WebContents()); 403 NavigationObserver observer(WebContents());
370 std::string fill_and_submit = 404 std::string fill_and_submit =
371 "document.getElementById('create_form_button').click();" 405 "document.getElementById('create_form_button').click();"
372 "window.setTimeout(function() {" 406 "window.setTimeout(function() {"
373 " document.dynamic_form.username.value = 'tempro';" 407 " document.dynamic_form.username.value = 'tempro';"
374 " document.dynamic_form.password.value = 'random';" 408 " document.dynamic_form.password.value = 'random';"
375 " document.dynamic_form.submit();" 409 " document.dynamic_form.submit();"
376 "}, 0)"; 410 "}, 0)";
377 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 411 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
378 observer.Wait(); 412 observer.Wait();
379 EXPECT_TRUE(observer.infobar_shown()); 413 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
414 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
415 } else {
416 EXPECT_TRUE(observer.infobar_shown());
417 }
380 } 418 }
381 419
382 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { 420 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) {
383 NavigateToFile("/password/password_form.html"); 421 NavigateToFile("/password/password_form.html");
384 422
385 // Don't fill the password form, just navigate away. Shouldn't prompt. 423 // Don't fill the password form, just navigate away. Shouldn't prompt.
386 NavigationObserver observer(WebContents()); 424 NavigationObserver observer(WebContents());
387 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), 425 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
388 "window.location.href = 'done.html';")); 426 "window.location.href = 'done.html';"));
389 observer.Wait(); 427 observer.Wait();
390 EXPECT_FALSE(observer.infobar_shown()); 428 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
429 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
430 } else {
431 EXPECT_FALSE(observer.infobar_shown());
432 }
391 } 433 }
392 434
393 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 435 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
394 NoPromptForSubFrameNavigation) { 436 NoPromptForSubFrameNavigation) {
395 NavigateToFile("/password/multi_frames.html"); 437 NavigateToFile("/password/multi_frames.html");
396 438
397 // If you are filling out a password form in one frame and a different frame 439 // If you are filling out a password form in one frame and a different frame
398 // navigates, this should not trigger the infobar. 440 // navigates, this should not trigger the infobar.
399 NavigationObserver observer(WebContents()); 441 NavigationObserver observer(WebContents());
400 observer.SetPathToWaitFor("/password/done.html"); 442 observer.SetPathToWaitFor("/password/done.html");
401 std::string fill = 443 std::string fill =
402 "var first_frame = document.getElementById('first_frame');" 444 "var first_frame = document.getElementById('first_frame');"
403 "var frame_doc = first_frame.contentDocument;" 445 "var frame_doc = first_frame.contentDocument;"
404 "frame_doc.getElementById('username_field').value = 'temp';" 446 "frame_doc.getElementById('username_field').value = 'temp';"
405 "frame_doc.getElementById('password_field').value = 'random';"; 447 "frame_doc.getElementById('password_field').value = 'random';";
406 std::string navigate_frame = 448 std::string navigate_frame =
407 "var second_iframe = document.getElementById('second_frame');" 449 "var second_iframe = document.getElementById('second_frame');"
408 "second_iframe.contentWindow.location.href = 'done.html';"; 450 "second_iframe.contentWindow.location.href = 'done.html';";
409 451
410 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); 452 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill));
411 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); 453 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame));
412 observer.Wait(); 454 observer.Wait();
413 EXPECT_FALSE(observer.infobar_shown()); 455 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
456 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
457 } else {
458 EXPECT_FALSE(observer.infobar_shown());
459 }
414 } 460 }
415 461
416 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 462 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
417 PromptAfterSubmitWithSubFrameNavigation) { 463 PromptAfterSubmitWithSubFrameNavigation) {
418 NavigateToFile("/password/multi_frames.html"); 464 NavigateToFile("/password/multi_frames.html");
419 465
420 // Make sure that we prompt to save password even if a sub-frame navigation 466 // Make sure that we prompt to save password even if a sub-frame navigation
421 // happens first. 467 // happens first.
422 NavigationObserver observer(WebContents()); 468 NavigationObserver observer(WebContents());
423 observer.SetPathToWaitFor("/password/done.html"); 469 observer.SetPathToWaitFor("/password/done.html");
424 std::string navigate_frame = 470 std::string navigate_frame =
425 "var second_iframe = document.getElementById('second_frame');" 471 "var second_iframe = document.getElementById('second_frame');"
426 "second_iframe.contentWindow.location.href = 'other.html';"; 472 "second_iframe.contentWindow.location.href = 'other.html';";
427 std::string fill_and_submit = 473 std::string fill_and_submit =
428 "var first_frame = document.getElementById('first_frame');" 474 "var first_frame = document.getElementById('first_frame');"
429 "var frame_doc = first_frame.contentDocument;" 475 "var frame_doc = first_frame.contentDocument;"
430 "frame_doc.getElementById('username_field').value = 'temp';" 476 "frame_doc.getElementById('username_field').value = 'temp';"
431 "frame_doc.getElementById('password_field').value = 'random';" 477 "frame_doc.getElementById('password_field').value = 'random';"
432 "frame_doc.getElementById('input_submit_button').click();"; 478 "frame_doc.getElementById('input_submit_button').click();";
433 479
434 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); 480 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame));
435 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 481 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
436 observer.Wait(); 482 observer.Wait();
437 EXPECT_TRUE(observer.infobar_shown()); 483 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
484 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
485 } else {
486 EXPECT_TRUE(observer.infobar_shown());
487 }
438 } 488 }
439 489
440 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 490 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
441 PromptForXHRSubmit) { 491 PromptForXHRSubmit) {
442 #if defined(OS_WIN) && defined(USE_ASH) 492 #if defined(OS_WIN) && defined(USE_ASH)
443 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 493 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
444 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 494 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
445 return; 495 return;
446 #endif 496 #endif
447 NavigateToFile("/password/password_xhr_submit.html"); 497 NavigateToFile("/password/password_xhr_submit.html");
448 498
449 // Verify that we show the save password prompt if a form returns false 499 // Verify that we show the save password prompt if a form returns false
450 // in its onsubmit handler but instead logs in/navigates via XHR. 500 // in its onsubmit handler but instead logs in/navigates via XHR.
451 // Note that calling 'submit()' on a form with javascript doesn't call 501 // Note that calling 'submit()' on a form with javascript doesn't call
452 // the onsubmit handler, so we click the submit button instead. 502 // the onsubmit handler, so we click the submit button instead.
453 NavigationObserver observer(WebContents()); 503 NavigationObserver observer(WebContents());
454 std::string fill_and_submit = 504 std::string fill_and_submit =
455 "document.getElementById('username_field').value = 'temp';" 505 "document.getElementById('username_field').value = 'temp';"
456 "document.getElementById('password_field').value = 'random';" 506 "document.getElementById('password_field').value = 'random';"
457 "document.getElementById('submit_button').click()"; 507 "document.getElementById('submit_button').click()";
458 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 508 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
459 observer.Wait(); 509 observer.Wait();
460 EXPECT_TRUE(observer.infobar_shown()); 510 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
511 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
512 } else {
513 EXPECT_TRUE(observer.infobar_shown());
514 }
461 } 515 }
462 516
463 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 517 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
464 PromptForXHRWithoutOnSubmit) { 518 PromptForXHRWithoutOnSubmit) {
465 NavigateToFile("/password/password_xhr_submit.html"); 519 NavigateToFile("/password/password_xhr_submit.html");
466 520
467 // Verify that if XHR navigation occurs and the form is properly filled out, 521 // Verify that if XHR navigation occurs and the form is properly filled out,
468 // we try and save the password even though onsubmit hasn't been called. 522 // we try and save the password even though onsubmit hasn't been called.
469 NavigationObserver observer(WebContents()); 523 NavigationObserver observer(WebContents());
470 std::string fill_and_navigate = 524 std::string fill_and_navigate =
471 "document.getElementById('username_field').value = 'temp';" 525 "document.getElementById('username_field').value = 'temp';"
472 "document.getElementById('password_field').value = 'random';" 526 "document.getElementById('password_field').value = 'random';"
473 "send_xhr()"; 527 "send_xhr()";
474 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); 528 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
475 observer.Wait(); 529 observer.Wait();
476 EXPECT_TRUE(observer.infobar_shown()); 530 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
531 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
532 } else {
533 EXPECT_TRUE(observer.infobar_shown());
534 }
477 } 535 }
478 536
479 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 537 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
480 NoPromptIfLinkClicked) { 538 NoPromptIfLinkClicked) {
481 NavigateToFile("/password/password_form.html"); 539 NavigateToFile("/password/password_form.html");
482 540
483 // Verify that if the user takes a direct action to leave the page, we don't 541 // Verify that if the user takes a direct action to leave the page, we don't
484 // prompt to save the password even if the form is already filled out. 542 // prompt to save the password even if the form is already filled out.
485 NavigationObserver observer(WebContents()); 543 NavigationObserver observer(WebContents());
486 std::string fill_and_click_link = 544 std::string fill_and_click_link =
487 "document.getElementById('username_field').value = 'temp';" 545 "document.getElementById('username_field').value = 'temp';"
488 "document.getElementById('password_field').value = 'random';" 546 "document.getElementById('password_field').value = 'random';"
489 "document.getElementById('link').click();"; 547 "document.getElementById('link').click();";
490 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); 548 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link));
491 observer.Wait(); 549 observer.Wait();
492 EXPECT_FALSE(observer.infobar_shown()); 550 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
551 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
552 } else {
553 EXPECT_FALSE(observer.infobar_shown());
554 }
493 } 555 }
494 556
495 // TODO(jam): http://crbug.com/350550 557 // TODO(jam): http://crbug.com/350550
496 #if !defined(OS_WIN) 558 #if !defined(OS_WIN)
497 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 559 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
498 VerifyPasswordGenerationUpload) { 560 VerifyPasswordGenerationUpload) {
499 // Prevent Autofill requests from actually going over the wire. 561 // Prevent Autofill requests from actually going over the wire.
500 net::TestURLFetcherFactory factory; 562 net::TestURLFetcherFactory factory;
501 // Disable Autofill requesting access to AddressBook data. This causes 563 // Disable Autofill requesting access to AddressBook data. This causes
502 // the test to hang on Mac. 564 // the test to hang on Mac.
503 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); 565 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
504 566
505 // Visit a signup form. 567 // Visit a signup form.
506 NavigateToFile("/password/signup_form.html"); 568 NavigateToFile("/password/signup_form.html");
507 569
508 // Enter a password and save it. 570 // Enter a password and save it.
509 NavigationObserver first_observer(WebContents()); 571 NavigationObserver first_observer(WebContents());
510 std::string fill_and_submit = 572 std::string fill_and_submit =
511 "document.getElementById('other_info').value = 'stuff';" 573 "document.getElementById('other_info').value = 'stuff';"
512 "document.getElementById('username_field').value = 'my_username';" 574 "document.getElementById('username_field').value = 'my_username';"
513 "document.getElementById('password_field').value = 'password';" 575 "document.getElementById('password_field').value = 'password';"
514 "document.getElementById('input_submit_button').click()"; 576 "document.getElementById('input_submit_button').click()";
515 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 577 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
516 578
517 first_observer.Wait(); 579 first_observer.Wait();
518 ASSERT_TRUE(first_observer.infobar_shown()); 580 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
581 ASSERT_TRUE(controller()->PasswordPendingUserDecision());
582 controller()->SavePassword();
583 } else {
584 ASSERT_TRUE(first_observer.infobar_shown());
585 }
519 586
520 // Now navigate to a login form that has similar HTML markup. 587 // Now navigate to a login form that has similar HTML markup.
521 NavigateToFile("/password/password_form.html"); 588 NavigateToFile("/password/password_form.html");
522 589
523 // Simulate a user click to force an autofill of the form's DOM value, not 590 // Simulate a user click to force an autofill of the form's DOM value, not
524 // just the suggested value. 591 // just the suggested value.
525 content::SimulateMouseClick( 592 content::SimulateMouseClick(
526 WebContents(), 0, blink::WebMouseEvent::ButtonLeft); 593 WebContents(), 0, blink::WebMouseEvent::ButtonLeft);
527 594
528 // The form should be filled with the previously submitted username. 595 // The form should be filled with the previously submitted username.
529 std::string get_username = 596 std::string get_username =
530 "window.domAutomationController.send(" 597 "window.domAutomationController.send("
531 "document.getElementById('username_field').value);"; 598 "document.getElementById('username_field').value);";
532 std::string actual_username; 599 std::string actual_username;
533 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(), 600 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(),
534 get_username, 601 get_username,
535 &actual_username)); 602 &actual_username));
536 ASSERT_EQ("my_username", actual_username); 603 ASSERT_EQ("my_username", actual_username);
537 604
538 // Submit the form and verify that there is no infobar (as the password 605 // Submit the form and verify that there is no infobar (as the password
539 // has already been saved). 606 // has already been saved).
540 NavigationObserver second_observer(WebContents()); 607 NavigationObserver second_observer(WebContents());
541 std::string submit_form = 608 std::string submit_form =
542 "document.getElementById('input_submit_button').click()"; 609 "document.getElementById('input_submit_button').click()";
543 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); 610 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form));
544 second_observer.Wait(); 611 second_observer.Wait();
545 EXPECT_FALSE(second_observer.infobar_shown()); 612 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
613 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
614 } else {
615 EXPECT_FALSE(second_observer.infobar_shown());
616 }
546 617
547 // Verify that we sent a ping to Autofill saying that the original form 618 // Verify that we sent a ping to Autofill saying that the original form
548 // was likely an account creation form since it has more than 2 text input 619 // was likely an account creation form since it has more than 2 text input
549 // fields and was used for the first time on a different form. 620 // fields and was used for the first time on a different form.
550 base::HistogramBase* upload_histogram = 621 base::HistogramBase* upload_histogram =
551 base::StatisticsRecorder::FindHistogram( 622 base::StatisticsRecorder::FindHistogram(
552 "PasswordGeneration.UploadStarted"); 623 "PasswordGeneration.UploadStarted");
553 ASSERT_TRUE(upload_histogram); 624 ASSERT_TRUE(upload_histogram);
554 scoped_ptr<base::HistogramSamples> snapshot = 625 scoped_ptr<base::HistogramSamples> snapshot =
555 upload_histogram->SnapshotSamples(); 626 upload_histogram->SnapshotSamples();
(...skipping 11 matching lines...) Expand all
567 NavigationObserver observer(WebContents()); 638 NavigationObserver observer(WebContents());
568 std::string fill_and_submit = 639 std::string fill_and_submit =
569 "var iframe = document.getElementById('test_iframe');" 640 "var iframe = document.getElementById('test_iframe');"
570 "var iframe_doc = iframe.contentDocument;" 641 "var iframe_doc = iframe.contentDocument;"
571 "iframe_doc.getElementById('username_field').value = 'temp';" 642 "iframe_doc.getElementById('username_field').value = 'temp';"
572 "iframe_doc.getElementById('password_field').value = 'random';" 643 "iframe_doc.getElementById('password_field').value = 'random';"
573 "iframe_doc.getElementById('submit_button').click()"; 644 "iframe_doc.getElementById('submit_button').click()";
574 645
575 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 646 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
576 observer.Wait(); 647 observer.Wait();
577 EXPECT_TRUE(observer.infobar_shown()); 648 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
649 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
650 } else {
651 EXPECT_TRUE(observer.infobar_shown());
652 }
578 } 653 }
579 654
580 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 655 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
581 PromptForInputElementWithoutName) { 656 PromptForInputElementWithoutName) {
582 // Check that the prompt is shown for forms where input elements lack the 657 // Check that the prompt is shown for forms where input elements lack the
583 // "name" attribute but the "id" is present. 658 // "name" attribute but the "id" is present.
584 NavigateToFile("/password/password_form.html"); 659 NavigateToFile("/password/password_form.html");
585 660
586 NavigationObserver observer(WebContents()); 661 NavigationObserver observer(WebContents());
587 std::string fill_and_submit = 662 std::string fill_and_submit =
588 "document.getElementById('username_field_no_name').value = 'temp';" 663 "document.getElementById('username_field_no_name').value = 'temp';"
589 "document.getElementById('password_field_no_name').value = 'random';" 664 "document.getElementById('password_field_no_name').value = 'random';"
590 "document.getElementById('input_submit_button_no_name').click()"; 665 "document.getElementById('input_submit_button_no_name').click()";
591 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 666 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
592 observer.Wait(); 667 observer.Wait();
593 EXPECT_TRUE(observer.infobar_shown()); 668 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
669 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
670 } else {
671 EXPECT_TRUE(observer.infobar_shown());
672 }
594 } 673 }
595 674
596 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 675 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
597 PromptForInputElementWithoutId) { 676 PromptForInputElementWithoutId) {
598 // Check that the prompt is shown for forms where input elements lack the 677 // Check that the prompt is shown for forms where input elements lack the
599 // "id" attribute but the "name" attribute is present. 678 // "id" attribute but the "name" attribute is present.
600 NavigateToFile("/password/password_form.html"); 679 NavigateToFile("/password/password_form.html");
601 680
602 NavigationObserver observer(WebContents()); 681 NavigationObserver observer(WebContents());
603 std::string fill_and_submit = 682 std::string fill_and_submit =
604 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" 683 "document.getElementsByName('username_field_no_id')[0].value = 'temp';"
605 "document.getElementsByName('password_field_no_id')[0].value = 'random';" 684 "document.getElementsByName('password_field_no_id')[0].value = 'random';"
606 "document.getElementsByName('input_submit_button_no_id')[0].click()"; 685 "document.getElementsByName('input_submit_button_no_id')[0].click()";
607 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 686 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
608 observer.Wait(); 687 observer.Wait();
609 EXPECT_TRUE(observer.infobar_shown()); 688 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
689 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
690 } else {
691 EXPECT_TRUE(observer.infobar_shown());
692 }
610 } 693 }
611 694
612 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 695 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
613 NoPromptForInputElementWithoutIdAndName) { 696 NoPromptForInputElementWithoutIdAndName) {
614 // Check that no prompt is shown for forms where the input fields lack both 697 // Check that no prompt is shown for forms where the input fields lack both
615 // the "id" and the "name" attributes. 698 // the "id" and the "name" attributes.
616 NavigateToFile("/password/password_form.html"); 699 NavigateToFile("/password/password_form.html");
617 700
618 NavigationObserver observer(WebContents()); 701 NavigationObserver observer(WebContents());
619 std::string fill_and_submit = 702 std::string fill_and_submit =
620 "var form = document.getElementById('testform_elements_no_id_no_name');" 703 "var form = document.getElementById('testform_elements_no_id_no_name');"
621 "var username = form.children[0];" 704 "var username = form.children[0];"
622 "username.value = 'temp';" 705 "username.value = 'temp';"
623 "var password = form.children[1];" 706 "var password = form.children[1];"
624 "password.value = 'random';" 707 "password.value = 'random';"
625 "form.children[2].click()"; // form.children[2] is the submit button. 708 "form.children[2].click()"; // form.children[2] is the submit button.
626 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 709 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
627 observer.Wait(); 710 observer.Wait();
628 EXPECT_FALSE(observer.infobar_shown()); 711 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
712 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
713 } else {
714 EXPECT_FALSE(observer.infobar_shown());
715 }
629 } 716 }
630 717
631 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, DeleteFrameBeforeSubmit) { 718 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, DeleteFrameBeforeSubmit) {
632 NavigateToFile("/password/multi_frames.html"); 719 NavigateToFile("/password/multi_frames.html");
633 720
634 NavigationObserver observer(WebContents()); 721 NavigationObserver observer(WebContents());
635 // Make sure we save some password info from an iframe and then destroy it. 722 // Make sure we save some password info from an iframe and then destroy it.
636 std::string save_and_remove = 723 std::string save_and_remove =
637 "var first_frame = document.getElementById('first_frame');" 724 "var first_frame = document.getElementById('first_frame');"
638 "var frame_doc = first_frame.contentDocument;" 725 "var frame_doc = first_frame.contentDocument;"
(...skipping 27 matching lines...) Expand all
666 browser()->tab_strip_model()->ActivateTabAt(0, false); 753 browser()->tab_strip_model()->ActivateTabAt(0, false);
667 754
668 // Fill in the credentials, and make sure they are saved. 755 // Fill in the credentials, and make sure they are saved.
669 NavigationObserver form_submit_observer(WebContents()); 756 NavigationObserver form_submit_observer(WebContents());
670 std::string fill_and_submit = 757 std::string fill_and_submit =
671 "document.getElementById('username_field').value = 'temp';" 758 "document.getElementById('username_field').value = 'temp';"
672 "document.getElementById('password_field').value = 'random';" 759 "document.getElementById('password_field').value = 'random';"
673 "document.getElementById('input_submit_button').click();"; 760 "document.getElementById('input_submit_button').click();";
674 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 761 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
675 form_submit_observer.Wait(); 762 form_submit_observer.Wait();
676 EXPECT_TRUE(form_submit_observer.infobar_shown()); 763 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
764 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
765 controller()->SavePassword();
766 } else {
767 EXPECT_TRUE(form_submit_observer.infobar_shown());
768 }
677 769
678 // Reload the original page to have the saved credentials autofilled. 770 // Reload the original page to have the saved credentials autofilled.
679 NavigationObserver reload_observer(WebContents()); 771 NavigationObserver reload_observer(WebContents());
680 NavigateToFile("/password/form_and_link.html"); 772 NavigateToFile("/password/form_and_link.html");
681 reload_observer.Wait(); 773 reload_observer.Wait();
682 774
683 // Wait until the username is filled, to make sure autofill kicked in. 775 // Wait until the username is filled, to make sure autofill kicked in.
684 WaitForElementValue("username_field", "temp"); 776 WaitForElementValue("username_field", "temp");
685 // Now check that the password is not accessible yet. 777 // Now check that the password is not accessible yet.
686 CheckElementValue("password_field", ""); 778 CheckElementValue("password_field", "");
(...skipping 17 matching lines...) Expand all
704 NavigateToFile("/password/form_and_link.html"); 796 NavigateToFile("/password/form_and_link.html");
705 797
706 // Fill in the credentials, and make sure they are saved. 798 // Fill in the credentials, and make sure they are saved.
707 NavigationObserver form_submit_observer(WebContents()); 799 NavigationObserver form_submit_observer(WebContents());
708 std::string fill_and_submit = 800 std::string fill_and_submit =
709 "document.getElementById('username_field').value = 'temp';" 801 "document.getElementById('username_field').value = 'temp';"
710 "document.getElementById('password_field').value = 'random_secret';" 802 "document.getElementById('password_field').value = 'random_secret';"
711 "document.getElementById('input_submit_button').click();"; 803 "document.getElementById('input_submit_button').click();";
712 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 804 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
713 form_submit_observer.Wait(); 805 form_submit_observer.Wait();
714 EXPECT_TRUE(form_submit_observer.infobar_shown()); 806 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
807 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
808 controller()->SavePassword();
809 } else {
810 EXPECT_TRUE(form_submit_observer.infobar_shown());
811 }
715 812
716 // Reload the original page to have the saved credentials autofilled. 813 // Reload the original page to have the saved credentials autofilled.
717 NavigationObserver reload_observer(WebContents()); 814 NavigationObserver reload_observer(WebContents());
718 NavigateToFile("/password/form_and_link.html"); 815 NavigateToFile("/password/form_and_link.html");
719 reload_observer.Wait(); 816 reload_observer.Wait();
720 817
721 NavigationObserver submit_observer(WebContents()); 818 NavigationObserver submit_observer(WebContents());
722 // Submit the form via a tap on the submit button. The button is placed at 0, 819 // Submit the form via a tap on the submit button. The button is placed at 0,
723 // 100, and has height 300 and width 700. 820 // 100, and has height 300 and width 700.
724 content::SimulateTapAt(WebContents(), gfx::Point(350, 250)); 821 content::SimulateTapAt(WebContents(), gfx::Point(350, 250));
725 submit_observer.Wait(); 822 submit_observer.Wait();
726 std::string query = WebContents()->GetURL().query(); 823 std::string query = WebContents()->GetURL().query();
727 EXPECT_NE(std::string::npos, query.find("random_secret")) << query; 824 EXPECT_NE(std::string::npos, query.find("random_secret")) << query;
728 } 825 }
729 #endif 826 #endif
730 827
731 // Test fix for crbug.com/338650. 828 // Test fix for crbug.com/338650.
732 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 829 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
733 DontPromptForPasswordFormWithDefaultValue) { 830 DontPromptForPasswordFormWithDefaultValue) {
734 NavigateToFile("/password/password_form_with_default_value.html"); 831 NavigateToFile("/password/password_form_with_default_value.html");
735 832
736 // Don't prompt if we navigate away even if there is a password value since 833 // Don't prompt if we navigate away even if there is a password value since
737 // it's not coming from the user. 834 // it's not coming from the user.
738 NavigationObserver observer(WebContents()); 835 NavigationObserver observer(WebContents());
739 NavigateToFile("/password/done.html"); 836 NavigateToFile("/password/done.html");
740 observer.Wait(); 837 observer.Wait();
741 EXPECT_FALSE(observer.infobar_shown()); 838 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
839 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
840 } else {
841 EXPECT_FALSE(observer.infobar_shown());
842 }
742 } 843 }
743 844
744 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 845 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
745 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { 846 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) {
746 NavigateToFile("/password/password_form.html"); 847 NavigateToFile("/password/password_form.html");
747 848
748 // Fill a form and submit through a <input type="submit"> button. 849 // Fill a form and submit through a <input type="submit"> button.
749 NavigationObserver observer(WebContents()); 850 NavigationObserver observer(WebContents());
750 std::string fill_and_submit = 851 std::string fill_and_submit =
751 "document.getElementById('username_field').value = 'temp';" 852 "document.getElementById('username_field').value = 'temp';"
752 "document.getElementById('password_field').value = 'random';" 853 "document.getElementById('password_field').value = 'random';"
753 "document.getElementById('input_submit_button').click()"; 854 "document.getElementById('input_submit_button').click()";
754 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 855 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
755 observer.Wait(); 856 observer.Wait();
756 EXPECT_TRUE(observer.infobar_shown()); 857 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
858 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
859 } else {
860 EXPECT_TRUE(observer.infobar_shown());
861 }
757 } 862 }
758 863
759 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 864 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
760 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { 865 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) {
761 password_manager::TestPasswordStore* password_store = 866 password_manager::TestPasswordStore* password_store =
762 static_cast<password_manager::TestPasswordStore*>( 867 static_cast<password_manager::TestPasswordStore*>(
763 PasswordStoreFactory::GetForProfile(browser()->profile(), 868 PasswordStoreFactory::GetForProfile(browser()->profile(),
764 Profile::IMPLICIT_ACCESS).get()); 869 Profile::IMPLICIT_ACCESS).get());
765 870
766 EXPECT_TRUE(password_store->IsEmpty()); 871 EXPECT_TRUE(password_store->IsEmpty());
767 872
768 NavigateToFile("/password/password_form.html"); 873 NavigateToFile("/password/password_form.html");
769 874
770 // Add the enable-automatic-password-saving switch. 875 // Add the enable-automatic-password-saving switch.
771 CommandLine::ForCurrentProcess()->AppendSwitch( 876 CommandLine::ForCurrentProcess()->AppendSwitch(
772 password_manager::switches::kEnableAutomaticPasswordSaving); 877 password_manager::switches::kEnableAutomaticPasswordSaving);
773 878
774 // Fill a form and submit through a <input type="submit"> button. 879 // Fill a form and submit through a <input type="submit"> button.
775 NavigationObserver observer(WebContents()); 880 NavigationObserver observer(WebContents());
776 // Make sure that the only passwords saved are the auto-saved ones. 881 // Make sure that the only passwords saved are the auto-saved ones.
777 observer.disable_should_automatically_accept_infobar(); 882 observer.disable_should_automatically_accept_infobar();
778 std::string fill_and_submit = 883 std::string fill_and_submit =
779 "document.getElementById('username_field').value = 'temp';" 884 "document.getElementById('username_field').value = 'temp';"
780 "document.getElementById('password_field').value = 'random';" 885 "document.getElementById('password_field').value = 'random';"
781 "document.getElementById('input_submit_button').click()"; 886 "document.getElementById('input_submit_button').click()";
782 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 887 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
783 observer.Wait(); 888 observer.Wait();
784 if (chrome::VersionInfo::GetChannel() == 889 if (chrome::VersionInfo::GetChannel() ==
785 chrome::VersionInfo::CHANNEL_UNKNOWN) { 890 chrome::VersionInfo::CHANNEL_UNKNOWN) {
786 EXPECT_FALSE(observer.infobar_shown()); 891 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
892 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
893 } else {
894 EXPECT_FALSE(observer.infobar_shown());
895 }
787 EXPECT_FALSE(password_store->IsEmpty()); 896 EXPECT_FALSE(password_store->IsEmpty());
788 } else { 897 } else {
789 EXPECT_TRUE(observer.infobar_shown()); 898 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
899 EXPECT_TRUE(controller()->PasswordPendingUserDecision());
900 } else {
901 EXPECT_TRUE(observer.infobar_shown());
902 }
790 EXPECT_TRUE(password_store->IsEmpty()); 903 EXPECT_TRUE(password_store->IsEmpty());
791 } 904 }
792 } 905 }
793 906
794 // Test fix for crbug.com/368690. 907 // Test fix for crbug.com/368690.
795 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptWhenReloading) { 908 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptWhenReloading) {
796 NavigateToFile("/password/password_form.html"); 909 NavigateToFile("/password/password_form.html");
797 910
798 std::string fill = 911 std::string fill =
799 "document.getElementById('username_redirect').value = 'temp';" 912 "document.getElementById('username_redirect').value = 'temp';"
800 "document.getElementById('password_redirect').value = 'random';"; 913 "document.getElementById('password_redirect').value = 'random';";
801 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); 914 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill));
802 915
803 NavigationObserver observer(WebContents()); 916 NavigationObserver observer(WebContents());
804 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); 917 GURL url = embedded_test_server()->GetURL("/password/password_form.html");
805 chrome::NavigateParams params(browser(), url, 918 chrome::NavigateParams params(browser(), url,
806 content::PAGE_TRANSITION_RELOAD); 919 content::PAGE_TRANSITION_RELOAD);
807 ui_test_utils::NavigateToURL(&params); 920 ui_test_utils::NavigateToURL(&params);
808 observer.Wait(); 921 observer.Wait();
809 EXPECT_FALSE(observer.infobar_shown()); 922 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
923 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
924 } else {
925 EXPECT_FALSE(observer.infobar_shown());
926 }
810 } 927 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698