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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 return result ? VISIBLE : HIDDEN; | 561 return result ? VISIBLE : HIDDEN; |
562 } | 562 } |
563 | 563 |
564 bool Click(const std::string& node_id) { | 564 bool Click(const std::string& node_id) { |
565 content::RenderViewHost* rvh = GetRenderViewHost(); | 565 content::RenderViewHost* rvh = GetRenderViewHost(); |
566 if (!rvh) | 566 if (!rvh) |
567 return false; | 567 return false; |
568 // We don't use ExecuteScriptAndGetValue for this one, since clicking | 568 // We don't use ExecuteScriptAndGetValue for this one, since clicking |
569 // the button/link may navigate away before the injected javascript can | 569 // the button/link may navigate away before the injected javascript can |
570 // reply, hanging the test. | 570 // reply, hanging the test. |
571 rvh->GetMainFrame()->ExecuteJavaScript( | 571 rvh->GetMainFrame()->ExecuteJavaScriptForTests( |
572 base::ASCIIToUTF16( | 572 base::ASCIIToUTF16( |
573 "document.getElementById('" + node_id + "').click();\n")); | 573 "document.getElementById('" + node_id + "').click();\n")); |
574 return true; | 574 return true; |
575 } | 575 } |
576 | 576 |
577 bool ClickAndWaitForDetach(const std::string& node_id) { | 577 bool ClickAndWaitForDetach(const std::string& node_id) { |
578 // We wait for interstitial_detached rather than nav_entry_committed, as | 578 // We wait for interstitial_detached rather than nav_entry_committed, as |
579 // going back from a main-frame malware interstitial page will not cause a | 579 // going back from a main-frame malware interstitial page will not cause a |
580 // nav entry committed event. | 580 // nav entry committed event. |
581 if (!Click(node_id)) | 581 if (!Click(node_id)) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, | 866 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, |
867 SafeBrowsingBlockingPageDecodesIDN) { | 867 SafeBrowsingBlockingPageDecodesIDN) { |
868 EXPECT_TRUE(VerifyIDNDecoded()); | 868 EXPECT_TRUE(VerifyIDNDecoded()); |
869 } | 869 } |
870 | 870 |
871 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, | 871 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, |
872 SafeBrowsingBlockingPageIDNTest, | 872 SafeBrowsingBlockingPageIDNTest, |
873 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 873 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
874 SB_THREAT_TYPE_URL_PHISHING, | 874 SB_THREAT_TYPE_URL_PHISHING, |
875 SB_THREAT_TYPE_URL_UNWANTED)); | 875 SB_THREAT_TYPE_URL_UNWANTED)); |
OLD | NEW |