| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 public: | 52 public: |
| 53 InterstitialObserver(content::WebContents* web_contents, | 53 InterstitialObserver(content::WebContents* web_contents, |
| 54 const base::Closure& attach_callback, | 54 const base::Closure& attach_callback, |
| 55 const base::Closure& detach_callback) | 55 const base::Closure& detach_callback) |
| 56 : WebContentsObserver(web_contents), | 56 : WebContentsObserver(web_contents), |
| 57 attach_callback_(attach_callback), | 57 attach_callback_(attach_callback), |
| 58 detach_callback_(detach_callback) { | 58 detach_callback_(detach_callback) { |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual void DidAttachInterstitialPage() OVERRIDE { | 61 virtual void DidAttachInterstitialPage() OVERRIDE { |
| 62 LOG(INFO) << __FUNCTION__; | |
| 63 attach_callback_.Run(); | 62 attach_callback_.Run(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 virtual void DidDetachInterstitialPage() OVERRIDE { | 65 virtual void DidDetachInterstitialPage() OVERRIDE { |
| 67 LOG(INFO) << __FUNCTION__; | |
| 68 detach_callback_.Run(); | 66 detach_callback_.Run(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 base::Closure attach_callback_; | 70 base::Closure attach_callback_; |
| 73 base::Closure detach_callback_; | 71 base::Closure detach_callback_; |
| 74 | 72 |
| 75 DISALLOW_COPY_AND_ASSIGN(InterstitialObserver); | 73 DISALLOW_COPY_AND_ASSIGN(InterstitialObserver); |
| 76 }; | 74 }; |
| 77 | 75 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 MalwareDetails::AddDOMDetails(params); | 246 MalwareDetails::AddDOMDetails(params); |
| 249 | 247 |
| 250 // Notify the UI thread that we got the dom details. | 248 // Notify the UI thread that we got the dom details. |
| 251 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 249 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 252 base::Bind(&FakeMalwareDetails::OnDOMDetailsDone, | 250 base::Bind(&FakeMalwareDetails::OnDOMDetailsDone, |
| 253 this)); | 251 this)); |
| 254 } | 252 } |
| 255 | 253 |
| 256 void WaitForDOM() { | 254 void WaitForDOM() { |
| 257 if (got_dom_) { | 255 if (got_dom_) { |
| 258 LOG(INFO) << "Already got the dom details."; | |
| 259 return; | 256 return; |
| 260 } | 257 } |
| 261 // This condition might not trigger normally, but if you add a | 258 // This condition might not trigger normally, but if you add a |
| 262 // sleep(1) in malware_dom_details it triggers :). | 259 // sleep(1) in malware_dom_details it triggers :). |
| 263 waiting_ = true; | 260 waiting_ = true; |
| 264 LOG(INFO) << "Waiting for dom details."; | |
| 265 content::RunMessageLoop(); | 261 content::RunMessageLoop(); |
| 266 EXPECT_TRUE(got_dom_); | 262 EXPECT_TRUE(got_dom_); |
| 267 } | 263 } |
| 268 | 264 |
| 269 private: | 265 private: |
| 270 virtual ~FakeMalwareDetails() {} | 266 virtual ~FakeMalwareDetails() {} |
| 271 | 267 |
| 272 void OnDOMDetailsDone() { | 268 void OnDOMDetailsDone() { |
| 273 got_dom_ = true; | 269 got_dom_ = true; |
| 274 if (waiting_) { | 270 if (waiting_) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 TestSafeBrowsingBlockingPage(SafeBrowsingUIManager* manager, | 306 TestSafeBrowsingBlockingPage(SafeBrowsingUIManager* manager, |
| 311 WebContents* web_contents, | 307 WebContents* web_contents, |
| 312 const UnsafeResourceList& unsafe_resources) | 308 const UnsafeResourceList& unsafe_resources) |
| 313 : SafeBrowsingBlockingPage(manager, web_contents, unsafe_resources), | 309 : SafeBrowsingBlockingPage(manager, web_contents, unsafe_resources), |
| 314 wait_for_delete_(false) { | 310 wait_for_delete_(false) { |
| 315 // Don't wait the whole 3 seconds for the browser test. | 311 // Don't wait the whole 3 seconds for the browser test. |
| 316 malware_details_proceed_delay_ms_ = 100; | 312 malware_details_proceed_delay_ms_ = 100; |
| 317 } | 313 } |
| 318 | 314 |
| 319 virtual ~TestSafeBrowsingBlockingPage() { | 315 virtual ~TestSafeBrowsingBlockingPage() { |
| 320 LOG(INFO) << __FUNCTION__; | |
| 321 if (!wait_for_delete_) | 316 if (!wait_for_delete_) |
| 322 return; | 317 return; |
| 323 | 318 |
| 324 // Notify that we are gone | 319 // Notify that we are gone |
| 325 base::MessageLoopForUI::current()->Quit(); | 320 base::MessageLoopForUI::current()->Quit(); |
| 326 wait_for_delete_ = false; | 321 wait_for_delete_ = false; |
| 327 } | 322 } |
| 328 | 323 |
| 329 void WaitForDelete() { | 324 void WaitForDelete() { |
| 330 LOG(INFO) << __FUNCTION__; | |
| 331 wait_for_delete_ = true; | 325 wait_for_delete_ = true; |
| 332 content::RunMessageLoop(); | 326 content::RunMessageLoop(); |
| 333 } | 327 } |
| 334 | 328 |
| 335 // InterstitialPageDelegate methods: | 329 // InterstitialPageDelegate methods: |
| 336 virtual void CommandReceived(const std::string& command) OVERRIDE { | 330 virtual void CommandReceived(const std::string& command) OVERRIDE { |
| 337 LOG(INFO) << __FUNCTION__ << " " << command; | |
| 338 SafeBrowsingBlockingPage::CommandReceived(command); | 331 SafeBrowsingBlockingPage::CommandReceived(command); |
| 339 } | 332 } |
| 340 virtual void OnProceed() OVERRIDE { | 333 virtual void OnProceed() OVERRIDE { |
| 341 LOG(INFO) << __FUNCTION__; | |
| 342 SafeBrowsingBlockingPage::OnProceed(); | 334 SafeBrowsingBlockingPage::OnProceed(); |
| 343 } | 335 } |
| 344 virtual void OnDontProceed() OVERRIDE { | 336 virtual void OnDontProceed() OVERRIDE { |
| 345 LOG(INFO) << __FUNCTION__; | |
| 346 SafeBrowsingBlockingPage::OnDontProceed(); | 337 SafeBrowsingBlockingPage::OnDontProceed(); |
| 347 } | 338 } |
| 348 | 339 |
| 349 private: | 340 private: |
| 350 bool wait_for_delete_; | 341 bool wait_for_delete_; |
| 351 }; | 342 }; |
| 352 | 343 |
| 353 class TestSafeBrowsingBlockingPageFactory | 344 class TestSafeBrowsingBlockingPageFactory |
| 354 : public SafeBrowsingBlockingPageFactory { | 345 : public SafeBrowsingBlockingPageFactory { |
| 355 public: | 346 public: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 412 } |
| 422 | 413 |
| 423 // Adds a safebrowsing malware result to the fake safebrowsing service, | 414 // Adds a safebrowsing malware result to the fake safebrowsing service, |
| 424 // navigates to a page with an iframe containing the malware site, and | 415 // navigates to a page with an iframe containing the malware site, and |
| 425 // returns the url of the parent page. | 416 // returns the url of the parent page. |
| 426 GURL SetupMalwareIframeWarningAndNavigate() { | 417 GURL SetupMalwareIframeWarningAndNavigate() { |
| 427 GURL url = test_server()->GetURL(kMalwarePage); | 418 GURL url = test_server()->GetURL(kMalwarePage); |
| 428 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 419 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 429 SetURLThreatType(iframe_url, SB_THREAT_TYPE_URL_MALWARE); | 420 SetURLThreatType(iframe_url, SB_THREAT_TYPE_URL_MALWARE); |
| 430 | 421 |
| 431 LOG(INFO) << "navigating... " << url.spec(); | |
| 432 ui_test_utils::NavigateToURL(browser(), url); | 422 ui_test_utils::NavigateToURL(browser(), url); |
| 433 EXPECT_TRUE(WaitForReady()); | 423 EXPECT_TRUE(WaitForReady()); |
| 434 return url; | 424 return url; |
| 435 } | 425 } |
| 436 | 426 |
| 437 void SendCommand(const std::string& command) { | 427 void SendCommand(const std::string& command) { |
| 438 WebContents* contents = | 428 WebContents* contents = |
| 439 browser()->tab_strip_model()->GetActiveWebContents(); | 429 browser()->tab_strip_model()->GetActiveWebContents(); |
| 440 // We use InterstitialPage::GetInterstitialPage(tab) instead of | 430 // We use InterstitialPage::GetInterstitialPage(tab) instead of |
| 441 // tab->GetInterstitialPage() because the tab doesn't have a pointer | 431 // tab->GetInterstitialPage() because the tab doesn't have a pointer |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 scoped_refptr<content::MessageLoopRunner> loop_runner( | 489 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 500 new content::MessageLoopRunner); | 490 new content::MessageLoopRunner); |
| 501 InterstitialObserver observer(contents, | 491 InterstitialObserver observer(contents, |
| 502 loop_runner->QuitClosure(), | 492 loop_runner->QuitClosure(), |
| 503 base::Closure()); | 493 base::Closure()); |
| 504 if (!InterstitialPage::GetInterstitialPage(contents)) | 494 if (!InterstitialPage::GetInterstitialPage(contents)) |
| 505 loop_runner->Run(); | 495 loop_runner->Run(); |
| 506 } | 496 } |
| 507 | 497 |
| 508 void SetReportSentCallback(const base::Closure& callback) { | 498 void SetReportSentCallback(const base::Closure& callback) { |
| 509 LOG(INFO) << __FUNCTION__; | |
| 510 factory_.most_recent_service() | 499 factory_.most_recent_service() |
| 511 ->fake_ui_manager() | 500 ->fake_ui_manager() |
| 512 ->set_malware_details_done_callback(callback); | 501 ->set_malware_details_done_callback(callback); |
| 513 } | 502 } |
| 514 | 503 |
| 515 std::string GetReportSent() { | 504 std::string GetReportSent() { |
| 516 LOG(INFO) << __FUNCTION__; | |
| 517 return factory_.most_recent_service()->fake_ui_manager()->GetReport(); | 505 return factory_.most_recent_service()->fake_ui_manager()->GetReport(); |
| 518 } | 506 } |
| 519 | 507 |
| 520 void MalwareRedirectCancelAndProceed(const std::string& open_function) { | 508 void MalwareRedirectCancelAndProceed(const std::string& open_function) { |
| 521 GURL load_url = test_server()->GetURL( | 509 GURL load_url = test_server()->GetURL( |
| 522 "files/safe_browsing/interstitial_cancel.html"); | 510 "files/safe_browsing/interstitial_cancel.html"); |
| 523 GURL malware_url("http://localhost/files/safe_browsing/malware.html"); | 511 GURL malware_url("http://localhost/files/safe_browsing/malware.html"); |
| 524 SetURLThreatType(malware_url, SB_THREAT_TYPE_URL_MALWARE); | 512 SetURLThreatType(malware_url, SB_THREAT_TYPE_URL_MALWARE); |
| 525 | 513 |
| 526 // Load the test page. | 514 // Load the test page. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 551 | 539 |
| 552 content::RenderViewHost* GetRenderViewHost() { | 540 content::RenderViewHost* GetRenderViewHost() { |
| 553 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage( | 541 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage( |
| 554 browser()->tab_strip_model()->GetActiveWebContents()); | 542 browser()->tab_strip_model()->GetActiveWebContents()); |
| 555 if (!interstitial) | 543 if (!interstitial) |
| 556 return NULL; | 544 return NULL; |
| 557 return interstitial->GetRenderViewHostForTesting(); | 545 return interstitial->GetRenderViewHostForTesting(); |
| 558 } | 546 } |
| 559 | 547 |
| 560 bool WaitForReady() { | 548 bool WaitForReady() { |
| 561 LOG(INFO) << __FUNCTION__; | |
| 562 content::RenderViewHost* rvh = GetRenderViewHost(); | 549 content::RenderViewHost* rvh = GetRenderViewHost(); |
| 563 if (!rvh) | 550 if (!rvh) |
| 564 return false; | 551 return false; |
| 565 // Wait until all <script> tags have executed, including jstemplate. | 552 // Wait until all <script> tags have executed, including jstemplate. |
| 566 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in | 553 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in |
| 567 // practice it spins at most once or twice. | 554 // practice it spins at most once or twice. |
| 568 std::string ready_state; | 555 std::string ready_state; |
| 569 do { | 556 do { |
| 570 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( | 557 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
| 571 rvh->GetMainFrame(), "document.readyState"); | 558 rvh->GetMainFrame(), "document.readyState"); |
| 572 if (!value.get() || !value->GetAsString(&ready_state)) | 559 if (!value.get() || !value->GetAsString(&ready_state)) |
| 573 return false; | 560 return false; |
| 574 } while (ready_state != "complete"); | 561 } while (ready_state != "complete"); |
| 575 LOG(INFO) << "done waiting"; | |
| 576 return true; | 562 return true; |
| 577 } | 563 } |
| 578 | 564 |
| 579 Visibility GetVisibility(const std::string& node_id) { | 565 Visibility GetVisibility(const std::string& node_id) { |
| 580 content::RenderViewHost* rvh = GetRenderViewHost(); | 566 content::RenderViewHost* rvh = GetRenderViewHost(); |
| 581 if (!rvh) | 567 if (!rvh) |
| 582 return VISIBILITY_ERROR; | 568 return VISIBILITY_ERROR; |
| 583 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( | 569 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
| 584 rvh->GetMainFrame(), | 570 rvh->GetMainFrame(), |
| 585 "var node = document.getElementById('" + node_id + "');\n" | 571 "var node = document.getElementById('" + node_id + "');\n" |
| 586 "if (node)\n" | 572 "if (node)\n" |
| 587 " node.offsetWidth > 0 && node.offsetHeight > 0;" | 573 " node.offsetWidth > 0 && node.offsetHeight > 0;" |
| 588 "else\n" | 574 "else\n" |
| 589 " 'node not found';\n"); | 575 " 'node not found';\n"); |
| 590 if (!value.get()) | 576 if (!value.get()) |
| 591 return VISIBILITY_ERROR; | 577 return VISIBILITY_ERROR; |
| 592 bool result = false; | 578 bool result = false; |
| 593 if (!value->GetAsBoolean(&result)) | 579 if (!value->GetAsBoolean(&result)) |
| 594 return VISIBILITY_ERROR; | 580 return VISIBILITY_ERROR; |
| 595 return result ? VISIBLE : HIDDEN; | 581 return result ? VISIBLE : HIDDEN; |
| 596 } | 582 } |
| 597 | 583 |
| 598 bool Click(const std::string& node_id) { | 584 bool Click(const std::string& node_id) { |
| 599 LOG(INFO) << "Click " << node_id; | |
| 600 content::RenderViewHost* rvh = GetRenderViewHost(); | 585 content::RenderViewHost* rvh = GetRenderViewHost(); |
| 601 if (!rvh) | 586 if (!rvh) |
| 602 return false; | 587 return false; |
| 603 // We don't use ExecuteScriptAndGetValue for this one, since clicking | 588 // We don't use ExecuteScriptAndGetValue for this one, since clicking |
| 604 // the button/link may navigate away before the injected javascript can | 589 // the button/link may navigate away before the injected javascript can |
| 605 // reply, hanging the test. | 590 // reply, hanging the test. |
| 606 rvh->GetMainFrame()->ExecuteJavaScript( | 591 rvh->GetMainFrame()->ExecuteJavaScript( |
| 607 base::ASCIIToUTF16( | 592 base::ASCIIToUTF16( |
| 608 "document.getElementById('" + node_id + "').click();\n")); | 593 "document.getElementById('" + node_id + "').click();\n")); |
| 609 return true; | 594 return true; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 MalwareIframeProceed) { | 709 MalwareIframeProceed) { |
| 725 GURL url = SetupMalwareIframeWarningAndNavigate(); | 710 GURL url = SetupMalwareIframeWarningAndNavigate(); |
| 726 | 711 |
| 727 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); | 712 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); |
| 728 AssertNoInterstitial(true); // Assert the interstitial is gone | 713 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 729 | 714 |
| 730 EXPECT_EQ(url, | 715 EXPECT_EQ(url, |
| 731 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 716 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 732 } | 717 } |
| 733 | 718 |
| 734 // TODO(felt): Needs to be re-enabled: http://crbug.com/273302 | |
| 735 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, | 719 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, |
| 736 DISABLED_MalwareIframeReportDetails) { | 720 MalwareIframeReportDetails) { |
| 737 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( | 721 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( |
| 738 new content::MessageLoopRunner); | 722 new content::MessageLoopRunner); |
| 739 SetReportSentCallback(malware_report_sent_runner->QuitClosure()); | 723 SetReportSentCallback(malware_report_sent_runner->QuitClosure()); |
| 740 | 724 |
| 741 GURL url = SetupMalwareIframeWarningAndNavigate(); | 725 GURL url = SetupMalwareIframeWarningAndNavigate(); |
| 742 | 726 |
| 743 LOG(INFO) << "1"; | |
| 744 | |
| 745 // If the DOM details from renderer did not already return, wait for them. | 727 // If the DOM details from renderer did not already return, wait for them. |
| 746 details_factory_.get_details()->WaitForDOM(); | 728 details_factory_.get_details()->WaitForDOM(); |
| 747 LOG(INFO) << "2"; | |
| 748 | 729 |
| 749 EXPECT_TRUE(Click("check-report")); | 730 EXPECT_TRUE(Click("opt-in-checkbox")); |
| 750 LOG(INFO) << "3"; | 731 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); |
| 751 | |
| 752 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 753 LOG(INFO) << "4"; | |
| 754 AssertNoInterstitial(true); // Assert the interstitial is gone | 732 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 755 LOG(INFO) << "5"; | |
| 756 | 733 |
| 757 ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 734 ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
| 758 prefs::kSafeBrowsingExtendedReportingEnabled)); | 735 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 759 LOG(INFO) << "6"; | |
| 760 | |
| 761 EXPECT_EQ(url, | 736 EXPECT_EQ(url, |
| 762 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 737 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 763 LOG(INFO) << "7"; | |
| 764 | 738 |
| 765 malware_report_sent_runner->Run(); | 739 malware_report_sent_runner->Run(); |
| 766 std::string serialized = GetReportSent(); | 740 std::string serialized = GetReportSent(); |
| 767 safe_browsing::ClientMalwareReportRequest report; | 741 safe_browsing::ClientMalwareReportRequest report; |
| 768 ASSERT_TRUE(report.ParseFromString(serialized)); | 742 ASSERT_TRUE(report.ParseFromString(serialized)); |
| 769 // Verify the report is complete. | 743 // Verify the report is complete. |
| 770 EXPECT_TRUE(report.complete()); | 744 EXPECT_TRUE(report.complete()); |
| 771 LOG(INFO) << "8"; | |
| 772 } | 745 } |
| 773 | 746 |
| 774 // Verifies that the "proceed anyway" link isn't available when it is disabled | 747 // Verifies that the "proceed anyway" link isn't available when it is disabled |
| 775 // by the corresponding policy. Also verifies that sending the "proceed" | 748 // by the corresponding policy. Also verifies that sending the "proceed" |
| 776 // command anyway doesn't advance to the malware site. | 749 // command anyway doesn't advance to the malware site. |
| 777 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) { | 750 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) { |
| 778 #if defined(OS_WIN) && defined(USE_ASH) | 751 #if defined(OS_WIN) && defined(USE_ASH) |
| 779 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 752 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 780 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 753 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 781 return; | 754 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 795 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); | 768 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); |
| 796 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph")); | 769 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph")); |
| 797 SendCommand("proceed"); | 770 SendCommand("proceed"); |
| 798 | 771 |
| 799 // The "proceed" command should go back instead, if proceeding is disabled. | 772 // The "proceed" command should go back instead, if proceeding is disabled. |
| 800 AssertNoInterstitial(true); | 773 AssertNoInterstitial(true); |
| 801 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | 774 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
| 802 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 775 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 803 } | 776 } |
| 804 | 777 |
| 805 // TODO(felt): Needs to be re-enabled: http://crbug.com/273302 | |
| 806 // Verifies that the reporting checkbox is hidden on non-HTTP pages. | 778 // Verifies that the reporting checkbox is hidden on non-HTTP pages. |
| 807 // TODO(mattm): Should also verify that no report is sent, but there isn't a | 779 // TODO(mattm): Should also verify that no report is sent, but there isn't a |
| 808 // good way to do that in the current design. | 780 // good way to do that in the current design. |
| 809 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, | 781 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, |
| 810 DISABLED_ReportingDisabled) { | 782 ReportingDisabled) { |
| 811 #if defined(OS_WIN) && defined(USE_ASH) | 783 #if defined(OS_WIN) && defined(USE_ASH) |
| 812 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 784 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 813 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 785 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 814 return; | 786 return; |
| 815 #endif | 787 #endif |
| 816 | 788 |
| 817 browser()->profile()->GetPrefs()->SetBoolean( | 789 browser()->profile()->GetPrefs()->SetBoolean( |
| 818 prefs::kSafeBrowsingExtendedReportingEnabled, true); | 790 prefs::kSafeBrowsingExtendedReportingEnabled, true); |
| 819 | 791 |
| 820 net::SpawnedTestServer https_server( | 792 net::SpawnedTestServer https_server( |
| 821 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | 793 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
| 822 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 794 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 823 ASSERT_TRUE(https_server.Start()); | 795 ASSERT_TRUE(https_server.Start()); |
| 824 GURL url = https_server.GetURL(kEmptyPage); | 796 GURL url = https_server.GetURL(kEmptyPage); |
| 825 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); | 797 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); |
| 826 ui_test_utils::NavigateToURL(browser(), url); | 798 ui_test_utils::NavigateToURL(browser(), url); |
| 827 ASSERT_TRUE(WaitForReady()); | 799 ASSERT_TRUE(WaitForReady()); |
| 828 | 800 |
| 829 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | 801 EXPECT_EQ(HIDDEN, GetVisibility("malware-opt-in")); |
| 830 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 802 EXPECT_EQ(HIDDEN, GetVisibility("opt-in-checkbox")); |
| 831 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 803 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); |
| 832 EXPECT_TRUE(Click("see-more-link")); | 804 EXPECT_TRUE(Click("details-button")); |
| 833 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 805 EXPECT_EQ(VISIBLE, GetVisibility("help-link")); |
| 834 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 806 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); |
| 835 | 807 |
| 836 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 808 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); |
| 837 AssertNoInterstitial(false); // Assert the interstitial is gone | 809 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 838 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | 810 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
| 839 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 811 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 840 } | 812 } |
| 841 | 813 |
| 842 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, | 814 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, |
| 843 PhishingDontProceed) { | 815 PhishingDontProceed) { |
| 844 #if defined(OS_WIN) && defined(USE_ASH) | 816 #if defined(OS_WIN) && defined(USE_ASH) |
| 845 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 817 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 846 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 818 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 857 EXPECT_EQ(VISIBLE, GetVisibility("details")); | 829 EXPECT_EQ(VISIBLE, GetVisibility("details")); |
| 858 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); | 830 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); |
| 859 EXPECT_EQ(HIDDEN, GetVisibility("error-code")); | 831 EXPECT_EQ(HIDDEN, GetVisibility("error-code")); |
| 860 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); | 832 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); |
| 861 | 833 |
| 862 AssertNoInterstitial(false); // Assert the interstitial is gone | 834 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 863 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". | 835 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". |
| 864 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 836 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 865 } | 837 } |
| 866 | 838 |
| 867 // http://crbug.com/247763 | 839 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, PhishingProceed) { |
| 868 #if defined(OS_WIN) | |
| 869 // Temporarily re-enabled to get some logs. | |
| 870 #define MAYBE_PhishingProceed PhishingProceed | |
| 871 #else | |
| 872 #define MAYBE_PhishingProceed PhishingProceed | |
| 873 #endif | |
| 874 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, | |
| 875 MAYBE_PhishingProceed) { | |
| 876 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 840 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
| 877 LOG(INFO) << "1"; | |
| 878 | |
| 879 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); | 841 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); |
| 880 LOG(INFO) << "2"; | |
| 881 AssertNoInterstitial(true); // Assert the interstitial is gone | 842 AssertNoInterstitial(true); // Assert the interstitial is gone |
| 882 LOG(INFO) << "3"; | |
| 883 EXPECT_EQ(url, | 843 EXPECT_EQ(url, |
| 884 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 844 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 885 LOG(INFO) << "4"; | |
| 886 } | 845 } |
| 887 | 846 |
| 888 // See crbug.com/248447 | 847 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, PhishingLearnMore) { |
| 889 #if defined(OS_WIN) | |
| 890 // Temporarily re-enabled to get some logs. | |
| 891 #define MAYBE_PhishingLearnMore PhishingLearnMore | |
| 892 #else | |
| 893 #define MAYBE_PhishingLearnMore PhishingLearnMore | |
| 894 #endif | |
| 895 | |
| 896 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, | |
| 897 MAYBE_PhishingLearnMore) { | |
| 898 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 848 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
| 899 LOG(INFO) << "1"; | |
| 900 | |
| 901 EXPECT_TRUE(ClickAndWaitForDetach("help-link")); | 849 EXPECT_TRUE(ClickAndWaitForDetach("help-link")); |
| 902 LOG(INFO) << "2"; | |
| 903 AssertNoInterstitial(false); // Assert the interstitial is gone | 850 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 904 | 851 |
| 905 LOG(INFO) << "3"; | |
| 906 // We are in the help page. | 852 // We are in the help page. |
| 907 EXPECT_EQ( | 853 EXPECT_EQ( |
| 908 "/transparencyreport/safebrowsing/", | 854 "/transparencyreport/safebrowsing/", |
| 909 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 855 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
| 910 LOG(INFO) << "4"; | |
| 911 } | 856 } |
| OLD | NEW |