Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 1035143002: Add IDN decoding test for SafeBrowsingBlockingPage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make IDN test parameterized Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/safe_browsing/database_manager.h" 18 #include "chrome/browser/safe_browsing/database_manager.h"
18 #include "chrome/browser/safe_browsing/malware_details.h" 19 #include "chrome/browser/safe_browsing/malware_details.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 20 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 22 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
22 #include "chrome/browser/safe_browsing/ui_manager.h" 23 #include "chrome/browser/safe_browsing/ui_manager.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
29 #include "chrome/test/base/in_process_browser_test.h" 30 #include "chrome/test/base/in_process_browser_test.h"
30 #include "chrome/test/base/test_switches.h" 31 #include "chrome/test/base/test_switches.h"
31 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
32 #include "content/public/browser/interstitial_page.h" 33 #include "content/public/browser/interstitial_page.h"
33 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/notification_types.h" 35 #include "content/public/browser/notification_types.h"
35 #include "content/public/browser/render_frame_host.h" 36 #include "content/public/browser/render_frame_host.h"
37 #include "content/public/browser/render_process_host.h"
36 #include "content/public/browser/render_view_host.h" 38 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
38 #include "content/public/test/browser_test_utils.h" 40 #include "content/public/test/browser_test_utils.h"
39 #include "content/public/test/test_browser_thread.h" 41 #include "content/public/test/test_browser_thread.h"
40 #include "content/public/test/test_utils.h" 42 #include "content/public/test/test_utils.h"
41 43
44 using chrome_browser_interstitials::SecurityInterstitialIDNTest;
42 using content::BrowserThread; 45 using content::BrowserThread;
43 using content::InterstitialPage; 46 using content::InterstitialPage;
44 using content::NavigationController; 47 using content::NavigationController;
45 using content::WebContents; 48 using content::WebContents;
46 49
47 namespace { 50 namespace {
48 51
49 const char kEmptyPage[] = "files/empty.html"; 52 const char kEmptyPage[] = "files/empty.html";
50 const char kMalwarePage[] = "files/safe_browsing/malware.html"; 53 const char kMalwarePage[] = "files/safe_browsing/malware.html";
51 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; 54 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html";
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 ? "/transparencyreport/safebrowsing/" 792 ? "/transparencyreport/safebrowsing/"
790 : "/safebrowsing/diagnostic", 793 : "/safebrowsing/diagnostic",
791 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); 794 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
792 } 795 }
793 796
794 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType, 797 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType,
795 SafeBrowsingBlockingPageBrowserTest, 798 SafeBrowsingBlockingPageBrowserTest,
796 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 799 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
797 SB_THREAT_TYPE_URL_PHISHING, 800 SB_THREAT_TYPE_URL_PHISHING,
798 SB_THREAT_TYPE_URL_UNWANTED)); 801 SB_THREAT_TYPE_URL_UNWANTED));
802
803 // Test that SafeBrowsingBlockingPage properly decodes IDN URLs that are
804 // displayed.
805 class SafeBrowsingBlockingPageIDNTest
806 : public SecurityInterstitialIDNTest,
807 public testing::WithParamInterface<SBThreatType> {
808 protected:
809 // SecurityInterstitialIDNTest implementation
810 SecurityInterstitialPage* CreateInterstitial(
811 content::WebContents* contents,
812 const GURL& request_url) const override {
813 SafeBrowsingService* sb_service =
814 g_browser_process->safe_browsing_service();
815 SafeBrowsingBlockingPage::UnsafeResource resource;
816
817 resource.url = request_url;
818 resource.is_subresource = false;
819 resource.threat_type = GetParam();
820 resource.render_process_host_id = contents->GetRenderProcessHost()->GetID();
821 resource.render_view_id = contents->GetRenderViewHost()->GetRoutingID();
822
823 return SafeBrowsingBlockingPage::CreateBlockingPage(
824 sb_service->ui_manager().get(), contents, resource);
825 }
826 };
827
828 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest,
829 SafeBrowsingBlockingPageDecodesIDN) {
830 EXPECT_TRUE(VerifyIDNDecoded());
831 }
832
833 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType,
834 SafeBrowsingBlockingPageIDNTest,
835 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
836 SB_THREAT_TYPE_URL_PHISHING,
837 SB_THREAT_TYPE_URL_UNWANTED));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698