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 known- | 5 // This test creates a fake safebrowsing service, where we can inject known- |
6 // threat urls. It then uses a real browser to go to these urls, and sends | 6 // threat urls. It then uses a real browser to go to these urls, and sends |
7 // "goback" or "proceed" commands and verifies they work. | 7 // "goback" or "proceed" commands and verifies they work. |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 // directly rather than using ClickAndWaitForDetach since there might not | 501 // directly rather than using ClickAndWaitForDetach since there might not |
502 // be a notification to wait for. | 502 // be a notification to wait for. |
503 SendCommand("\"proceed\""); | 503 SendCommand("\"proceed\""); |
504 } | 504 } |
505 | 505 |
506 content::RenderViewHost* GetRenderViewHost() { | 506 content::RenderViewHost* GetRenderViewHost() { |
507 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage( | 507 InterstitialPage* interstitial = InterstitialPage::GetInterstitialPage( |
508 browser()->tab_strip_model()->GetActiveWebContents()); | 508 browser()->tab_strip_model()->GetActiveWebContents()); |
509 if (!interstitial) | 509 if (!interstitial) |
510 return NULL; | 510 return NULL; |
511 return interstitial->GetRenderViewHostForTesting(); | 511 return interstitial->GetMainFrame()->GetRenderViewHost(); |
512 } | 512 } |
513 | 513 |
514 bool WaitForReady() { | 514 bool WaitForReady() { |
515 content::RenderViewHost* rvh = GetRenderViewHost(); | 515 content::RenderViewHost* rvh = GetRenderViewHost(); |
516 if (!rvh) | 516 if (!rvh) |
517 return false; | 517 return false; |
518 // Wait until all <script> tags have executed, including jstemplate. | 518 // Wait until all <script> tags have executed, including jstemplate. |
519 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in | 519 // TODO(joaodasilva): it would be nice to avoid the busy loop, though in |
520 // practice it spins at most once or twice. | 520 // practice it spins at most once or twice. |
521 std::string ready_state; | 521 std::string ready_state; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 ? "/transparencyreport/safebrowsing/" | 796 ? "/transparencyreport/safebrowsing/" |
797 : "/safebrowsing/diagnostic", | 797 : "/safebrowsing/diagnostic", |
798 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 798 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
799 } | 799 } |
800 | 800 |
801 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType, | 801 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType, |
802 SafeBrowsingBlockingPageBrowserTest, | 802 SafeBrowsingBlockingPageBrowserTest, |
803 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 803 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
804 SB_THREAT_TYPE_URL_PHISHING, | 804 SB_THREAT_TYPE_URL_PHISHING, |
805 SB_THREAT_TYPE_URL_UNWANTED)); | 805 SB_THREAT_TYPE_URL_UNWANTED)); |
OLD | NEW |