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

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: update comments and rebase again 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_management/task_manager_browsertest_util.h" 56 #include "chrome/browser/task_management/task_manager_browsertest_util.h"
57 #include "chrome/browser/ui/browser.h" 57 #include "chrome/browser/ui/browser.h"
58 #include "chrome/browser/ui/browser_commands.h" 58 #include "chrome/browser/ui/browser_commands.h"
59 #include "chrome/browser/ui/browser_finder.h" 59 #include "chrome/browser/ui/browser_finder.h"
60 #include "chrome/browser/ui/browser_window.h" 60 #include "chrome/browser/ui/browser_window.h"
61 #include "chrome/browser/ui/location_bar/location_bar.h" 61 #include "chrome/browser/ui/location_bar/location_bar.h"
62 #include "chrome/browser/ui/tabs/tab_strip_model.h" 62 #include "chrome/browser/ui/tabs/tab_strip_model.h"
63 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 63 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 handle(handle) { 725 handle(handle) {
726 } 726 }
727 727
728 FinalStatus final_status; 728 FinalStatus final_status;
729 base::WeakPtr<TestPrerender> handle; 729 base::WeakPtr<TestPrerender> handle;
730 }; 730 };
731 731
732 std::deque<ExpectedContents> expected_contents_queue_; 732 std::deque<ExpectedContents> expected_contents_queue_;
733 }; 733 };
734 734
735 // TODO(nparker): Switch this to use TestSafeBrowsingDatabaseManager and run
736 // with SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE.
737 // Note: don't forget to override GetProtocolManagerDelegate and return NULL,
738 // because FakeSafeBrowsingDatabaseManager does not implement
739 // LocalSafeBrowsingDatabaseManager.
740 #if defined(FULL_SAFE_BROWSING)
741 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for 735 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for
742 // a given URL. 736 // a given URL.
743 class FakeSafeBrowsingDatabaseManager 737 class FakeSafeBrowsingDatabaseManager
744 : public LocalSafeBrowsingDatabaseManager { 738 : public safe_browsing::TestSafeBrowsingDatabaseManager {
745 public: 739 public:
746 explicit FakeSafeBrowsingDatabaseManager(SafeBrowsingService* service) 740 FakeSafeBrowsingDatabaseManager() {}
747 : LocalSafeBrowsingDatabaseManager(service),
748 threat_type_(safe_browsing::SB_THREAT_TYPE_SAFE) {}
749 741
750 // Called on the IO thread to check if the given url is safe or not. If we 742 // Called on the IO thread to check if the given url is safe or not. If we
751 // can synchronously determine that the url is safe, CheckUrl returns true. 743 // can synchronously determine that the url is safe, CheckUrl returns true.
752 // Otherwise it returns false, and "client" is called asynchronously with the 744 // Otherwise it returns false, and "client" is called asynchronously with the
753 // result when it is ready. 745 // result when it is ready.
754 // Returns true, indicating a SAFE result, unless the URL is the fixed URL 746 // Returns true, indicating a SAFE result, unless the URL is the fixed URL
755 // specified by the user, and the user-specified result is not SAFE 747 // specified by the user, and the user-specified result is not SAFE
756 // (in which that result will be communicated back via a call into the 748 // (in which that result will be communicated back via a call into the
757 // client, and false will be returned). 749 // client, and false will be returned).
758 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl. 750 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl.
759 bool CheckBrowseUrl(const GURL& gurl, Client* client) override { 751 bool CheckBrowseUrl(const GURL& gurl, Client* client) override {
760 if (gurl != url_ || threat_type_ == safe_browsing::SB_THREAT_TYPE_SAFE) 752 if (badurls_.find(gurl.spec()) == badurls_.end() ||
753 badurls_[gurl.spec()] == safe_browsing::SB_THREAT_TYPE_SAFE)
761 return true; 754 return true;
mmenke 2016/05/20 20:08:37 nit: Use braces when any part of an if spans more
Jialiu Lin 2016/05/20 20:33:29 Done.
762 755
763 BrowserThread::PostTask( 756 BrowserThread::PostTask(
764 BrowserThread::IO, FROM_HERE, 757 BrowserThread::IO, FROM_HERE,
765 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, 758 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone,
766 this, gurl, client)); 759 this, gurl, client));
767 return false; 760 return false;
768 } 761 }
769 762
770 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) { 763 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) {
771 url_ = url; 764 badurls_[url.spec()] = threat_type;
772 threat_type_ = threat_type; 765 }
766
767 // These are called when checking URLs, so we implement them.
768 bool IsSupported() const override { return true; }
769 bool ChecksAreAlwaysAsync() const override { return false; }
770 bool CanCheckResourceType(
771 content::ResourceType /* resource_type */) const override {
772 return true;
773 }
774
775 bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
mmenke 2016/05/20 20:08:37 include <std>
mmenke 2016/05/20 20:25:59 Erm..set, rather
Jialiu Lin 2016/05/20 20:33:29 I figured. :-)
Jialiu Lin 2016/05/20 20:33:30 Done.
776 Client* client) override {
777 return true;
773 } 778 }
774 779
775 private: 780 private:
776 ~FakeSafeBrowsingDatabaseManager() override {} 781 ~FakeSafeBrowsingDatabaseManager() override {}
777 782
778 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { 783 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) {
779 std::vector<SBThreatType> expected_threats; 784 std::vector<SBThreatType> expected_threats;
780 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 785 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
781 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING); 786 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING);
782 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to 787 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to
783 // client->OnCheckBrowseUrlResult() 788 // client->OnCheckBrowseUrlResult()
784 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( 789 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check(
785 std::vector<GURL>(1, gurl), 790 std::vector<GURL>(1, gurl),
786 std::vector<safe_browsing::SBFullHash>(), 791 std::vector<safe_browsing::SBFullHash>(),
787 client, 792 client,
788 safe_browsing::MALWARE, 793 safe_browsing::MALWARE,
789 expected_threats); 794 expected_threats);
790 sb_check.url_results[0] = threat_type_; 795 sb_check.url_results[0] = badurls_[gurl.spec()];
791 sb_check.OnSafeBrowsingResult(); 796 sb_check.OnSafeBrowsingResult();
792 } 797 }
793 798
794 GURL url_; 799 base::hash_map<std::string, SBThreatType> badurls_;
mmenke 2016/05/20 20:08:37 bad_urls_?
mmenke 2016/05/20 20:08:37 include base/hash_map, or wherever this is declare
Jialiu Lin 2016/05/20 20:33:29 changed to std::unordered_map since hash_map is de
Jialiu Lin 2016/05/20 20:33:29 Done.
795 SBThreatType threat_type_;
796 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); 800 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager);
797 }; 801 };
798 802
799 class FakeSafeBrowsingService : public SafeBrowsingService {
800 public:
801 FakeSafeBrowsingService() { }
802
803 // Returned pointer has the same lifespan as the database_manager_ refcounted
804 // object.
805 FakeSafeBrowsingDatabaseManager* fake_database_manager() {
806 return fake_database_manager_;
807 }
808
809 protected:
810 ~FakeSafeBrowsingService() override {}
811
812 safe_browsing::SafeBrowsingDatabaseManager* CreateDatabaseManager() override {
813 fake_database_manager_ = new FakeSafeBrowsingDatabaseManager(this);
814 return fake_database_manager_;
815 }
816
817 private:
818 FakeSafeBrowsingDatabaseManager* fake_database_manager_;
819
820 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingService);
821 };
822
823 // Factory that creates FakeSafeBrowsingService instances.
824 class TestSafeBrowsingServiceFactory
825 : public safe_browsing::SafeBrowsingServiceFactory {
826 public:
827 TestSafeBrowsingServiceFactory() :
828 most_recent_service_(NULL) { }
829 ~TestSafeBrowsingServiceFactory() override {}
830
831 SafeBrowsingService* CreateSafeBrowsingService() override {
832 most_recent_service_ = new FakeSafeBrowsingService();
833 return most_recent_service_;
834 }
835
836 FakeSafeBrowsingService* most_recent_service() const {
837 return most_recent_service_;
838 }
839
840 private:
841 FakeSafeBrowsingService* most_recent_service_;
842 };
843 #endif
844
845 class FakeDevToolsClient : public content::DevToolsAgentHostClient { 803 class FakeDevToolsClient : public content::DevToolsAgentHostClient {
846 public: 804 public:
847 FakeDevToolsClient() {} 805 FakeDevToolsClient() {}
848 ~FakeDevToolsClient() override {} 806 ~FakeDevToolsClient() override {}
849 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, 807 void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
850 const std::string& message) override {} 808 const std::string& message) override {}
851 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {} 809 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {}
852 }; 810 };
853 811
854 class RestorePrerenderMode { 812 class RestorePrerenderMode {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 base::FilePath().AppendASCII(file_name)); 1072 base::FilePath().AppendASCII(file_name));
1115 } 1073 }
1116 1074
1117 } // namespace 1075 } // namespace
1118 1076
1119 class PrerenderBrowserTest : virtual public InProcessBrowserTest { 1077 class PrerenderBrowserTest : virtual public InProcessBrowserTest {
1120 public: 1078 public:
1121 PrerenderBrowserTest() 1079 PrerenderBrowserTest()
1122 : autostart_test_server_(true), 1080 : autostart_test_server_(true),
1123 prerender_contents_factory_(NULL), 1081 prerender_contents_factory_(NULL),
1124 #if defined(FULL_SAFE_BROWSING) 1082 safe_browsing_factory_(
1125 safe_browsing_factory_(new TestSafeBrowsingServiceFactory()), 1083 new safe_browsing::TestSafeBrowsingServiceFactory()),
mmenke 2016/05/20 20:08:37 Do we get anything from making this a unique_ptr?
Jialiu Lin 2016/05/20 20:33:29 agreed... I just tried to keep minimum change to t
1126 #endif
1127 call_javascript_(true), 1084 call_javascript_(true),
1128 check_load_events_(true), 1085 check_load_events_(true),
1129 loader_path_("/prerender/prerender_loader.html"), 1086 loader_path_("/prerender/prerender_loader.html"),
1130 explicitly_set_browser_(NULL) { 1087 explicitly_set_browser_(NULL) {}
1131 }
1132 1088
1133 ~PrerenderBrowserTest() override {} 1089 ~PrerenderBrowserTest() override {}
1134 1090
1135 content::SessionStorageNamespace* GetSessionStorageNamespace() const { 1091 content::SessionStorageNamespace* GetSessionStorageNamespace() const {
1136 WebContents* web_contents = GetActiveWebContents(); 1092 WebContents* web_contents = GetActiveWebContents();
1137 if (!web_contents) 1093 if (!web_contents)
1138 return NULL; 1094 return NULL;
1139 return web_contents->GetController().GetDefaultSessionStorageNamespace(); 1095 return web_contents->GetController().GetDefaultSessionStorageNamespace();
1140 } 1096 }
1141 1097
1142 void SetUpInProcessBrowserTestFixture() override { 1098 void SetUpInProcessBrowserTestFixture() override {
1143 #if defined(FULL_SAFE_BROWSING) 1099 safe_browsing_factory_->SetTestDatabaseManager(
1100 new FakeSafeBrowsingDatabaseManager());
1144 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get()); 1101 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get());
1145 #endif
1146 } 1102 }
1147 1103
1148 void TearDownInProcessBrowserTestFixture() override { 1104 void TearDownInProcessBrowserTestFixture() override {
1149 #if defined(FULL_SAFE_BROWSING)
1150 SafeBrowsingService::RegisterFactory(NULL); 1105 SafeBrowsingService::RegisterFactory(NULL);
1151 #endif
1152 } 1106 }
1153 1107
1154 void SetUpCommandLine(base::CommandLine* command_line) override { 1108 void SetUpCommandLine(base::CommandLine* command_line) override {
1155 command_line->AppendSwitchASCII(switches::kPrerenderMode, 1109 command_line->AppendSwitchASCII(switches::kPrerenderMode,
1156 switches::kPrerenderModeSwitchValueEnabled); 1110 switches::kPrerenderModeSwitchValueEnabled);
1157 command_line->AppendSwitch(switches::kEnablePepperTesting); 1111 command_line->AppendSwitch(switches::kEnablePepperTesting);
1158 command_line->AppendSwitchASCII( 1112 command_line->AppendSwitchASCII(
1159 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); 1113 switches::kOverridePluginPowerSaverForTesting, "ignore-list");
1160 1114
1161 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); 1115 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line));
1162 } 1116 }
1163 1117
1164 void SetUpOnMainThread() override { 1118 void SetUpOnMainThread() override {
1165 current_browser()->profile()->GetPrefs()->SetBoolean( 1119 current_browser()->profile()->GetPrefs()->SetBoolean(
1166 prefs::kPromptForDownload, false); 1120 prefs::kPromptForDownload, false);
1167 IncreasePrerenderMemory(); 1121 IncreasePrerenderMemory();
1168 if (autostart_test_server_) 1122 if (autostart_test_server_)
1169 ASSERT_TRUE(embedded_test_server()->Start()); 1123 ASSERT_TRUE(embedded_test_server()->Start());
1170 ChromeResourceDispatcherHostDelegate:: 1124 ChromeResourceDispatcherHostDelegate::
1171 SetExternalProtocolHandlerDelegateForTesting( 1125 SetExternalProtocolHandlerDelegateForTesting(
1172 &external_protocol_handler_delegate_); 1126 &external_protocol_handler_delegate_);
1173 1127
1174 PrerenderManager* prerender_manager = GetPrerenderManager(); 1128 PrerenderManager* prerender_manager = GetPrerenderManager();
1175 ASSERT_TRUE(prerender_manager); 1129 ASSERT_TRUE(prerender_manager);
1176 prerender_manager->mutable_config().rate_limit_enabled = false; 1130 prerender_manager->mutable_config().rate_limit_enabled = false;
1177 ASSERT_TRUE(prerender_contents_factory_ == NULL); 1131 ASSERT_TRUE(prerender_contents_factory_ == NULL);
1178 prerender_contents_factory_ = new TestPrerenderContentsFactory; 1132 prerender_contents_factory_ = new TestPrerenderContentsFactory;
1179 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_); 1133 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_);
1134 ASSERT_TRUE(safe_browsing_factory_->test_safe_browsing_service());
1180 } 1135 }
1181 1136
1182 // Convenience function to get the currently active WebContents in 1137 // Convenience function to get the currently active WebContents in
1183 // current_browser(). 1138 // current_browser().
1184 WebContents* GetActiveWebContents() const { 1139 WebContents* GetActiveWebContents() const {
1185 return current_browser()->tab_strip_model()->GetActiveWebContents(); 1140 return current_browser()->tab_strip_model()->GetActiveWebContents();
1186 } 1141 }
1187 1142
1188 // Overload for a single expected final status 1143 // Overload for a single expected final status
1189 std::unique_ptr<TestPrerender> PrerenderTestURL( 1144 std::unique_ptr<TestPrerender> PrerenderTestURL(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 static_cast<base::DictionaryValue*>( 1417 static_cast<base::DictionaryValue*>(
1463 GetPrerenderManager()->GetAsValue())); 1418 GetPrerenderManager()->GetAsValue()));
1464 if (!prerender_dict.get()) 1419 if (!prerender_dict.get())
1465 return -1; 1420 return -1;
1466 base::ListValue* history_list; 1421 base::ListValue* history_list;
1467 if (!prerender_dict->GetList("history", &history_list)) 1422 if (!prerender_dict->GetList("history", &history_list))
1468 return -1; 1423 return -1;
1469 return static_cast<int>(history_list->GetSize()); 1424 return static_cast<int>(history_list->GetSize());
1470 } 1425 }
1471 1426
1472 #if defined(FULL_SAFE_BROWSING)
1473 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() { 1427 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() {
1474 return safe_browsing_factory_->most_recent_service()-> 1428 return static_cast<FakeSafeBrowsingDatabaseManager*>(
1475 fake_database_manager(); 1429 safe_browsing_factory_->test_safe_browsing_service()
1430 ->database_manager()
1431 .get());
1476 } 1432 }
1477 #endif
1478 1433
1479 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const { 1434 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const {
1480 PrerenderManager::PrerenderData* prerender_data = 1435 PrerenderManager::PrerenderData* prerender_data =
1481 GetPrerenderManager()->FindPrerenderData(url, NULL); 1436 GetPrerenderManager()->FindPrerenderData(url, NULL);
1482 return static_cast<TestPrerenderContents*>( 1437 return static_cast<TestPrerenderContents*>(
1483 prerender_data ? prerender_data->contents() : NULL); 1438 prerender_data ? prerender_data->contents() : NULL);
1484 } 1439 }
1485 1440
1486 void SetLoaderHostOverride(const std::string& host) { 1441 void SetLoaderHostOverride(const std::string& host) {
1487 loader_host_override_ = host; 1442 loader_host_override_ = host;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 } else { 1659 } else {
1705 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), 1660 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(),
1706 web_contents); 1661 web_contents);
1707 render_frame_host->ExecuteJavaScriptForTests( 1662 render_frame_host->ExecuteJavaScriptForTests(
1708 base::ASCIIToUTF16(javascript)); 1663 base::ASCIIToUTF16(javascript));
1709 observer.Wait(); 1664 observer.Wait();
1710 } 1665 }
1711 } 1666 }
1712 1667
1713 TestPrerenderContentsFactory* prerender_contents_factory_; 1668 TestPrerenderContentsFactory* prerender_contents_factory_;
1714 #if defined(FULL_SAFE_BROWSING) 1669 std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory>
1715 std::unique_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; 1670 safe_browsing_factory_;
1716 #endif
1717 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; 1671 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_;
1718 GURL dest_url_; 1672 GURL dest_url_;
1719 std::unique_ptr<net::EmbeddedTestServer> https_src_server_; 1673 std::unique_ptr<net::EmbeddedTestServer> https_src_server_;
1720 bool call_javascript_; 1674 bool call_javascript_;
1721 bool check_load_events_; 1675 bool check_load_events_;
1722 std::string loader_host_override_; 1676 std::string loader_host_override_;
1723 std::string loader_path_; 1677 std::string loader_path_;
1724 std::string loader_query_; 1678 std::string loader_query_;
1725 Browser* explicitly_set_browser_; 1679 Browser* explicitly_set_browser_;
1726 base::HistogramTester histogram_tester_; 1680 base::HistogramTester histogram_tester_;
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 std::make_pair("REPLACE_WITH_URL", https_url.spec())); 2922 std::make_pair("REPLACE_WITH_URL", https_url.spec()));
2969 std::string replacement_path; 2923 std::string replacement_path;
2970 net::test_server::GetFilePathWithReplacements( 2924 net::test_server::GetFilePathWithReplacements(
2971 "/prerender/prerender_with_iframe.html", replacement_text, 2925 "/prerender/prerender_with_iframe.html", replacement_text,
2972 &replacement_path); 2926 &replacement_path);
2973 PrerenderTestURL(replacement_path, 2927 PrerenderTestURL(replacement_path,
2974 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 2928 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED,
2975 0); 2929 0);
2976 } 2930 }
2977 2931
2978 #if defined(FULL_SAFE_BROWSING)
2979 // Ensures that we do not prerender pages with a safe browsing 2932 // Ensures that we do not prerender pages with a safe browsing
2980 // interstitial. 2933 // interstitial.
2981 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) { 2934 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) {
2982 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html"); 2935 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html");
2983 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( 2936 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl(
2984 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 2937 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
2985 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING, 2938 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING,
2986 0); 2939 0);
2987 } 2940 }
2988 2941
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 std::make_pair("REPLACE_WITH_URL", iframe_url.spec())); 2987 std::make_pair("REPLACE_WITH_URL", iframe_url.spec()));
3035 std::string replacement_path; 2988 std::string replacement_path;
3036 net::test_server::GetFilePathWithReplacements( 2989 net::test_server::GetFilePathWithReplacements(
3037 "/prerender/prerender_with_iframe.html", replacement_text, 2990 "/prerender/prerender_with_iframe.html", replacement_text,
3038 &replacement_path); 2991 &replacement_path);
3039 PrerenderTestURL(replacement_path, 2992 PrerenderTestURL(replacement_path,
3040 FINAL_STATUS_SAFE_BROWSING, 2993 FINAL_STATUS_SAFE_BROWSING,
3041 0); 2994 0);
3042 } 2995 }
3043 2996
3044 #endif
3045
3046 // Checks that a local storage read will not cause prerender to fail. 2997 // Checks that a local storage read will not cause prerender to fail.
3047 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) { 2998 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) {
3048 PrerenderTestURL("/prerender/prerender_localstorage_read.html", 2999 PrerenderTestURL("/prerender/prerender_localstorage_read.html",
3049 FINAL_STATUS_USED, 1); 3000 FINAL_STATUS_USED, 1);
3050 NavigateToDestURL(); 3001 NavigateToDestURL();
3051 } 3002 }
3052 3003
3053 // Checks that a local storage write will not cause prerender to fail. 3004 // Checks that a local storage write will not cause prerender to fail.
3054 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { 3005 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) {
3055 PrerenderTestURL("/prerender/prerender_localstorage_write.html", 3006 PrerenderTestURL("/prerender/prerender_localstorage_write.html",
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 browser()->tab_strip_model()->GetActiveWebContents(); 3921 browser()->tab_strip_model()->GetActiveWebContents();
3971 bool display_test_result = false; 3922 bool display_test_result = false;
3972 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3923 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3973 "DidDisplayReallyPass()", 3924 "DidDisplayReallyPass()",
3974 &display_test_result)); 3925 &display_test_result));
3975 ASSERT_TRUE(display_test_result); 3926 ASSERT_TRUE(display_test_result);
3976 } 3927 }
3977 #endif // !defined(DISABLE_NACL) 3928 #endif // !defined(DISABLE_NACL)
3978 3929
3979 } // namespace prerender 3930 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698