| 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 // |
| 10 // TODO(mattm): remove / merge this file with |
| 11 // safe_browsing_blocking_page_test.cc once the SBInterstitial field trial |
| 12 // finishes. |
| 9 | 13 |
| 10 #include "base/bind.h" | 14 #include "base/bind.h" |
| 11 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 16 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/safe_browsing/malware_details.h" | 20 #include "chrome/browser/safe_browsing/malware_details.h" |
| 17 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 180 |
| 177 FakeMalwareDetails* get_details() { | 181 FakeMalwareDetails* get_details() { |
| 178 return details_; | 182 return details_; |
| 179 } | 183 } |
| 180 | 184 |
| 181 private: | 185 private: |
| 182 FakeMalwareDetails* details_; | 186 FakeMalwareDetails* details_; |
| 183 }; | 187 }; |
| 184 | 188 |
| 185 // A SafeBrowingBlockingPage class that lets us wait until it's hidden. | 189 // A SafeBrowingBlockingPage class that lets us wait until it's hidden. |
| 186 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { | 190 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPageV2 { |
| 187 public: | 191 public: |
| 188 TestSafeBrowsingBlockingPage(SafeBrowsingService* service, | 192 TestSafeBrowsingBlockingPage(SafeBrowsingService* service, |
| 189 WebContents* web_contents, | 193 WebContents* web_contents, |
| 190 const UnsafeResourceList& unsafe_resources) | 194 const UnsafeResourceList& unsafe_resources) |
| 191 : SafeBrowsingBlockingPage(service, web_contents, unsafe_resources), | 195 : SafeBrowsingBlockingPageV2(service, web_contents, unsafe_resources), |
| 192 wait_for_delete_(false) { | 196 wait_for_delete_(false) { |
| 193 // Don't wait the whole 3 seconds for the browser test. | 197 // Don't wait the whole 3 seconds for the browser test. |
| 194 malware_details_proceed_delay_ms_ = 100; | 198 malware_details_proceed_delay_ms_ = 100; |
| 195 } | 199 } |
| 196 | 200 |
| 197 ~TestSafeBrowsingBlockingPage() { | 201 ~TestSafeBrowsingBlockingPage() { |
| 198 if (!wait_for_delete_) | 202 if (!wait_for_delete_) |
| 199 return; | 203 return; |
| 200 | 204 |
| 201 // Notify that we are gone | 205 // Notify that we are gone |
| (...skipping 22 matching lines...) Expand all Loading... |
| 224 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 228 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 225 OVERRIDE { | 229 OVERRIDE { |
| 226 return new TestSafeBrowsingBlockingPage(service, web_contents, | 230 return new TestSafeBrowsingBlockingPage(service, web_contents, |
| 227 unsafe_resources); | 231 unsafe_resources); |
| 228 } | 232 } |
| 229 }; | 233 }; |
| 230 | 234 |
| 231 } // namespace | 235 } // namespace |
| 232 | 236 |
| 233 // Tests the safe browsing blocking page in a browser. | 237 // Tests the safe browsing blocking page in a browser. |
| 234 class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { | 238 class SafeBrowsingBlockingPageV2Test : public InProcessBrowserTest { |
| 235 public: | 239 public: |
| 236 SafeBrowsingBlockingPageTest() { | 240 SafeBrowsingBlockingPageV2Test() { |
| 237 } | 241 } |
| 238 | 242 |
| 239 virtual void SetUp() OVERRIDE { | 243 virtual void SetUp() OVERRIDE { |
| 240 SafeBrowsingService::RegisterFactory(&factory_); | 244 SafeBrowsingService::RegisterFactory(&factory_); |
| 241 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_); | 245 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_); |
| 242 MalwareDetails::RegisterFactory(&details_factory_); | 246 MalwareDetails::RegisterFactory(&details_factory_); |
| 243 InProcessBrowserTest::SetUp(); | 247 InProcessBrowserTest::SetUp(); |
| 244 } | 248 } |
| 245 | 249 |
| 246 virtual void TearDown() OVERRIDE { | 250 virtual void TearDown() OVERRIDE { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( | 387 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( |
| 384 string16(), | 388 string16(), |
| 385 ASCIIToUTF16( | 389 ASCIIToUTF16( |
| 386 // Make sure jstemplate has processed the page. | 390 // Make sure jstemplate has processed the page. |
| 387 // TODO(joaodasilva): it would be better to make sure all the | 391 // TODO(joaodasilva): it would be better to make sure all the |
| 388 // <script> tags have executed before injecting more javascript. | 392 // <script> tags have executed before injecting more javascript. |
| 389 "var root = document.getElementById('template_root');\n" | 393 "var root = document.getElementById('template_root');\n" |
| 390 "jstProcess(new JsEvalContext(templateData), root);\n" | 394 "jstProcess(new JsEvalContext(templateData), root);\n" |
| 391 // Now inspect the "proceed anyway" <div>. | 395 // Now inspect the "proceed anyway" <div>. |
| 392 "var list = document.querySelectorAll(" | 396 "var list = document.querySelectorAll(" |
| 393 " 'div[jsdisplay=\"!proceedDisabled\"]');\n" | 397 " 'span[jsdisplay=\"!proceedDisabled\"]');\n" |
| 394 "if (list.length == 1)\n" | 398 "if (list.length == 1)\n" |
| 395 " list[0].style.display === 'none';\n" | 399 " list[0].style.display === 'none';\n" |
| 396 "else\n" | 400 "else\n" |
| 397 " 'Fail with non-boolean result value';\n"))); | 401 " 'Fail with non-boolean result value';\n"))); |
| 398 if (!value.get()) | 402 if (!value.get()) |
| 399 return false; | 403 return false; |
| 400 return value->GetAsBoolean(result); | 404 return value->GetAsBoolean(result); |
| 401 } | 405 } |
| 402 | 406 |
| 403 protected: | 407 protected: |
| 404 TestMalwareDetailsFactory details_factory_; | 408 TestMalwareDetailsFactory details_factory_; |
| 405 | 409 |
| 406 private: | 410 private: |
| 407 TestSafeBrowsingServiceFactory factory_; | 411 TestSafeBrowsingServiceFactory factory_; |
| 408 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; | 412 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; |
| 409 | 413 |
| 410 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest); | 414 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2Test); |
| 411 }; | 415 }; |
| 412 | 416 |
| 413 const char kEmptyPage[] = "files/empty.html"; | 417 const char kEmptyPage[] = "files/empty.html"; |
| 414 const char kMalwarePage[] = "files/safe_browsing/malware.html"; | 418 const char kMalwarePage[] = "files/safe_browsing/malware.html"; |
| 415 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; | 419 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; |
| 416 | 420 |
| 417 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 421 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 418 MalwareRedirectInIFrameCanceled) { | 422 MalwareRedirectInIFrameCanceled) { |
| 419 // 1. Test the case that redirect is a subresource. | 423 // 1. Test the case that redirect is a subresource. |
| 420 MalwareRedirectCancelAndProceed("openWinIFrame"); | 424 MalwareRedirectCancelAndProceed("openWinIFrame"); |
| 421 // If the redirect was from subresource but canceled, "proceed" will continue | 425 // If the redirect was from subresource but canceled, "proceed" will continue |
| 422 // with the rest of resources. | 426 // with the rest of resources. |
| 423 AssertNoInterstitial(true); | 427 AssertNoInterstitial(true); |
| 424 } | 428 } |
| 425 | 429 |
| 426 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareRedirectCanceled) { | 430 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 431 MalwareRedirectCanceled) { |
| 427 // 2. Test the case that redirect is the only resource. | 432 // 2. Test the case that redirect is the only resource. |
| 428 MalwareRedirectCancelAndProceed("openWin"); | 433 MalwareRedirectCancelAndProceed("openWin"); |
| 429 // Clicking proceed won't do anything if the main request is cancelled | 434 // Clicking proceed won't do anything if the main request is cancelled |
| 430 // already. See crbug.com/76460. | 435 // already. See crbug.com/76460. |
| 431 EXPECT_TRUE(YesInterstitial()); | 436 EXPECT_TRUE(YesInterstitial()); |
| 432 } | 437 } |
| 433 | 438 |
| 434 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { | 439 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) { |
| 435 GURL url = test_server()->GetURL(kEmptyPage); | 440 GURL url = test_server()->GetURL(kEmptyPage); |
| 436 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 441 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 437 | 442 |
| 438 ui_test_utils::NavigateToURL(browser(), url); | 443 ui_test_utils::NavigateToURL(browser(), url); |
| 439 | 444 |
| 440 bool hidden = false; | 445 bool hidden = false; |
| 441 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); | 446 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); |
| 442 EXPECT_FALSE(hidden); | 447 EXPECT_FALSE(hidden); |
| 443 | 448 |
| 444 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 449 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
| 445 AssertNoInterstitial(false); // Assert the interstitial is gone | 450 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 446 EXPECT_EQ( | 451 EXPECT_EQ( |
| 447 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 452 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 448 chrome::GetActiveWebContents(browser())->GetURL()); | 453 chrome::GetActiveWebContents(browser())->GetURL()); |
| 449 } | 454 } |
| 450 | 455 |
| 451 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 456 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) { |
| 452 GURL url = test_server()->GetURL(kEmptyPage); | 457 GURL url = test_server()->GetURL(kEmptyPage); |
| 453 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 458 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 454 | 459 |
| 455 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 460 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 456 // event that clears the interstitial. We wait for DidNavigate instead. | 461 // event that clears the interstitial. We wait for DidNavigate instead. |
| 457 ui_test_utils::NavigateToURL(browser(), url); | 462 ui_test_utils::NavigateToURL(browser(), url); |
| 458 content::WindowedNotificationObserver observer( | 463 content::WindowedNotificationObserver observer( |
| 459 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 464 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 460 content::Source<NavigationController>( | 465 content::Source<NavigationController>( |
| 461 &chrome::GetActiveWebContents(browser())->GetController())); | 466 &chrome::GetActiveWebContents(browser())->GetController())); |
| 462 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 467 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
| 463 observer.Wait(); | 468 observer.Wait(); |
| 464 AssertNoInterstitial(true); // Assert the interstitial is gone. | 469 AssertNoInterstitial(true); // Assert the interstitial is gone. |
| 465 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 470 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 466 } | 471 } |
| 467 | 472 |
| 468 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { | 473 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 474 MalwareLearnMore) { |
| 469 GURL url = test_server()->GetURL(kEmptyPage); | 475 GURL url = test_server()->GetURL(kEmptyPage); |
| 470 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 476 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 471 | 477 |
| 472 ui_test_utils::NavigateToURL(browser(), url); | 478 ui_test_utils::NavigateToURL(browser(), url); |
| 473 | 479 |
| 474 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" | |
| 475 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 476 EXPECT_EQ( | |
| 477 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". | |
| 478 chrome::GetActiveWebContents(browser())->GetURL()); | |
| 479 } | |
| 480 | |
| 481 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { | |
| 482 GURL url = test_server()->GetURL(kEmptyPage); | |
| 483 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 484 | |
| 485 ui_test_utils::NavigateToURL(browser(), url); | |
| 486 | |
| 487 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | |
| 488 // event that clears the interstitial. We wait for DidNavigate instead. | |
| 489 content::WindowedNotificationObserver observer( | |
| 490 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 491 content::Source<NavigationController>( | |
| 492 &chrome::GetActiveWebContents(browser())->GetController())); | |
| 493 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". | |
| 494 observer.Wait(); | |
| 495 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 496 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | |
| 497 } | |
| 498 | |
| 499 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { | |
| 500 GURL url = test_server()->GetURL(kEmptyPage); | |
| 501 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 502 | |
| 503 ui_test_utils::NavigateToURL(browser(), url); | |
| 504 | |
| 505 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | |
| 506 // event that clears the interstitial. We wait for DidNavigate instead. | |
| 507 content::WindowedNotificationObserver observer( | |
| 508 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 509 content::Source<NavigationController>( | |
| 510 &chrome::GetActiveWebContents(browser())->GetController())); | |
| 511 SendCommand("\"reportError\""); // Simulate the user clicking "report error" | |
| 512 observer.Wait(); | |
| 513 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 514 | |
| 515 // We are in the error reporting page. | |
| 516 EXPECT_EQ( | |
| 517 "/safebrowsing/report_error/", | |
| 518 chrome::GetActiveWebContents(browser())->GetURL().path()); | |
| 519 } | |
| 520 | |
| 521 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | |
| 522 PhishingLearnMore) { | |
| 523 GURL url = test_server()->GetURL(kEmptyPage); | |
| 524 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 525 | |
| 526 ui_test_utils::NavigateToURL(browser(), url); | |
| 527 | |
| 528 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 480 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 529 // event that clears the interstitial. We wait for DidNavigate instead. | 481 // event that clears the interstitial. We wait for DidNavigate instead. |
| 530 content::WindowedNotificationObserver observer( | 482 content::WindowedNotificationObserver observer( |
| 531 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 483 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 532 content::Source<NavigationController>( | 484 content::Source<NavigationController>( |
| 533 &chrome::GetActiveWebContents(browser())->GetController())); | 485 &chrome::GetActiveWebContents(browser())->GetController())); |
| 534 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" | 486 SendCommand("\"learnMore2\""); // Simulate the user clicking "learn more" |
| 535 observer.Wait(); | 487 observer.Wait(); |
| 536 AssertNoInterstitial(false); // Assert the interstitial is gone | 488 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 537 | 489 |
| 538 // We are in the help page. | 490 // We are in the help page. |
| 539 EXPECT_EQ( | 491 EXPECT_EQ( |
| 540 "/support/bin/answer.py", | 492 "/goodtoknow/online-safety/malware/", |
| 541 chrome::GetActiveWebContents(browser())->GetURL().path()); | 493 chrome::GetActiveWebContents(browser())->GetURL().path()); |
| 542 } | 494 } |
| 543 | 495 |
| 544 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { | 496 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 497 MalwareIframeDontProceed) { |
| 545 GURL url = test_server()->GetURL(kMalwarePage); | 498 GURL url = test_server()->GetURL(kMalwarePage); |
| 546 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 499 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 547 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 500 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 548 | 501 |
| 549 ui_test_utils::NavigateToURL(browser(), url); | 502 ui_test_utils::NavigateToURL(browser(), url); |
| 550 | 503 |
| 551 content::WindowedNotificationObserver observer( | 504 content::WindowedNotificationObserver observer( |
| 552 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 505 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 553 content::Source<NavigationController>( | 506 content::Source<NavigationController>( |
| 554 &chrome::GetActiveWebContents(browser())->GetController())); | 507 &chrome::GetActiveWebContents(browser())->GetController())); |
| 555 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 508 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
| 556 observer.Wait(); | 509 observer.Wait(); |
| 557 AssertNoInterstitial(false); // Assert the interstitial is gone | 510 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 558 | 511 |
| 559 EXPECT_EQ( | 512 EXPECT_EQ( |
| 560 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 513 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 561 chrome::GetActiveWebContents(browser())->GetURL()); | 514 chrome::GetActiveWebContents(browser())->GetURL()); |
| 562 } | 515 } |
| 563 | 516 |
| 564 // Crashy, http://crbug.com/68834. | 517 // Crashy, http://crbug.com/68834. |
| 565 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 518 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 566 DISABLED_MalwareIframeProceed) { | 519 DISABLED_MalwareIframeProceed) { |
| 567 GURL url = test_server()->GetURL(kMalwarePage); | 520 GURL url = test_server()->GetURL(kMalwarePage); |
| 568 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 521 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 569 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 522 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 570 | 523 |
| 571 ui_test_utils::NavigateToURL(browser(), url); | 524 ui_test_utils::NavigateToURL(browser(), url); |
| 572 | 525 |
| 573 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 526 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
| 574 AssertNoInterstitial(true); // Assert the interstitial is gone | 527 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 575 | 528 |
| 576 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 529 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 577 } | 530 } |
| 578 | 531 |
| 579 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 532 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 580 MalwareIframeReportDetails) { | 533 MalwareIframeReportDetails) { |
| 581 GURL url = test_server()->GetURL(kMalwarePage); | 534 GURL url = test_server()->GetURL(kMalwarePage); |
| 582 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 535 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 583 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 536 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 584 | 537 |
| 585 ui_test_utils::NavigateToURL(browser(), url); | 538 ui_test_utils::NavigateToURL(browser(), url); |
| 586 | 539 |
| 587 // If the DOM details from renderer did not already return, wait for them. | 540 // If the DOM details from renderer did not already return, wait for them. |
| 588 details_factory_.get_details()->WaitForDOM(); | 541 details_factory_.get_details()->WaitForDOM(); |
| 589 | 542 |
| 590 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. | 543 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. |
| 591 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 544 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
| 592 prefs::kSafeBrowsingReportingEnabled)); | 545 prefs::kSafeBrowsingReportingEnabled)); |
| 593 | 546 |
| 594 SendCommand("\"proceed\""); // Simulate the user clicking "back" | 547 SendCommand("\"proceed\""); // Simulate the user clicking "back" |
| 595 AssertNoInterstitial(true); // Assert the interstitial is gone | 548 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 596 | 549 |
| 597 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 550 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 598 AssertReportSent(); | 551 AssertReportSent(); |
| 599 } | 552 } |
| 600 | 553 |
| 601 // Verifies that the "proceed anyway" link isn't available when it is disabled | 554 // Verifies that the "proceed anyway" link isn't available when it is disabled |
| 602 // by the corresponding policy. Also verifies that sending the "proceed" | 555 // by the corresponding policy. Also verifies that sending the "proceed" |
| 603 // command anyway doesn't advance to the malware site. | 556 // command anyway doesn't advance to the malware site. |
| 604 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) { | 557 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ProceedDisabled) { |
| 605 // Simulate a policy disabling the "proceed anyway" link. | 558 // Simulate a policy disabling the "proceed anyway" link. |
| 606 browser()->profile()->GetPrefs()->SetBoolean( | 559 browser()->profile()->GetPrefs()->SetBoolean( |
| 607 prefs::kSafeBrowsingProceedAnywayDisabled, true); | 560 prefs::kSafeBrowsingProceedAnywayDisabled, true); |
| 608 | 561 |
| 609 GURL url = test_server()->GetURL(kEmptyPage); | 562 GURL url = test_server()->GetURL(kEmptyPage); |
| 610 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 563 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 611 ui_test_utils::NavigateToURL(browser(), url); | 564 ui_test_utils::NavigateToURL(browser(), url); |
| 612 | 565 |
| 613 // The "proceed anyway" link should be hidden. | 566 // The "proceed anyway" link should be hidden. |
| 614 bool hidden = false; | 567 bool hidden = false; |
| 615 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); | 568 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); |
| 616 EXPECT_TRUE(hidden); | 569 EXPECT_TRUE(hidden); |
| 617 | 570 |
| 618 // The "proceed" command should go back instead, if proceeding is disabled. | 571 // The "proceed" command should go back instead, if proceeding is disabled. |
| 619 SendCommand("\"proceed\""); | 572 SendCommand("\"proceed\""); |
| 620 AssertNoInterstitial(true); | 573 AssertNoInterstitial(true); |
| 621 EXPECT_EQ( | 574 EXPECT_EQ( |
| 622 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 575 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 623 chrome::GetActiveWebContents(browser())->GetURL()); | 576 chrome::GetActiveWebContents(browser())->GetURL()); |
| 624 } | 577 } |
| OLD | NEW |