| OLD | NEW |
| 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" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 AssertNoInterstitial(false); // Assert the interstitial is gone | 421 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 422 EXPECT_EQ( | 422 EXPECT_EQ( |
| 423 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 423 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 424 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); | 424 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); |
| 425 } | 425 } |
| 426 | 426 |
| 427 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 427 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { |
| 428 GURL url = test_server()->GetURL(kEmptyPage); | 428 GURL url = test_server()->GetURL(kEmptyPage); |
| 429 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 429 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 430 | 430 |
| 431 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 432 // event that clears the interstitial. We wait for DidNavigate instead. |
| 431 ui_test_utils::NavigateToURL(browser(), url); | 433 ui_test_utils::NavigateToURL(browser(), url); |
| 432 ui_test_utils::WindowedNotificationObserver observer( | 434 ui_test_utils::WindowedNotificationObserver observer( |
| 433 content::NOTIFICATION_LOAD_STOP, | 435 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 434 content::Source<NavigationController>( | 436 content::Source<NavigationController>( |
| 435 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 437 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 436 GetController())); | 438 GetController())); |
| 437 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 439 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
| 438 observer.Wait(); | 440 observer.Wait(); |
| 439 AssertNoInterstitial(true); // Assert the interstitial is gone. | 441 AssertNoInterstitial(true); // Assert the interstitial is gone. |
| 440 EXPECT_EQ( | 442 EXPECT_EQ( |
| 441 url, | 443 url, |
| 442 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); | 444 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); |
| 443 } | 445 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 454 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". | 456 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". |
| 455 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); | 457 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); |
| 456 } | 458 } |
| 457 | 459 |
| 458 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { | 460 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { |
| 459 GURL url = test_server()->GetURL(kEmptyPage); | 461 GURL url = test_server()->GetURL(kEmptyPage); |
| 460 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 462 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
| 461 | 463 |
| 462 ui_test_utils::NavigateToURL(browser(), url); | 464 ui_test_utils::NavigateToURL(browser(), url); |
| 463 | 465 |
| 466 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 467 // event that clears the interstitial. We wait for DidNavigate instead. |
| 464 ui_test_utils::WindowedNotificationObserver observer( | 468 ui_test_utils::WindowedNotificationObserver observer( |
| 465 content::NOTIFICATION_LOAD_STOP, | 469 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 466 content::Source<NavigationController>( | 470 content::Source<NavigationController>( |
| 467 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 471 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 468 GetController())); | 472 GetController())); |
| 469 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". | 473 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". |
| 470 observer.Wait(); | 474 observer.Wait(); |
| 471 AssertNoInterstitial(true); // Assert the interstitial is gone | 475 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 472 EXPECT_EQ( | 476 EXPECT_EQ( |
| 473 url, | 477 url, |
| 474 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); | 478 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); |
| 475 } | 479 } |
| 476 | 480 |
| 477 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { | 481 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { |
| 478 GURL url = test_server()->GetURL(kEmptyPage); | 482 GURL url = test_server()->GetURL(kEmptyPage); |
| 479 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 483 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
| 480 | 484 |
| 481 ui_test_utils::NavigateToURL(browser(), url); | 485 ui_test_utils::NavigateToURL(browser(), url); |
| 482 | 486 |
| 487 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 488 // event that clears the interstitial. We wait for DidNavigate instead. |
| 483 ui_test_utils::WindowedNotificationObserver observer( | 489 ui_test_utils::WindowedNotificationObserver observer( |
| 484 content::NOTIFICATION_LOAD_STOP, | 490 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 485 content::Source<NavigationController>( | 491 content::Source<NavigationController>( |
| 486 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 492 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 487 GetController())); | 493 GetController())); |
| 488 SendCommand("\"reportError\""); // Simulate the user clicking "report error" | 494 SendCommand("\"reportError\""); // Simulate the user clicking "report error" |
| 489 observer.Wait(); | 495 observer.Wait(); |
| 490 AssertNoInterstitial(false); // Assert the interstitial is gone | 496 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 491 | 497 |
| 492 // We are in the error reporting page. | 498 // We are in the error reporting page. |
| 493 EXPECT_EQ( | 499 EXPECT_EQ( |
| 494 "/safebrowsing/report_error/", | 500 "/safebrowsing/report_error/", |
| 495 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL(). | 501 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL(). |
| 496 path()); | 502 path()); |
| 497 } | 503 } |
| 498 | 504 |
| 499 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 505 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
| 500 PhishingLearnMore) { | 506 PhishingLearnMore) { |
| 501 GURL url = test_server()->GetURL(kEmptyPage); | 507 GURL url = test_server()->GetURL(kEmptyPage); |
| 502 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 508 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
| 503 | 509 |
| 504 ui_test_utils::NavigateToURL(browser(), url); | 510 ui_test_utils::NavigateToURL(browser(), url); |
| 505 | 511 |
| 512 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 513 // event that clears the interstitial. We wait for DidNavigate instead. |
| 506 ui_test_utils::WindowedNotificationObserver observer( | 514 ui_test_utils::WindowedNotificationObserver observer( |
| 507 content::NOTIFICATION_LOAD_STOP, | 515 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 508 content::Source<NavigationController>( | 516 content::Source<NavigationController>( |
| 509 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 517 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 510 GetController())); | 518 GetController())); |
| 511 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" | 519 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" |
| 512 observer.Wait(); | 520 observer.Wait(); |
| 513 AssertNoInterstitial(false); // Assert the interstitial is gone | 521 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 514 | 522 |
| 515 // We are in the help page. | 523 // We are in the help page. |
| 516 EXPECT_EQ( | 524 EXPECT_EQ( |
| 517 "/support/bin/answer.py", | 525 "/support/bin/answer.py", |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 SendCommand("\"proceed\""); // Simulate the user clicking "back" | 591 SendCommand("\"proceed\""); // Simulate the user clicking "back" |
| 584 AssertNoInterstitial(true); // Assert the interstitial is gone | 592 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 585 | 593 |
| 586 EXPECT_EQ( | 594 EXPECT_EQ( |
| 587 url, | 595 url, |
| 588 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); | 596 browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); |
| 589 AssertReportSent(); | 597 AssertReportSent(); |
| 590 } | 598 } |
| 591 | 599 |
| 592 } // namespace | 600 } // namespace |
| OLD | NEW |