| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in | 388 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in |
| 385 // practice it spins at most once or twice. | 389 // practice it spins at most once or twice. |
| 386 std::string ready_state; | 390 std::string ready_state; |
| 387 do { | 391 do { |
| 388 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( | 392 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( |
| 389 string16(), | 393 string16(), |
| 390 ASCIIToUTF16("document.readyState"))); | 394 ASCIIToUTF16("document.readyState"))); |
| 391 if (!value.get() || !value->GetAsString(&ready_state)) | 395 if (!value.get() || !value->GetAsString(&ready_state)) |
| 392 return false; | 396 return false; |
| 393 } while (ready_state != "complete"); | 397 } while (ready_state != "complete"); |
| 394 // Now get the display style for the "proceed anyway" <div>. | 398 // Now check hidden state of the "proceed anyway" <span>. |
| 395 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( | 399 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( |
| 396 string16(), | 400 string16(), |
| 397 ASCIIToUTF16( | 401 ASCIIToUTF16( |
| 398 "var list = document.querySelectorAll(" | 402 "var element = document.getElementById('proceed-span');\n" |
| 399 " 'div[jsdisplay=\"!proceedDisabled\"]');\n" | 403 "if (element !== null)\n" |
| 400 "if (list.length == 1)\n" | 404 " element.hidden;\n" |
| 401 " list[0].style.display === 'none';\n" | |
| 402 "else\n" | 405 "else\n" |
| 403 " 'Fail with non-boolean result value';\n"))); | 406 " 'Fail with non-boolean result value';\n"))); |
| 404 if (!value.get()) | 407 if (!value.get()) |
| 405 return false; | 408 return false; |
| 406 return value->GetAsBoolean(result); | 409 return value->GetAsBoolean(result); |
| 407 } | 410 } |
| 408 | 411 |
| 409 protected: | 412 protected: |
| 410 TestMalwareDetailsFactory details_factory_; | 413 TestMalwareDetailsFactory details_factory_; |
| 411 | 414 |
| 412 private: | 415 private: |
| 413 TestSafeBrowsingServiceFactory factory_; | 416 TestSafeBrowsingServiceFactory factory_; |
| 414 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; | 417 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; |
| 415 | 418 |
| 416 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest); | 419 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2Test); |
| 417 }; | 420 }; |
| 418 | 421 |
| 419 const char kEmptyPage[] = "files/empty.html"; | 422 const char kEmptyPage[] = "files/empty.html"; |
| 420 const char kMalwarePage[] = "files/safe_browsing/malware.html"; | 423 const char kMalwarePage[] = "files/safe_browsing/malware.html"; |
| 421 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; | 424 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; |
| 422 | 425 |
| 423 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 426 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 424 MalwareRedirectInIFrameCanceled) { | 427 MalwareRedirectInIFrameCanceled) { |
| 425 // 1. Test the case that redirect is a subresource. | 428 // 1. Test the case that redirect is a subresource. |
| 426 MalwareRedirectCancelAndProceed("openWinIFrame"); | 429 MalwareRedirectCancelAndProceed("openWinIFrame"); |
| 427 // If the redirect was from subresource but canceled, "proceed" will continue | 430 // If the redirect was from subresource but canceled, "proceed" will continue |
| 428 // with the rest of resources. | 431 // with the rest of resources. |
| 429 AssertNoInterstitial(true); | 432 AssertNoInterstitial(true); |
| 430 } | 433 } |
| 431 | 434 |
| 432 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareRedirectCanceled) { | 435 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 436 MalwareRedirectCanceled) { |
| 433 // 2. Test the case that redirect is the only resource. | 437 // 2. Test the case that redirect is the only resource. |
| 434 MalwareRedirectCancelAndProceed("openWin"); | 438 MalwareRedirectCancelAndProceed("openWin"); |
| 435 // Clicking proceed won't do anything if the main request is cancelled | 439 // Clicking proceed won't do anything if the main request is cancelled |
| 436 // already. See crbug.com/76460. | 440 // already. See crbug.com/76460. |
| 437 EXPECT_TRUE(YesInterstitial()); | 441 EXPECT_TRUE(YesInterstitial()); |
| 438 } | 442 } |
| 439 | 443 |
| 440 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { | 444 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) { |
| 441 GURL url = test_server()->GetURL(kEmptyPage); | 445 GURL url = test_server()->GetURL(kEmptyPage); |
| 442 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 446 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 443 | 447 |
| 444 ui_test_utils::NavigateToURL(browser(), url); | 448 ui_test_utils::NavigateToURL(browser(), url); |
| 445 | 449 |
| 446 bool hidden = false; | 450 bool hidden = false; |
| 447 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); | 451 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); |
| 448 EXPECT_FALSE(hidden); | 452 EXPECT_FALSE(hidden); |
| 449 | 453 |
| 450 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 454 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
| 451 AssertNoInterstitial(false); // Assert the interstitial is gone | 455 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 452 EXPECT_EQ( | 456 EXPECT_EQ( |
| 453 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 457 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 454 chrome::GetActiveWebContents(browser())->GetURL()); | 458 chrome::GetActiveWebContents(browser())->GetURL()); |
| 455 } | 459 } |
| 456 | 460 |
| 457 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 461 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) { |
| 458 GURL url = test_server()->GetURL(kEmptyPage); | 462 GURL url = test_server()->GetURL(kEmptyPage); |
| 459 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 463 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 460 | 464 |
| 461 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 465 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 462 // event that clears the interstitial. We wait for DidNavigate instead. | 466 // event that clears the interstitial. We wait for DidNavigate instead. |
| 463 ui_test_utils::NavigateToURL(browser(), url); | 467 ui_test_utils::NavigateToURL(browser(), url); |
| 464 content::WindowedNotificationObserver observer( | 468 content::WindowedNotificationObserver observer( |
| 465 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 469 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 466 content::Source<NavigationController>( | 470 content::Source<NavigationController>( |
| 467 &chrome::GetActiveWebContents(browser())->GetController())); | 471 &chrome::GetActiveWebContents(browser())->GetController())); |
| 468 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 472 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
| 469 observer.Wait(); | 473 observer.Wait(); |
| 470 AssertNoInterstitial(true); // Assert the interstitial is gone. | 474 AssertNoInterstitial(true); // Assert the interstitial is gone. |
| 471 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 475 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 472 } | 476 } |
| 473 | 477 |
| 474 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { | 478 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 479 MalwareLearnMore) { |
| 475 GURL url = test_server()->GetURL(kEmptyPage); | 480 GURL url = test_server()->GetURL(kEmptyPage); |
| 476 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 481 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 477 | 482 |
| 478 ui_test_utils::NavigateToURL(browser(), url); | 483 ui_test_utils::NavigateToURL(browser(), url); |
| 479 | 484 |
| 480 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" | |
| 481 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 482 EXPECT_EQ( | |
| 483 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". | |
| 484 chrome::GetActiveWebContents(browser())->GetURL()); | |
| 485 } | |
| 486 | |
| 487 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { | |
| 488 GURL url = test_server()->GetURL(kEmptyPage); | |
| 489 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 490 | |
| 491 ui_test_utils::NavigateToURL(browser(), url); | |
| 492 | |
| 493 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | |
| 494 // event that clears the interstitial. We wait for DidNavigate instead. | |
| 495 content::WindowedNotificationObserver observer( | |
| 496 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 497 content::Source<NavigationController>( | |
| 498 &chrome::GetActiveWebContents(browser())->GetController())); | |
| 499 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". | |
| 500 observer.Wait(); | |
| 501 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 502 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | |
| 503 } | |
| 504 | |
| 505 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { | |
| 506 GURL url = test_server()->GetURL(kEmptyPage); | |
| 507 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 508 | |
| 509 ui_test_utils::NavigateToURL(browser(), url); | |
| 510 | |
| 511 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | |
| 512 // event that clears the interstitial. We wait for DidNavigate instead. | |
| 513 content::WindowedNotificationObserver observer( | |
| 514 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 515 content::Source<NavigationController>( | |
| 516 &chrome::GetActiveWebContents(browser())->GetController())); | |
| 517 SendCommand("\"reportError\""); // Simulate the user clicking "report error" | |
| 518 observer.Wait(); | |
| 519 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 520 | |
| 521 // We are in the error reporting page. | |
| 522 EXPECT_EQ( | |
| 523 "/safebrowsing/report_error/", | |
| 524 chrome::GetActiveWebContents(browser())->GetURL().path()); | |
| 525 } | |
| 526 | |
| 527 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | |
| 528 PhishingLearnMore) { | |
| 529 GURL url = test_server()->GetURL(kEmptyPage); | |
| 530 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 531 | |
| 532 ui_test_utils::NavigateToURL(browser(), url); | |
| 533 | |
| 534 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 485 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
| 535 // event that clears the interstitial. We wait for DidNavigate instead. | 486 // event that clears the interstitial. We wait for DidNavigate instead. |
| 536 content::WindowedNotificationObserver observer( | 487 content::WindowedNotificationObserver observer( |
| 537 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 488 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 538 content::Source<NavigationController>( | 489 content::Source<NavigationController>( |
| 539 &chrome::GetActiveWebContents(browser())->GetController())); | 490 &chrome::GetActiveWebContents(browser())->GetController())); |
| 540 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" | 491 SendCommand("\"learnMore2\""); // Simulate the user clicking "learn more" |
| 541 observer.Wait(); | 492 observer.Wait(); |
| 542 AssertNoInterstitial(false); // Assert the interstitial is gone | 493 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 543 | 494 |
| 544 // We are in the help page. | 495 // We are in the help page. |
| 545 EXPECT_EQ( | 496 EXPECT_EQ( |
| 546 "/support/bin/answer.py", | 497 "/goodtoknow/online-safety/malware/", |
| 547 chrome::GetActiveWebContents(browser())->GetURL().path()); | 498 chrome::GetActiveWebContents(browser())->GetURL().path()); |
| 548 } | 499 } |
| 549 | 500 |
| 550 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { | 501 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 502 MalwareIframeDontProceed) { |
| 551 GURL url = test_server()->GetURL(kMalwarePage); | 503 GURL url = test_server()->GetURL(kMalwarePage); |
| 552 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 504 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 553 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 505 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 554 | 506 |
| 555 ui_test_utils::NavigateToURL(browser(), url); | 507 ui_test_utils::NavigateToURL(browser(), url); |
| 556 | 508 |
| 557 content::WindowedNotificationObserver observer( | 509 content::WindowedNotificationObserver observer( |
| 558 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 510 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 559 content::Source<NavigationController>( | 511 content::Source<NavigationController>( |
| 560 &chrome::GetActiveWebContents(browser())->GetController())); | 512 &chrome::GetActiveWebContents(browser())->GetController())); |
| 561 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 513 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
| 562 observer.Wait(); | 514 observer.Wait(); |
| 563 AssertNoInterstitial(false); // Assert the interstitial is gone | 515 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 564 | 516 |
| 565 EXPECT_EQ( | 517 EXPECT_EQ( |
| 566 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 518 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 567 chrome::GetActiveWebContents(browser())->GetURL()); | 519 chrome::GetActiveWebContents(browser())->GetURL()); |
| 568 } | 520 } |
| 569 | 521 |
| 570 // Crashy, http://crbug.com/68834. | 522 // Crashy, http://crbug.com/68834. |
| 571 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 523 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 572 DISABLED_MalwareIframeProceed) { | 524 DISABLED_MalwareIframeProceed) { |
| 573 GURL url = test_server()->GetURL(kMalwarePage); | 525 GURL url = test_server()->GetURL(kMalwarePage); |
| 574 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 526 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 575 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 527 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 576 | 528 |
| 577 ui_test_utils::NavigateToURL(browser(), url); | 529 ui_test_utils::NavigateToURL(browser(), url); |
| 578 | 530 |
| 579 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 531 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
| 580 AssertNoInterstitial(true); // Assert the interstitial is gone | 532 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 581 | 533 |
| 582 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 534 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 583 } | 535 } |
| 584 | 536 |
| 585 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 537 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, |
| 586 MalwareIframeReportDetails) { | 538 MalwareIframeReportDetails) { |
| 587 GURL url = test_server()->GetURL(kMalwarePage); | 539 GURL url = test_server()->GetURL(kMalwarePage); |
| 588 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 540 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 589 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 541 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 590 | 542 |
| 591 ui_test_utils::NavigateToURL(browser(), url); | 543 ui_test_utils::NavigateToURL(browser(), url); |
| 592 | 544 |
| 593 // If the DOM details from renderer did not already return, wait for them. | 545 // If the DOM details from renderer did not already return, wait for them. |
| 594 details_factory_.get_details()->WaitForDOM(); | 546 details_factory_.get_details()->WaitForDOM(); |
| 595 | 547 |
| 596 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. | 548 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. |
| 597 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 549 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
| 598 prefs::kSafeBrowsingReportingEnabled)); | 550 prefs::kSafeBrowsingReportingEnabled)); |
| 599 | 551 |
| 600 SendCommand("\"proceed\""); // Simulate the user clicking "back" | 552 SendCommand("\"proceed\""); // Simulate the user clicking "back" |
| 601 AssertNoInterstitial(true); // Assert the interstitial is gone | 553 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 602 | 554 |
| 603 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | 555 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
| 604 AssertReportSent(); | 556 AssertReportSent(); |
| 605 } | 557 } |
| 606 | 558 |
| 607 // Verifies that the "proceed anyway" link isn't available when it is disabled | 559 // Verifies that the "proceed anyway" link isn't available when it is disabled |
| 608 // by the corresponding policy. Also verifies that sending the "proceed" | 560 // by the corresponding policy. Also verifies that sending the "proceed" |
| 609 // command anyway doesn't advance to the malware site. | 561 // command anyway doesn't advance to the malware site. |
| 610 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) { | 562 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ProceedDisabled) { |
| 611 // Simulate a policy disabling the "proceed anyway" link. | 563 // Simulate a policy disabling the "proceed anyway" link. |
| 612 browser()->profile()->GetPrefs()->SetBoolean( | 564 browser()->profile()->GetPrefs()->SetBoolean( |
| 613 prefs::kSafeBrowsingProceedAnywayDisabled, true); | 565 prefs::kSafeBrowsingProceedAnywayDisabled, true); |
| 614 | 566 |
| 615 GURL url = test_server()->GetURL(kEmptyPage); | 567 GURL url = test_server()->GetURL(kEmptyPage); |
| 616 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 568 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 617 ui_test_utils::NavigateToURL(browser(), url); | 569 ui_test_utils::NavigateToURL(browser(), url); |
| 618 | 570 |
| 619 // The "proceed anyway" link should be hidden. | 571 // The "proceed anyway" link should be hidden. |
| 620 bool hidden = false; | 572 bool hidden = false; |
| 621 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); | 573 EXPECT_TRUE(GetProceedLinkIsHidden(&hidden)); |
| 622 EXPECT_TRUE(hidden); | 574 EXPECT_TRUE(hidden); |
| 623 | 575 |
| 624 // The "proceed" command should go back instead, if proceeding is disabled. | 576 // The "proceed" command should go back instead, if proceeding is disabled. |
| 625 SendCommand("\"proceed\""); | 577 SendCommand("\"proceed\""); |
| 626 AssertNoInterstitial(true); | 578 AssertNoInterstitial(true); |
| 627 EXPECT_EQ( | 579 EXPECT_EQ( |
| 628 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 580 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 629 chrome::GetActiveWebContents(browser())->GetURL()); | 581 chrome::GetActiveWebContents(browser())->GetURL()); |
| 630 } | 582 } |
| OLD | NEW |