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

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

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 416
417 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { 417 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) {
418 GURL url = test_server()->GetURL(kEmptyPage); 418 GURL url = test_server()->GetURL(kEmptyPage);
419 AddURLResult(url, SafeBrowsingService::URL_MALWARE); 419 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
420 420
421 ui_test_utils::NavigateToURL(browser(), url); 421 ui_test_utils::NavigateToURL(browser(), url);
422 ui_test_utils::WindowedNotificationObserver observer( 422 ui_test_utils::WindowedNotificationObserver observer(
423 content::NOTIFICATION_LOAD_STOP, 423 content::NOTIFICATION_LOAD_STOP,
424 content::Source<NavigationController>( 424 content::Source<NavigationController>(
425 &browser()->GetSelectedTabContentsWrapper()->controller())); 425 &browser()->GetSelectedTabContentsWrapper()->tab_contents()->
426 controller()));
426 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" 427 SendCommand("\"proceed\""); // Simulate the user clicking "proceed"
427 observer.Wait(); 428 observer.Wait();
428 AssertNoInterstitial(true); // Assert the interstitial is gone. 429 AssertNoInterstitial(true); // Assert the interstitial is gone.
429 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 430 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
430 } 431 }
431 432
432 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { 433 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) {
433 GURL url = test_server()->GetURL(kEmptyPage); 434 GURL url = test_server()->GetURL(kEmptyPage);
434 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 435 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
435 436
436 ui_test_utils::NavigateToURL(browser(), url); 437 ui_test_utils::NavigateToURL(browser(), url);
437 438
438 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" 439 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed"
439 AssertNoInterstitial(false); // Assert the interstitial is gone 440 AssertNoInterstitial(false); // Assert the interstitial is gone
440 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // We are back to "about:blank". 441 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // We are back to "about:blank".
441 browser()->GetSelectedTabContents()->GetURL()); 442 browser()->GetSelectedTabContents()->GetURL());
442 } 443 }
443 444
444 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { 445 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) {
445 GURL url = test_server()->GetURL(kEmptyPage); 446 GURL url = test_server()->GetURL(kEmptyPage);
446 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 447 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
447 448
448 ui_test_utils::NavigateToURL(browser(), url); 449 ui_test_utils::NavigateToURL(browser(), url);
449 450
450 ui_test_utils::WindowedNotificationObserver observer( 451 ui_test_utils::WindowedNotificationObserver observer(
451 content::NOTIFICATION_LOAD_STOP, 452 content::NOTIFICATION_LOAD_STOP,
452 content::Source<NavigationController>( 453 content::Source<NavigationController>(
453 &browser()->GetSelectedTabContentsWrapper()->controller())); 454 &browser()->GetSelectedTabContentsWrapper()->tab_contents()->
455 controller()));
454 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". 456 SendCommand("\"proceed\""); // Simulate the user clicking "proceed".
455 observer.Wait(); 457 observer.Wait();
456 AssertNoInterstitial(true); // Assert the interstitial is gone 458 AssertNoInterstitial(true); // Assert the interstitial is gone
457 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 459 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
458 } 460 }
459 461
460 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { 462 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) {
461 GURL url = test_server()->GetURL(kEmptyPage); 463 GURL url = test_server()->GetURL(kEmptyPage);
462 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 464 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
463 465
464 ui_test_utils::NavigateToURL(browser(), url); 466 ui_test_utils::NavigateToURL(browser(), url);
465 467
466 ui_test_utils::WindowedNotificationObserver observer( 468 ui_test_utils::WindowedNotificationObserver observer(
467 content::NOTIFICATION_LOAD_STOP, 469 content::NOTIFICATION_LOAD_STOP,
468 content::Source<NavigationController>( 470 content::Source<NavigationController>(
469 &browser()->GetSelectedTabContentsWrapper()->controller())); 471 &browser()->GetSelectedTabContentsWrapper()->tab_contents()->
472 controller()));
470 SendCommand("\"reportError\""); // Simulate the user clicking "report error" 473 SendCommand("\"reportError\""); // Simulate the user clicking "report error"
471 observer.Wait(); 474 observer.Wait();
472 AssertNoInterstitial(false); // Assert the interstitial is gone 475 AssertNoInterstitial(false); // Assert the interstitial is gone
473 476
474 // We are in the error reporting page. 477 // We are in the error reporting page.
475 EXPECT_EQ("/safebrowsing/report_error/", 478 EXPECT_EQ("/safebrowsing/report_error/",
476 browser()->GetSelectedTabContents()->GetURL().path()); 479 browser()->GetSelectedTabContents()->GetURL().path());
477 } 480 }
478 481
479 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 482 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
480 PhishingLearnMore) { 483 PhishingLearnMore) {
481 GURL url = test_server()->GetURL(kEmptyPage); 484 GURL url = test_server()->GetURL(kEmptyPage);
482 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 485 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
483 486
484 ui_test_utils::NavigateToURL(browser(), url); 487 ui_test_utils::NavigateToURL(browser(), url);
485 488
486 ui_test_utils::WindowedNotificationObserver observer( 489 ui_test_utils::WindowedNotificationObserver observer(
487 content::NOTIFICATION_LOAD_STOP, 490 content::NOTIFICATION_LOAD_STOP,
488 content::Source<NavigationController>( 491 content::Source<NavigationController>(
489 &browser()->GetSelectedTabContentsWrapper()->controller())); 492 &browser()->GetSelectedTabContentsWrapper()->tab_contents()->
493 controller()));
490 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" 494 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more"
491 observer.Wait(); 495 observer.Wait();
492 AssertNoInterstitial(false); // Assert the interstitial is gone 496 AssertNoInterstitial(false); // Assert the interstitial is gone
493 497
494 // We are in the help page. 498 // We are in the help page.
495 EXPECT_EQ("/support/bin/answer.py", 499 EXPECT_EQ("/support/bin/answer.py",
496 browser()->GetSelectedTabContents()->GetURL().path()); 500 browser()->GetSelectedTabContents()->GetURL().path());
497 } 501 }
498 502
499 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { 503 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 prefs::kSafeBrowsingReportingEnabled)); 553 prefs::kSafeBrowsingReportingEnabled));
550 554
551 SendCommand("\"proceed\""); // Simulate the user clicking "back" 555 SendCommand("\"proceed\""); // Simulate the user clicking "back"
552 AssertNoInterstitial(true); // Assert the interstitial is gone 556 AssertNoInterstitial(true); // Assert the interstitial is gone
553 557
554 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 558 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
555 AssertReportSent(); 559 AssertReportSent();
556 } 560 }
557 561
558 } // namespace 562 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_tab_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698