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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 11419276: Remove tabstrip wrappers in browser_tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years 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 // This test creates a fake safebrowsing service, where we can inject 5 // This test creates a fake safebrowsing service, where we can inject
6 // malware and phishing urls. It then uses a real browser to go to 6 // malware and phishing urls. It then uses a real browser to go to
7 // these urls, and sends "goback" or "proceed" commands and verifies 7 // these urls, and sends "goback" or "proceed" commands and verifies
8 // they work. 8 // they work.
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/safe_browsing/database_manager.h" 16 #include "chrome/browser/safe_browsing/database_manager.h"
17 #include "chrome/browser/safe_browsing/malware_details.h" 17 #include "chrome/browser/safe_browsing/malware_details.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
20 #include "chrome/browser/safe_browsing/ui_manager.h" 20 #include "chrome/browser/safe_browsing/ui_manager.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/interstitial_page.h" 29 #include "content/public/browser/interstitial_page.h"
29 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/notification_types.h" 31 #include "content/public/browser/notification_types.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_contents_view.h" 34 #include "content/public/browser/web_contents_view.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 GURL url = test_server()->GetURL(kMalwarePage); 355 GURL url = test_server()->GetURL(kMalwarePage);
355 GURL iframe_url = test_server()->GetURL(kMalwareIframe); 356 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
356 SetURLThreatType(iframe_url, SB_THREAT_TYPE_URL_MALWARE); 357 SetURLThreatType(iframe_url, SB_THREAT_TYPE_URL_MALWARE);
357 358
358 ui_test_utils::NavigateToURL(browser(), url); 359 ui_test_utils::NavigateToURL(browser(), url);
359 EXPECT_TRUE(WaitForReady()); 360 EXPECT_TRUE(WaitForReady());
360 return url; 361 return url;
361 } 362 }
362 363
363 void SendCommand(const std::string& command) { 364 void SendCommand(const std::string& command) {
364 WebContents* contents = chrome::GetActiveWebContents(browser()); 365 WebContents* contents =
366 browser()->tab_strip_model()->GetActiveWebContents();
365 // We use InterstitialPage::GetInterstitialPage(tab) instead of 367 // We use InterstitialPage::GetInterstitialPage(tab) instead of
366 // tab->GetInterstitialPage() because the tab doesn't have a pointer 368 // tab->GetInterstitialPage() because the tab doesn't have a pointer
367 // to its interstital page until it gets a command from the renderer 369 // to its interstital page until it gets a command from the renderer
368 // that it has indeed displayed it -- and this sometimes happens after 370 // that it has indeed displayed it -- and this sometimes happens after
369 // NavigateToURL returns. 371 // NavigateToURL returns.
370 SafeBrowsingBlockingPage* interstitial_page = 372 SafeBrowsingBlockingPage* interstitial_page =
371 static_cast<SafeBrowsingBlockingPage*>( 373 static_cast<SafeBrowsingBlockingPage*>(
372 InterstitialPage::GetInterstitialPage(contents)-> 374 InterstitialPage::GetInterstitialPage(contents)->
373 GetDelegateForTesting()); 375 GetDelegateForTesting());
374 ASSERT_TRUE(interstitial_page); 376 ASSERT_TRUE(interstitial_page);
375 interstitial_page->CommandReceived(command); 377 interstitial_page->CommandReceived(command);
376 } 378 }
377 379
378 void DontProceedThroughInterstitial() { 380 void DontProceedThroughInterstitial() {
379 WebContents* contents = chrome::GetActiveWebContents(browser()); 381 WebContents* contents =
382 browser()->tab_strip_model()->GetActiveWebContents();
380 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( 383 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage(
381 contents); 384 contents);
382 ASSERT_TRUE(interstitial_page); 385 ASSERT_TRUE(interstitial_page);
383 interstitial_page->DontProceed(); 386 interstitial_page->DontProceed();
384 } 387 }
385 388
386 void ProceedThroughInterstitial() { 389 void ProceedThroughInterstitial() {
387 WebContents* contents = chrome::GetActiveWebContents(browser()); 390 WebContents* contents =
391 browser()->tab_strip_model()->GetActiveWebContents();
388 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( 392 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage(
389 contents); 393 contents);
390 ASSERT_TRUE(interstitial_page); 394 ASSERT_TRUE(interstitial_page);
391 interstitial_page->Proceed(); 395 interstitial_page->Proceed();
392 } 396 }
393 397
394 void AssertNoInterstitial(bool wait_for_delete) { 398 void AssertNoInterstitial(bool wait_for_delete) {
395 WebContents* contents = chrome::GetActiveWebContents(browser()); 399 WebContents* contents =
400 browser()->tab_strip_model()->GetActiveWebContents();
396 401
397 if (contents->ShowingInterstitialPage() && wait_for_delete) { 402 if (contents->ShowingInterstitialPage() && wait_for_delete) {
398 // We'll get notified when the interstitial is deleted. 403 // We'll get notified when the interstitial is deleted.
399 TestSafeBrowsingBlockingPage* page = 404 TestSafeBrowsingBlockingPage* page =
400 static_cast<TestSafeBrowsingBlockingPage*>( 405 static_cast<TestSafeBrowsingBlockingPage*>(
401 contents->GetInterstitialPage()->GetDelegateForTesting()); 406 contents->GetInterstitialPage()->GetDelegateForTesting());
402 page->WaitForDelete(); 407 page->WaitForDelete();
403 } 408 }
404 409
405 // Can't use InterstitialPage::GetInterstitialPage() because that 410 // Can't use InterstitialPage::GetInterstitialPage() because that
406 // gets updated after the TestSafeBrowsingBlockingPage destructor 411 // gets updated after the TestSafeBrowsingBlockingPage destructor
407 ASSERT_FALSE(contents->ShowingInterstitialPage()); 412 ASSERT_FALSE(contents->ShowingInterstitialPage());
408 } 413 }
409 414
410 bool YesInterstitial() { 415 bool YesInterstitial() {
411 WebContents* contents = chrome::GetActiveWebContents(browser()); 416 WebContents* contents =
417 browser()->tab_strip_model()->GetActiveWebContents();
412 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( 418 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage(
413 contents); 419 contents);
414 return interstitial_page != NULL; 420 return interstitial_page != NULL;
415 } 421 }
416 422
417 void WaitForInterstitial() { 423 void WaitForInterstitial() {
418 WebContents* contents = chrome::GetActiveWebContents(browser()); 424 WebContents* contents =
425 browser()->tab_strip_model()->GetActiveWebContents();
419 content::WindowedNotificationObserver interstitial_observer( 426 content::WindowedNotificationObserver interstitial_observer(
420 content::NOTIFICATION_INTERSTITIAL_ATTACHED, 427 content::NOTIFICATION_INTERSTITIAL_ATTACHED,
421 content::Source<WebContents>(contents)); 428 content::Source<WebContents>(contents));
422 if (!InterstitialPage::GetInterstitialPage(contents)) 429 if (!InterstitialPage::GetInterstitialPage(contents))
423 interstitial_observer.Wait(); 430 interstitial_observer.Wait();
424 } 431 }
425 432
426 void AssertReportSent() { 433 void AssertReportSent() {
427 // When a report is scheduled in the IO thread we should get notified. 434 // When a report is scheduled in the IO thread we should get notified.
428 content::RunMessageLoop(); 435 content::RunMessageLoop();
(...skipping 18 matching lines...) Expand all
447 ui_test_utils::NavigateToURL(browser(), load_url); 454 ui_test_utils::NavigateToURL(browser(), load_url);
448 // Trigger the safe browsing interstitial page via a redirect in 455 // Trigger the safe browsing interstitial page via a redirect in
449 // "openWin()". 456 // "openWin()".
450 ui_test_utils::NavigateToURLWithDisposition( 457 ui_test_utils::NavigateToURLWithDisposition(
451 browser(), 458 browser(),
452 GURL("javascript:" + open_function + "()"), 459 GURL("javascript:" + open_function + "()"),
453 CURRENT_TAB, 460 CURRENT_TAB,
454 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 461 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
455 WaitForInterstitial(); 462 WaitForInterstitial();
456 // Cancel the redirect request while interstitial page is open. 463 // Cancel the redirect request while interstitial page is open.
457 chrome::ActivateTabAt(browser(), 0, true); 464 browser()->tab_strip_model()->ActivateTabAt(0, true);
458 ui_test_utils::NavigateToURLWithDisposition( 465 ui_test_utils::NavigateToURLWithDisposition(
459 browser(), 466 browser(),
460 GURL("javascript:stopWin()"), 467 GURL("javascript:stopWin()"),
461 CURRENT_TAB, 468 CURRENT_TAB,
462 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 469 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
463 chrome::ActivateTabAt(browser(), 1, true); 470 browser()->tab_strip_model()->ActivateTabAt(1, true);
464 // Simulate the user clicking "proceed", there should be no crash. Since 471 // Simulate the user clicking "proceed", there should be no crash. Since
465 // clicking proceed may do nothing (see comment in MalwareRedirectCanceled 472 // clicking proceed may do nothing (see comment in MalwareRedirectCanceled
466 // below, and crbug.com/76460), we use SendCommand to trigger the callback 473 // below, and crbug.com/76460), we use SendCommand to trigger the callback
467 // directly rather than using ClickAndWaitForDetach since there might not 474 // directly rather than using ClickAndWaitForDetach since there might not
468 // be a notification to wait for. 475 // be a notification to wait for.
469 SendCommand("\"proceed\""); 476 SendCommand("\"proceed\"");
470 } 477 }
471 478
472 content::RenderViewHost* GetRenderViewHost() { 479 content::RenderViewHost* GetRenderViewHost() {
473 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage( 480 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage(
474 chrome::GetActiveWebContents(browser())); 481 browser()->tab_strip_model()->GetActiveWebContents());
475 if (!interstitial) 482 if (!interstitial)
476 return NULL; 483 return NULL;
477 return interstitial->GetRenderViewHostForTesting(); 484 return interstitial->GetRenderViewHostForTesting();
478 } 485 }
479 486
480 bool WaitForReady() { 487 bool WaitForReady() {
481 content::RenderViewHost* rvh = GetRenderViewHost(); 488 content::RenderViewHost* rvh = GetRenderViewHost();
482 if (!rvh) 489 if (!rvh)
483 return false; 490 return false;
484 // Wait until all <script> tags have executed, including jstemplate. 491 // Wait until all <script> tags have executed, including jstemplate.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 ASCIIToUTF16("document.getElementById('" + node_id + "').click();\n")); 534 ASCIIToUTF16("document.getElementById('" + node_id + "').click();\n"));
528 return true; 535 return true;
529 } 536 }
530 537
531 bool ClickAndWaitForDetach(const std::string& node_id) { 538 bool ClickAndWaitForDetach(const std::string& node_id) {
532 // We wait for interstitial_detached rather than nav_entry_committed, as 539 // We wait for interstitial_detached rather than nav_entry_committed, as
533 // going back from a main-frame malware interstitial page will not cause a 540 // going back from a main-frame malware interstitial page will not cause a
534 // nav entry committed event. 541 // nav entry committed event.
535 content::WindowedNotificationObserver observer( 542 content::WindowedNotificationObserver observer(
536 content::NOTIFICATION_INTERSTITIAL_DETACHED, 543 content::NOTIFICATION_INTERSTITIAL_DETACHED,
537 content::Source<WebContents>(chrome::GetActiveWebContents(browser()))); 544 content::Source<WebContents>(
545 browser()->tab_strip_model()->GetActiveWebContents()));
538 if (!Click(node_id)) 546 if (!Click(node_id))
539 return false; 547 return false;
540 observer.Wait(); 548 observer.Wait();
541 return true; 549 return true;
542 } 550 }
543 551
544 protected: 552 protected:
545 TestMalwareDetailsFactory details_factory_; 553 TestMalwareDetailsFactory details_factory_;
546 554
547 private: 555 private:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 589 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
582 EXPECT_TRUE(Click("see-more-link")); 590 EXPECT_TRUE(Click("see-more-link"));
583 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 591 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
584 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 592 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
585 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 593 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
586 594
587 EXPECT_TRUE(ClickAndWaitForDetach("back")); 595 EXPECT_TRUE(ClickAndWaitForDetach("back"));
588 AssertNoInterstitial(false); // Assert the interstitial is gone 596 AssertNoInterstitial(false); // Assert the interstitial is gone
589 EXPECT_EQ( 597 EXPECT_EQ(
590 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 598 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
591 chrome::GetActiveWebContents(browser())->GetURL()); 599 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
592 } 600 }
593 601
594 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { 602 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) {
595 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 603 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
596 604
597 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 605 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
598 AssertNoInterstitial(true); // Assert the interstitial is gone. 606 AssertNoInterstitial(true); // Assert the interstitial is gone.
599 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 607 EXPECT_EQ(url,
608 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
600 } 609 }
601 610
602 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 611 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
603 MalwareLearnMore) { 612 MalwareLearnMore) {
604 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 613 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
605 614
606 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); 615 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
607 AssertNoInterstitial(false); // Assert the interstitial is gone 616 AssertNoInterstitial(false); // Assert the interstitial is gone
608 617
609 // We are in the help page. 618 // We are in the help page.
610 EXPECT_EQ( 619 EXPECT_EQ(
611 "/goodtoknow/online-safety/malware/", 620 "/goodtoknow/online-safety/malware/",
612 chrome::GetActiveWebContents(browser())->GetURL().path()); 621 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
613 } 622 }
614 623
615 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 624 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
616 MalwareIframeDontProceed) { 625 MalwareIframeDontProceed) {
617 SetupMalwareIframeWarningAndNavigate(); 626 SetupMalwareIframeWarningAndNavigate();
618 627
619 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); 628 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon"));
620 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); 629 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon"));
621 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); 630 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon"));
622 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 631 EXPECT_EQ(VISIBLE, GetVisibility("check-report"));
623 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 632 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
624 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 633 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
625 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 634 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
626 EXPECT_TRUE(Click("see-more-link")); 635 EXPECT_TRUE(Click("see-more-link"));
627 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 636 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
628 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 637 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
629 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 638 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
630 639
631 EXPECT_TRUE(ClickAndWaitForDetach("back")); 640 EXPECT_TRUE(ClickAndWaitForDetach("back"));
632 AssertNoInterstitial(false); // Assert the interstitial is gone 641 AssertNoInterstitial(false); // Assert the interstitial is gone
633 642
634 EXPECT_EQ( 643 EXPECT_EQ(
635 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 644 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
636 chrome::GetActiveWebContents(browser())->GetURL()); 645 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
637 } 646 }
638 647
639 // Crashy, http://crbug.com/68834. 648 // Crashy, http://crbug.com/68834.
640 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 649 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
641 DISABLED_MalwareIframeProceed) { 650 DISABLED_MalwareIframeProceed) {
642 GURL url = SetupMalwareIframeWarningAndNavigate(); 651 GURL url = SetupMalwareIframeWarningAndNavigate();
643 652
644 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 653 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
645 AssertNoInterstitial(true); // Assert the interstitial is gone 654 AssertNoInterstitial(true); // Assert the interstitial is gone
646 655
647 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 656 EXPECT_EQ(url,
657 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
648 } 658 }
649 659
650 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 660 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
651 MalwareIframeReportDetails) { 661 MalwareIframeReportDetails) {
652 GURL url = SetupMalwareIframeWarningAndNavigate(); 662 GURL url = SetupMalwareIframeWarningAndNavigate();
653 663
654 // If the DOM details from renderer did not already return, wait for them. 664 // If the DOM details from renderer did not already return, wait for them.
655 details_factory_.get_details()->WaitForDOM(); 665 details_factory_.get_details()->WaitForDOM();
656 666
657 EXPECT_TRUE(Click("check-report")); 667 EXPECT_TRUE(Click("check-report"));
658 668
659 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 669 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
660 AssertNoInterstitial(true); // Assert the interstitial is gone 670 AssertNoInterstitial(true); // Assert the interstitial is gone
661 671
662 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 672 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
663 prefs::kSafeBrowsingReportingEnabled)); 673 prefs::kSafeBrowsingReportingEnabled));
664 674
665 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 675 EXPECT_EQ(url,
676 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
666 AssertReportSent(); 677 AssertReportSent();
667 } 678 }
668 679
669 // Verifies that the "proceed anyway" link isn't available when it is disabled 680 // Verifies that the "proceed anyway" link isn't available when it is disabled
670 // by the corresponding policy. Also verifies that sending the "proceed" 681 // by the corresponding policy. Also verifies that sending the "proceed"
671 // command anyway doesn't advance to the malware site. 682 // command anyway doesn't advance to the malware site.
672 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) { 683 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) {
673 // Simulate a policy disabling the "proceed anyway" link. 684 // Simulate a policy disabling the "proceed anyway" link.
674 browser()->profile()->GetPrefs()->SetBoolean( 685 browser()->profile()->GetPrefs()->SetBoolean(
675 prefs::kSafeBrowsingProceedAnywayDisabled, true); 686 prefs::kSafeBrowsingProceedAnywayDisabled, true);
676 687
677 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 688 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
678 689
679 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 690 EXPECT_EQ(VISIBLE, GetVisibility("check-report"));
680 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 691 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
681 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 692 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
682 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); 693 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span"));
683 EXPECT_TRUE(Click("see-more-link")); 694 EXPECT_TRUE(Click("see-more-link"));
684 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 695 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
685 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 696 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
686 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); 697 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span"));
687 698
688 // The "proceed" command should go back instead, if proceeding is disabled. 699 // The "proceed" command should go back instead, if proceeding is disabled.
689 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 700 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
690 AssertNoInterstitial(true); 701 AssertNoInterstitial(true);
691 EXPECT_EQ( 702 EXPECT_EQ(
692 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 703 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
693 chrome::GetActiveWebContents(browser())->GetURL()); 704 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
694 } 705 }
695 706
696 // Verifies that the reporting checkbox is hidden on non-HTTP pages. 707 // Verifies that the reporting checkbox is hidden on non-HTTP pages.
697 // TODO(mattm): Should also verify that no report is sent, but there isn't a 708 // TODO(mattm): Should also verify that no report is sent, but there isn't a
698 // good way to do that in the current design. 709 // good way to do that in the current design.
699 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) { 710 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) {
700 browser()->profile()->GetPrefs()->SetBoolean( 711 browser()->profile()->GetPrefs()->SetBoolean(
701 prefs::kSafeBrowsingReportingEnabled, true); 712 prefs::kSafeBrowsingReportingEnabled, true);
702 713
703 net::TestServer https_server(net::TestServer::TYPE_HTTPS, 714 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
704 net::TestServer::kLocalhost, 715 net::TestServer::kLocalhost,
705 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 716 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
706 ASSERT_TRUE(https_server.Start()); 717 ASSERT_TRUE(https_server.Start());
707 GURL url = https_server.GetURL(kEmptyPage); 718 GURL url = https_server.GetURL(kEmptyPage);
708 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); 719 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE);
709 ui_test_utils::NavigateToURL(browser(), url); 720 ui_test_utils::NavigateToURL(browser(), url);
710 ASSERT_TRUE(WaitForReady()); 721 ASSERT_TRUE(WaitForReady());
711 722
712 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); 723 EXPECT_EQ(HIDDEN, GetVisibility("check-report"));
713 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 724 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
714 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 725 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
715 EXPECT_TRUE(Click("see-more-link")); 726 EXPECT_TRUE(Click("see-more-link"));
716 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 727 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
717 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 728 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
718 729
719 EXPECT_TRUE(ClickAndWaitForDetach("back")); 730 EXPECT_TRUE(ClickAndWaitForDetach("back"));
720 AssertNoInterstitial(false); // Assert the interstitial is gone 731 AssertNoInterstitial(false); // Assert the interstitial is gone
721 EXPECT_EQ( 732 EXPECT_EQ(
722 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 733 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
723 chrome::GetActiveWebContents(browser())->GetURL()); 734 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
724 } 735 }
725 736
726 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { 737 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) {
727 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 738 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
728 739
729 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); 740 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon"));
730 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); 741 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon"));
731 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); 742 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon"));
732 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); 743 EXPECT_EQ(HIDDEN, GetVisibility("check-report"));
733 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 744 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
734 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 745 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
735 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 746 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
736 EXPECT_TRUE(Click("see-more-link")); 747 EXPECT_TRUE(Click("see-more-link"));
737 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 748 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
738 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); 749 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link"));
739 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 750 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
740 751
741 EXPECT_TRUE(ClickAndWaitForDetach("back")); 752 EXPECT_TRUE(ClickAndWaitForDetach("back"));
742 AssertNoInterstitial(false); // Assert the interstitial is gone 753 AssertNoInterstitial(false); // Assert the interstitial is gone
743 EXPECT_EQ( 754 EXPECT_EQ(
744 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". 755 GURL(chrome::kAboutBlankURL), // We are back to "about:blank".
745 chrome::GetActiveWebContents(browser())->GetURL()); 756 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
746 } 757 }
747 758
748 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { 759 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) {
749 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 760 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
750 761
751 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 762 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
752 AssertNoInterstitial(true); // Assert the interstitial is gone 763 AssertNoInterstitial(true); // Assert the interstitial is gone
753 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 764 EXPECT_EQ(url,
765 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
754 } 766 }
755 767
756 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { 768 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) {
757 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 769 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
758 770
759 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); 771 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link"));
760 AssertNoInterstitial(false); // Assert the interstitial is gone 772 AssertNoInterstitial(false); // Assert the interstitial is gone
761 773
762 // We are in the error reporting page. 774 // We are in the error reporting page.
763 EXPECT_EQ( 775 EXPECT_EQ(
764 "/safebrowsing/report_error/", 776 "/safebrowsing/report_error/",
765 chrome::GetActiveWebContents(browser())->GetURL().path()); 777 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
766 } 778 }
767 779
768 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingLearnMore) { 780 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingLearnMore) {
769 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 781 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
770 782
771 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); 783 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
772 AssertNoInterstitial(false); // Assert the interstitial is gone 784 AssertNoInterstitial(false); // Assert the interstitial is gone
773 785
774 // We are in the help page. 786 // We are in the help page.
775 EXPECT_EQ( 787 EXPECT_EQ(
776 "/goodtoknow/online-safety/phishing/", 788 "/goodtoknow/online-safety/phishing/",
777 chrome::GetActiveWebContents(browser())->GetURL().path()); 789 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
778 } 790 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/web_cache_manager_browsertest.cc ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698