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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1943993006: Create test fixture for SafeBrowsingService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase update Created 4 years, 7 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
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 #include <stddef.h> 5 #include <stddef.h>
6 #include <deque> 6 #include <deque>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/prerender/prerender_field_trial.h" 43 #include "chrome/browser/prerender/prerender_field_trial.h"
44 #include "chrome/browser/prerender/prerender_handle.h" 44 #include "chrome/browser/prerender/prerender_handle.h"
45 #include "chrome/browser/prerender/prerender_link_manager.h" 45 #include "chrome/browser/prerender/prerender_link_manager.h"
46 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 46 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
47 #include "chrome/browser/prerender/prerender_manager.h" 47 #include "chrome/browser/prerender/prerender_manager.h"
48 #include "chrome/browser/prerender/prerender_manager_factory.h" 48 #include "chrome/browser/prerender/prerender_manager_factory.h"
49 #include "chrome/browser/profiles/profile.h" 49 #include "chrome/browser/profiles/profile.h"
50 #include "chrome/browser/profiles/profile_io_data.h" 50 #include "chrome/browser/profiles/profile_io_data.h"
51 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 51 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
52 #include "chrome/browser/safe_browsing/local_database_manager.h" 52 #include "chrome/browser/safe_browsing/local_database_manager.h"
53 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 53 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
54 #include "chrome/browser/task_management/mock_web_contents_task_manager.h" 54 #include "chrome/browser/task_management/mock_web_contents_task_manager.h"
55 #include "chrome/browser/task_management/providers/web_contents/web_contents_tag s_manager.h" 55 #include "chrome/browser/task_management/providers/web_contents/web_contents_tag s_manager.h"
56 #include "chrome/browser/task_manager/task_manager.h" 56 #include "chrome/browser/task_manager/task_manager.h"
57 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 57 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
58 #include "chrome/browser/ui/browser.h" 58 #include "chrome/browser/ui/browser.h"
59 #include "chrome/browser/ui/browser_commands.h" 59 #include "chrome/browser/ui/browser_commands.h"
60 #include "chrome/browser/ui/browser_finder.h" 60 #include "chrome/browser/ui/browser_finder.h"
61 #include "chrome/browser/ui/browser_window.h" 61 #include "chrome/browser/ui/browser_window.h"
62 #include "chrome/browser/ui/location_bar/location_bar.h" 62 #include "chrome/browser/ui/location_bar/location_bar.h"
63 #include "chrome/browser/ui/tabs/tab_strip_model.h" 63 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 handle(handle) { 733 handle(handle) {
734 } 734 }
735 735
736 FinalStatus final_status; 736 FinalStatus final_status;
737 base::WeakPtr<TestPrerender> handle; 737 base::WeakPtr<TestPrerender> handle;
738 }; 738 };
739 739
740 std::deque<ExpectedContents> expected_contents_queue_; 740 std::deque<ExpectedContents> expected_contents_queue_;
741 }; 741 };
742 742
743 // TODO(nparker): Switch this to use TestSafeBrowsingDatabaseManager and run
744 // with SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE.
745 // Note: don't forget to override GetProtocolManagerDelegate and return NULL,
746 // because FakeSafeBrowsingDatabaseManager does not implement
747 // LocalSafeBrowsingDatabaseManager.
748 #if defined(FULL_SAFE_BROWSING)
749 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for 743 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for
750 // a given URL. 744 // a given URL.
751 class FakeSafeBrowsingDatabaseManager 745 class FakeSafeBrowsingDatabaseManager
752 : public LocalSafeBrowsingDatabaseManager { 746 : public safe_browsing::TestSafeBrowsingDatabaseManager {
753 public: 747 public:
754 explicit FakeSafeBrowsingDatabaseManager(SafeBrowsingService* service) 748 FakeSafeBrowsingDatabaseManager() {}
755 : LocalSafeBrowsingDatabaseManager(service),
756 threat_type_(safe_browsing::SB_THREAT_TYPE_SAFE) {}
757 749
758 // Called on the IO thread to check if the given url is safe or not. If we 750 // Called on the IO thread to check if the given url is safe or not. If we
759 // can synchronously determine that the url is safe, CheckUrl returns true. 751 // can synchronously determine that the url is safe, CheckUrl returns true.
760 // Otherwise it returns false, and "client" is called asynchronously with the 752 // Otherwise it returns false, and "client" is called asynchronously with the
761 // result when it is ready. 753 // result when it is ready.
762 // Returns true, indicating a SAFE result, unless the URL is the fixed URL 754 // Returns true, indicating a SAFE result, unless the URL is the fixed URL
763 // specified by the user, and the user-specified result is not SAFE 755 // specified by the user, and the user-specified result is not SAFE
764 // (in which that result will be communicated back via a call into the 756 // (in which that result will be communicated back via a call into the
765 // client, and false will be returned). 757 // client, and false will be returned).
766 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl. 758 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl.
767 bool CheckBrowseUrl(const GURL& gurl, Client* client) override { 759 bool CheckBrowseUrl(const GURL& gurl, Client* client) override {
768 if (gurl != url_ || threat_type_ == safe_browsing::SB_THREAT_TYPE_SAFE) 760 if (badurls_.find(gurl.spec()) == badurls_.end() ||
761 badurls_[gurl.spec()] == safe_browsing::SB_THREAT_TYPE_SAFE)
769 return true; 762 return true;
770 763
771 BrowserThread::PostTask( 764 BrowserThread::PostTask(
772 BrowserThread::IO, FROM_HERE, 765 BrowserThread::IO, FROM_HERE,
773 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, 766 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone,
774 this, gurl, client)); 767 this, gurl, client));
775 return false; 768 return false;
776 } 769 }
777 770
778 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) { 771 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) {
779 url_ = url; 772 badurls_[url.spec()] = threat_type;
780 threat_type_ = threat_type; 773 }
774
775 // These are called when checking URLs, so we implement them.
776 bool IsSupported() const override { return true; }
777 bool ChecksAreAlwaysAsync() const override { return false; }
778 bool CanCheckResourceType(
779 content::ResourceType /* resource_type */) const override {
780 return true;
781 }
782
783 bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
784 Client* client) override {
785 return true;
781 } 786 }
782 787
783 private: 788 private:
784 ~FakeSafeBrowsingDatabaseManager() override {} 789 ~FakeSafeBrowsingDatabaseManager() override {}
785 790
786 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { 791 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) {
787 std::vector<SBThreatType> expected_threats; 792 std::vector<SBThreatType> expected_threats;
788 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 793 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
789 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING); 794 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING);
790 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to 795 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to
791 // client->OnCheckBrowseUrlResult() 796 // client->OnCheckBrowseUrlResult()
792 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( 797 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check(
793 std::vector<GURL>(1, gurl), 798 std::vector<GURL>(1, gurl),
794 std::vector<safe_browsing::SBFullHash>(), 799 std::vector<safe_browsing::SBFullHash>(),
795 client, 800 client,
796 safe_browsing::MALWARE, 801 safe_browsing::MALWARE,
797 expected_threats); 802 expected_threats);
798 sb_check.url_results[0] = threat_type_; 803 sb_check.url_results[0] = badurls_[gurl.spec()];
799 sb_check.OnSafeBrowsingResult(); 804 sb_check.OnSafeBrowsingResult();
800 } 805 }
801 806
802 GURL url_; 807 base::hash_map<std::string, SBThreatType> badurls_;
803 SBThreatType threat_type_;
804 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); 808 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager);
805 }; 809 };
806 810
807 class FakeSafeBrowsingService : public SafeBrowsingService {
808 public:
809 FakeSafeBrowsingService() { }
810
811 // Returned pointer has the same lifespan as the database_manager_ refcounted
812 // object.
813 FakeSafeBrowsingDatabaseManager* fake_database_manager() {
814 return fake_database_manager_;
815 }
816
817 protected:
818 ~FakeSafeBrowsingService() override {}
819
820 safe_browsing::SafeBrowsingDatabaseManager* CreateDatabaseManager() override {
821 fake_database_manager_ = new FakeSafeBrowsingDatabaseManager(this);
822 return fake_database_manager_;
823 }
824
825 private:
826 FakeSafeBrowsingDatabaseManager* fake_database_manager_;
827
828 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingService);
829 };
830
831 // Factory that creates FakeSafeBrowsingService instances.
832 class TestSafeBrowsingServiceFactory
833 : public safe_browsing::SafeBrowsingServiceFactory {
834 public:
835 TestSafeBrowsingServiceFactory() :
836 most_recent_service_(NULL) { }
837 ~TestSafeBrowsingServiceFactory() override {}
838
839 SafeBrowsingService* CreateSafeBrowsingService() override {
840 most_recent_service_ = new FakeSafeBrowsingService();
841 return most_recent_service_;
842 }
843
844 FakeSafeBrowsingService* most_recent_service() const {
845 return most_recent_service_;
846 }
847
848 private:
849 FakeSafeBrowsingService* most_recent_service_;
850 };
851 #endif
852
853 class FakeDevToolsClient : public content::DevToolsAgentHostClient { 811 class FakeDevToolsClient : public content::DevToolsAgentHostClient {
854 public: 812 public:
855 FakeDevToolsClient() {} 813 FakeDevToolsClient() {}
856 ~FakeDevToolsClient() override {} 814 ~FakeDevToolsClient() override {}
857 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, 815 void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
858 const std::string& message) override {} 816 const std::string& message) override {}
859 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {} 817 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {}
860 }; 818 };
861 819
862 class RestorePrerenderMode { 820 class RestorePrerenderMode {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 base::FilePath().AppendASCII(file_name)); 1080 base::FilePath().AppendASCII(file_name));
1123 } 1081 }
1124 1082
1125 } // namespace 1083 } // namespace
1126 1084
1127 class PrerenderBrowserTest : virtual public InProcessBrowserTest { 1085 class PrerenderBrowserTest : virtual public InProcessBrowserTest {
1128 public: 1086 public:
1129 PrerenderBrowserTest() 1087 PrerenderBrowserTest()
1130 : autostart_test_server_(true), 1088 : autostart_test_server_(true),
1131 prerender_contents_factory_(NULL), 1089 prerender_contents_factory_(NULL),
1132 #if defined(FULL_SAFE_BROWSING) 1090 safe_browsing_factory_(
1133 safe_browsing_factory_(new TestSafeBrowsingServiceFactory()), 1091 new safe_browsing::TestSafeBrowsingServiceFactory()),
1134 #endif
1135 call_javascript_(true), 1092 call_javascript_(true),
1136 check_load_events_(true), 1093 check_load_events_(true),
1137 loader_path_("/prerender/prerender_loader.html"), 1094 loader_path_("/prerender/prerender_loader.html"),
1138 explicitly_set_browser_(NULL) { 1095 explicitly_set_browser_(NULL) {}
1139 }
1140 1096
1141 ~PrerenderBrowserTest() override {} 1097 ~PrerenderBrowserTest() override {}
1142 1098
1143 content::SessionStorageNamespace* GetSessionStorageNamespace() const { 1099 content::SessionStorageNamespace* GetSessionStorageNamespace() const {
1144 WebContents* web_contents = GetActiveWebContents(); 1100 WebContents* web_contents = GetActiveWebContents();
1145 if (!web_contents) 1101 if (!web_contents)
1146 return NULL; 1102 return NULL;
1147 return web_contents->GetController().GetDefaultSessionStorageNamespace(); 1103 return web_contents->GetController().GetDefaultSessionStorageNamespace();
1148 } 1104 }
1149 1105
1150 void SetUpInProcessBrowserTestFixture() override { 1106 void SetUpInProcessBrowserTestFixture() override {
1151 #if defined(FULL_SAFE_BROWSING) 1107 safe_browsing_factory_->SetTestDatabaseManager(
1108 new FakeSafeBrowsingDatabaseManager());
1152 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get()); 1109 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get());
1153 #endif
1154 } 1110 }
1155 1111
1156 void TearDownInProcessBrowserTestFixture() override { 1112 void TearDownInProcessBrowserTestFixture() override {
1157 #if defined(FULL_SAFE_BROWSING)
1158 SafeBrowsingService::RegisterFactory(NULL); 1113 SafeBrowsingService::RegisterFactory(NULL);
1159 #endif
1160 } 1114 }
1161 1115
1162 void SetUpCommandLine(base::CommandLine* command_line) override { 1116 void SetUpCommandLine(base::CommandLine* command_line) override {
1163 command_line->AppendSwitchASCII(switches::kPrerenderMode, 1117 command_line->AppendSwitchASCII(switches::kPrerenderMode,
1164 switches::kPrerenderModeSwitchValueEnabled); 1118 switches::kPrerenderModeSwitchValueEnabled);
1165 command_line->AppendSwitch(switches::kEnablePepperTesting); 1119 command_line->AppendSwitch(switches::kEnablePepperTesting);
1166 command_line->AppendSwitchASCII( 1120 command_line->AppendSwitchASCII(
1167 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); 1121 switches::kOverridePluginPowerSaverForTesting, "ignore-list");
1168 1122
1169 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); 1123 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line));
1170 } 1124 }
1171 1125
1172 void SetUpOnMainThread() override { 1126 void SetUpOnMainThread() override {
1173 current_browser()->profile()->GetPrefs()->SetBoolean( 1127 current_browser()->profile()->GetPrefs()->SetBoolean(
1174 prefs::kPromptForDownload, false); 1128 prefs::kPromptForDownload, false);
1175 IncreasePrerenderMemory(); 1129 IncreasePrerenderMemory();
1176 if (autostart_test_server_) 1130 if (autostart_test_server_)
1177 ASSERT_TRUE(embedded_test_server()->Start()); 1131 ASSERT_TRUE(embedded_test_server()->Start());
1178 ChromeResourceDispatcherHostDelegate:: 1132 ChromeResourceDispatcherHostDelegate::
1179 SetExternalProtocolHandlerDelegateForTesting( 1133 SetExternalProtocolHandlerDelegateForTesting(
1180 &external_protocol_handler_delegate_); 1134 &external_protocol_handler_delegate_);
1181 1135
1182 PrerenderManager* prerender_manager = GetPrerenderManager(); 1136 PrerenderManager* prerender_manager = GetPrerenderManager();
1183 ASSERT_TRUE(prerender_manager); 1137 ASSERT_TRUE(prerender_manager);
1184 prerender_manager->mutable_config().rate_limit_enabled = false; 1138 prerender_manager->mutable_config().rate_limit_enabled = false;
1185 ASSERT_TRUE(prerender_contents_factory_ == NULL); 1139 ASSERT_TRUE(prerender_contents_factory_ == NULL);
1186 prerender_contents_factory_ = new TestPrerenderContentsFactory; 1140 prerender_contents_factory_ = new TestPrerenderContentsFactory;
1187 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_); 1141 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_);
1142 ASSERT_TRUE(safe_browsing_factory_->test_safe_browsing_service());
1188 } 1143 }
1189 1144
1190 // Convenience function to get the currently active WebContents in 1145 // Convenience function to get the currently active WebContents in
1191 // current_browser(). 1146 // current_browser().
1192 WebContents* GetActiveWebContents() const { 1147 WebContents* GetActiveWebContents() const {
1193 return current_browser()->tab_strip_model()->GetActiveWebContents(); 1148 return current_browser()->tab_strip_model()->GetActiveWebContents();
1194 } 1149 }
1195 1150
1196 // Overload for a single expected final status 1151 // Overload for a single expected final status
1197 std::unique_ptr<TestPrerender> PrerenderTestURL( 1152 std::unique_ptr<TestPrerender> PrerenderTestURL(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 static_cast<base::DictionaryValue*>( 1425 static_cast<base::DictionaryValue*>(
1471 GetPrerenderManager()->GetAsValue())); 1426 GetPrerenderManager()->GetAsValue()));
1472 if (!prerender_dict.get()) 1427 if (!prerender_dict.get())
1473 return -1; 1428 return -1;
1474 base::ListValue* history_list; 1429 base::ListValue* history_list;
1475 if (!prerender_dict->GetList("history", &history_list)) 1430 if (!prerender_dict->GetList("history", &history_list))
1476 return -1; 1431 return -1;
1477 return static_cast<int>(history_list->GetSize()); 1432 return static_cast<int>(history_list->GetSize());
1478 } 1433 }
1479 1434
1480 #if defined(FULL_SAFE_BROWSING)
1481 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() { 1435 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() {
1482 return safe_browsing_factory_->most_recent_service()-> 1436 return static_cast<FakeSafeBrowsingDatabaseManager*>(
1483 fake_database_manager(); 1437 safe_browsing_factory_->test_safe_browsing_service()
1438 ->database_manager()
1439 .get());
1484 } 1440 }
1485 #endif
1486 1441
1487 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const { 1442 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const {
1488 PrerenderManager::PrerenderData* prerender_data = 1443 PrerenderManager::PrerenderData* prerender_data =
1489 GetPrerenderManager()->FindPrerenderData(url, NULL); 1444 GetPrerenderManager()->FindPrerenderData(url, NULL);
1490 return static_cast<TestPrerenderContents*>( 1445 return static_cast<TestPrerenderContents*>(
1491 prerender_data ? prerender_data->contents() : NULL); 1446 prerender_data ? prerender_data->contents() : NULL);
1492 } 1447 }
1493 1448
1494 void SetLoaderHostOverride(const std::string& host) { 1449 void SetLoaderHostOverride(const std::string& host) {
1495 loader_host_override_ = host; 1450 loader_host_override_ = host;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 } else { 1667 } else {
1713 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), 1668 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(),
1714 web_contents); 1669 web_contents);
1715 render_frame_host->ExecuteJavaScriptForTests( 1670 render_frame_host->ExecuteJavaScriptForTests(
1716 base::ASCIIToUTF16(javascript)); 1671 base::ASCIIToUTF16(javascript));
1717 observer.Wait(); 1672 observer.Wait();
1718 } 1673 }
1719 } 1674 }
1720 1675
1721 TestPrerenderContentsFactory* prerender_contents_factory_; 1676 TestPrerenderContentsFactory* prerender_contents_factory_;
1722 #if defined(FULL_SAFE_BROWSING) 1677 std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory>
1723 std::unique_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; 1678 safe_browsing_factory_;
1724 #endif
1725 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; 1679 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_;
1726 GURL dest_url_; 1680 GURL dest_url_;
1727 std::unique_ptr<net::EmbeddedTestServer> https_src_server_; 1681 std::unique_ptr<net::EmbeddedTestServer> https_src_server_;
1728 bool call_javascript_; 1682 bool call_javascript_;
1729 bool check_load_events_; 1683 bool check_load_events_;
1730 std::string loader_host_override_; 1684 std::string loader_host_override_;
1731 std::string loader_path_; 1685 std::string loader_path_;
1732 std::string loader_query_; 1686 std::string loader_query_;
1733 Browser* explicitly_set_browser_; 1687 Browser* explicitly_set_browser_;
1734 base::HistogramTester histogram_tester_; 1688 base::HistogramTester histogram_tester_;
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 std::make_pair("REPLACE_WITH_URL", https_url.spec())); 2930 std::make_pair("REPLACE_WITH_URL", https_url.spec()));
2977 std::string replacement_path; 2931 std::string replacement_path;
2978 net::test_server::GetFilePathWithReplacements( 2932 net::test_server::GetFilePathWithReplacements(
2979 "/prerender/prerender_with_iframe.html", replacement_text, 2933 "/prerender/prerender_with_iframe.html", replacement_text,
2980 &replacement_path); 2934 &replacement_path);
2981 PrerenderTestURL(replacement_path, 2935 PrerenderTestURL(replacement_path,
2982 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 2936 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED,
2983 0); 2937 0);
2984 } 2938 }
2985 2939
2986 #if defined(FULL_SAFE_BROWSING)
2987 // Ensures that we do not prerender pages with a safe browsing 2940 // Ensures that we do not prerender pages with a safe browsing
2988 // interstitial. 2941 // interstitial.
2989 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) { 2942 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) {
2990 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html"); 2943 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html");
2991 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( 2944 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl(
2992 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 2945 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
2993 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING, 2946 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING,
2994 0); 2947 0);
2995 } 2948 }
2996 2949
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 std::make_pair("REPLACE_WITH_URL", iframe_url.spec())); 2995 std::make_pair("REPLACE_WITH_URL", iframe_url.spec()));
3043 std::string replacement_path; 2996 std::string replacement_path;
3044 net::test_server::GetFilePathWithReplacements( 2997 net::test_server::GetFilePathWithReplacements(
3045 "/prerender/prerender_with_iframe.html", replacement_text, 2998 "/prerender/prerender_with_iframe.html", replacement_text,
3046 &replacement_path); 2999 &replacement_path);
3047 PrerenderTestURL(replacement_path, 3000 PrerenderTestURL(replacement_path,
3048 FINAL_STATUS_SAFE_BROWSING, 3001 FINAL_STATUS_SAFE_BROWSING,
3049 0); 3002 0);
3050 } 3003 }
3051 3004
3052 #endif
3053
3054 // Checks that a local storage read will not cause prerender to fail. 3005 // Checks that a local storage read will not cause prerender to fail.
3055 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) { 3006 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) {
3056 PrerenderTestURL("/prerender/prerender_localstorage_read.html", 3007 PrerenderTestURL("/prerender/prerender_localstorage_read.html",
3057 FINAL_STATUS_USED, 1); 3008 FINAL_STATUS_USED, 1);
3058 NavigateToDestURL(); 3009 NavigateToDestURL();
3059 } 3010 }
3060 3011
3061 // Checks that a local storage write will not cause prerender to fail. 3012 // Checks that a local storage write will not cause prerender to fail.
3062 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { 3013 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) {
3063 PrerenderTestURL("/prerender/prerender_localstorage_write.html", 3014 PrerenderTestURL("/prerender/prerender_localstorage_write.html",
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 browser()->tab_strip_model()->GetActiveWebContents(); 3986 browser()->tab_strip_model()->GetActiveWebContents();
4036 bool display_test_result = false; 3987 bool display_test_result = false;
4037 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3988 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
4038 "DidDisplayReallyPass()", 3989 "DidDisplayReallyPass()",
4039 &display_test_result)); 3990 &display_test_result));
4040 ASSERT_TRUE(display_test_result); 3991 ASSERT_TRUE(display_test_result);
4041 } 3992 }
4042 #endif // !defined(DISABLE_NACL) 3993 #endif // !defined(DISABLE_NACL)
4043 3994
4044 } // namespace prerender 3995 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698