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

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: nits 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 <set>
8 #include <string>
9 #include <unordered_map>
7 #include <utility> 10 #include <utility>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/command_line.h" 14 #include "base/command_line.h"
12 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
13 #include "base/macros.h" 16 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
16 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
(...skipping 26 matching lines...) Expand all
43 #include "chrome/browser/prerender/prerender_field_trial.h" 46 #include "chrome/browser/prerender/prerender_field_trial.h"
44 #include "chrome/browser/prerender/prerender_handle.h" 47 #include "chrome/browser/prerender/prerender_handle.h"
45 #include "chrome/browser/prerender/prerender_link_manager.h" 48 #include "chrome/browser/prerender/prerender_link_manager.h"
46 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 49 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
47 #include "chrome/browser/prerender/prerender_manager.h" 50 #include "chrome/browser/prerender/prerender_manager.h"
48 #include "chrome/browser/prerender/prerender_manager_factory.h" 51 #include "chrome/browser/prerender/prerender_manager_factory.h"
49 #include "chrome/browser/profiles/profile.h" 52 #include "chrome/browser/profiles/profile.h"
50 #include "chrome/browser/profiles/profile_io_data.h" 53 #include "chrome/browser/profiles/profile_io_data.h"
51 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 54 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
52 #include "chrome/browser/safe_browsing/local_database_manager.h" 55 #include "chrome/browser/safe_browsing/local_database_manager.h"
53 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 56 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
54 #include "chrome/browser/task_management/mock_web_contents_task_manager.h" 57 #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" 58 #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" 59 #include "chrome/browser/task_management/task_manager_browsertest_util.h"
57 #include "chrome/browser/ui/browser.h" 60 #include "chrome/browser/ui/browser.h"
58 #include "chrome/browser/ui/browser_commands.h" 61 #include "chrome/browser/ui/browser_commands.h"
59 #include "chrome/browser/ui/browser_finder.h" 62 #include "chrome/browser/ui/browser_finder.h"
60 #include "chrome/browser/ui/browser_window.h" 63 #include "chrome/browser/ui/browser_window.h"
61 #include "chrome/browser/ui/location_bar/location_bar.h" 64 #include "chrome/browser/ui/location_bar/location_bar.h"
62 #include "chrome/browser/ui/tabs/tab_strip_model.h" 65 #include "chrome/browser/ui/tabs/tab_strip_model.h"
63 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 66 #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) { 728 handle(handle) {
726 } 729 }
727 730
728 FinalStatus final_status; 731 FinalStatus final_status;
729 base::WeakPtr<TestPrerender> handle; 732 base::WeakPtr<TestPrerender> handle;
730 }; 733 };
731 734
732 std::deque<ExpectedContents> expected_contents_queue_; 735 std::deque<ExpectedContents> expected_contents_queue_;
733 }; 736 };
734 737
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 738 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for
742 // a given URL. 739 // a given URL.
743 class FakeSafeBrowsingDatabaseManager 740 class FakeSafeBrowsingDatabaseManager
744 : public LocalSafeBrowsingDatabaseManager { 741 : public safe_browsing::TestSafeBrowsingDatabaseManager {
745 public: 742 public:
746 explicit FakeSafeBrowsingDatabaseManager(SafeBrowsingService* service) 743 FakeSafeBrowsingDatabaseManager() {}
747 : LocalSafeBrowsingDatabaseManager(service),
748 threat_type_(safe_browsing::SB_THREAT_TYPE_SAFE) {}
749 744
750 // Called on the IO thread to check if the given url is safe or not. If we 745 // 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. 746 // can synchronously determine that the url is safe, CheckUrl returns true.
752 // Otherwise it returns false, and "client" is called asynchronously with the 747 // Otherwise it returns false, and "client" is called asynchronously with the
753 // result when it is ready. 748 // result when it is ready.
754 // Returns true, indicating a SAFE result, unless the URL is the fixed URL 749 // 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 750 // 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 751 // (in which that result will be communicated back via a call into the
757 // client, and false will be returned). 752 // client, and false will be returned).
758 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl. 753 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl.
759 bool CheckBrowseUrl(const GURL& gurl, Client* client) override { 754 bool CheckBrowseUrl(const GURL& gurl, Client* client) override {
760 if (gurl != url_ || threat_type_ == safe_browsing::SB_THREAT_TYPE_SAFE) 755 if (bad_urls_.find(gurl.spec()) == bad_urls_.end() ||
756 bad_urls_[gurl.spec()] == safe_browsing::SB_THREAT_TYPE_SAFE) {
761 return true; 757 return true;
758 }
762 759
763 BrowserThread::PostTask( 760 BrowserThread::PostTask(
764 BrowserThread::IO, FROM_HERE, 761 BrowserThread::IO, FROM_HERE,
765 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, 762 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone,
766 this, gurl, client)); 763 this, gurl, client));
767 return false; 764 return false;
768 } 765 }
769 766
770 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) { 767 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) {
771 url_ = url; 768 bad_urls_[url.spec()] = threat_type;
772 threat_type_ = threat_type; 769 }
770
771 // These are called when checking URLs, so we implement them.
772 bool IsSupported() const override { return true; }
773 bool ChecksAreAlwaysAsync() const override { return false; }
774 bool CanCheckResourceType(
775 content::ResourceType /* resource_type */) const override {
776 return true;
777 }
778
779 bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
780 Client* client) override {
781 return true;
773 } 782 }
774 783
775 private: 784 private:
776 ~FakeSafeBrowsingDatabaseManager() override {} 785 ~FakeSafeBrowsingDatabaseManager() override {}
777 786
778 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { 787 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) {
779 std::vector<SBThreatType> expected_threats; 788 std::vector<SBThreatType> expected_threats;
780 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 789 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
781 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING); 790 expected_threats.push_back(safe_browsing::SB_THREAT_TYPE_URL_PHISHING);
782 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to 791 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to
783 // client->OnCheckBrowseUrlResult() 792 // client->OnCheckBrowseUrlResult()
784 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( 793 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check(
785 std::vector<GURL>(1, gurl), 794 std::vector<GURL>(1, gurl),
786 std::vector<safe_browsing::SBFullHash>(), 795 std::vector<safe_browsing::SBFullHash>(),
787 client, 796 client,
788 safe_browsing::MALWARE, 797 safe_browsing::MALWARE,
789 expected_threats); 798 expected_threats);
790 sb_check.url_results[0] = threat_type_; 799 sb_check.url_results[0] = bad_urls_[gurl.spec()];
791 sb_check.OnSafeBrowsingResult(); 800 sb_check.OnSafeBrowsingResult();
792 } 801 }
793 802
794 GURL url_; 803 std::unordered_map<std::string, SBThreatType> bad_urls_;
795 SBThreatType threat_type_;
796 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); 804 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager);
797 }; 805 };
798 806
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 { 807 class FakeDevToolsClient : public content::DevToolsAgentHostClient {
846 public: 808 public:
847 FakeDevToolsClient() {} 809 FakeDevToolsClient() {}
848 ~FakeDevToolsClient() override {} 810 ~FakeDevToolsClient() override {}
849 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, 811 void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
850 const std::string& message) override {} 812 const std::string& message) override {}
851 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {} 813 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override {}
852 }; 814 };
853 815
854 class RestorePrerenderMode { 816 class RestorePrerenderMode {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 base::FilePath().AppendASCII(file_name)); 1076 base::FilePath().AppendASCII(file_name));
1115 } 1077 }
1116 1078
1117 } // namespace 1079 } // namespace
1118 1080
1119 class PrerenderBrowserTest : virtual public InProcessBrowserTest { 1081 class PrerenderBrowserTest : virtual public InProcessBrowserTest {
1120 public: 1082 public:
1121 PrerenderBrowserTest() 1083 PrerenderBrowserTest()
1122 : autostart_test_server_(true), 1084 : autostart_test_server_(true),
1123 prerender_contents_factory_(NULL), 1085 prerender_contents_factory_(NULL),
1124 #if defined(FULL_SAFE_BROWSING) 1086 safe_browsing_factory_(
1125 safe_browsing_factory_(new TestSafeBrowsingServiceFactory()), 1087 new safe_browsing::TestSafeBrowsingServiceFactory()),
1126 #endif
1127 call_javascript_(true), 1088 call_javascript_(true),
1128 check_load_events_(true), 1089 check_load_events_(true),
1129 loader_path_("/prerender/prerender_loader.html"), 1090 loader_path_("/prerender/prerender_loader.html"),
1130 explicitly_set_browser_(NULL) { 1091 explicitly_set_browser_(NULL) {}
1131 }
1132 1092
1133 ~PrerenderBrowserTest() override {} 1093 ~PrerenderBrowserTest() override {}
1134 1094
1135 content::SessionStorageNamespace* GetSessionStorageNamespace() const { 1095 content::SessionStorageNamespace* GetSessionStorageNamespace() const {
1136 WebContents* web_contents = GetActiveWebContents(); 1096 WebContents* web_contents = GetActiveWebContents();
1137 if (!web_contents) 1097 if (!web_contents)
1138 return NULL; 1098 return NULL;
1139 return web_contents->GetController().GetDefaultSessionStorageNamespace(); 1099 return web_contents->GetController().GetDefaultSessionStorageNamespace();
1140 } 1100 }
1141 1101
1142 void SetUpInProcessBrowserTestFixture() override { 1102 void SetUpInProcessBrowserTestFixture() override {
1143 #if defined(FULL_SAFE_BROWSING) 1103 safe_browsing_factory_->SetTestDatabaseManager(
1144 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get()); 1104 new FakeSafeBrowsingDatabaseManager());
1145 #endif 1105 SafeBrowsingService::RegisterFactory(safe_browsing_factory_);
1146 } 1106 }
1147 1107
1148 void TearDownInProcessBrowserTestFixture() override { 1108 void TearDownInProcessBrowserTestFixture() override {
1149 #if defined(FULL_SAFE_BROWSING)
1150 SafeBrowsingService::RegisterFactory(NULL); 1109 SafeBrowsingService::RegisterFactory(NULL);
1151 #endif
1152 } 1110 }
1153 1111
1154 void SetUpCommandLine(base::CommandLine* command_line) override { 1112 void SetUpCommandLine(base::CommandLine* command_line) override {
1155 command_line->AppendSwitchASCII(switches::kPrerenderMode, 1113 command_line->AppendSwitchASCII(switches::kPrerenderMode,
1156 switches::kPrerenderModeSwitchValueEnabled); 1114 switches::kPrerenderModeSwitchValueEnabled);
1157 command_line->AppendSwitch(switches::kEnablePepperTesting); 1115 command_line->AppendSwitch(switches::kEnablePepperTesting);
1158 command_line->AppendSwitchASCII( 1116 command_line->AppendSwitchASCII(
1159 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); 1117 switches::kOverridePluginPowerSaverForTesting, "ignore-list");
1160 1118
1161 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); 1119 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line));
1162 } 1120 }
1163 1121
1164 void SetUpOnMainThread() override { 1122 void SetUpOnMainThread() override {
1165 current_browser()->profile()->GetPrefs()->SetBoolean( 1123 current_browser()->profile()->GetPrefs()->SetBoolean(
1166 prefs::kPromptForDownload, false); 1124 prefs::kPromptForDownload, false);
1167 IncreasePrerenderMemory(); 1125 IncreasePrerenderMemory();
1168 if (autostart_test_server_) 1126 if (autostart_test_server_)
1169 ASSERT_TRUE(embedded_test_server()->Start()); 1127 ASSERT_TRUE(embedded_test_server()->Start());
1170 ChromeResourceDispatcherHostDelegate:: 1128 ChromeResourceDispatcherHostDelegate::
1171 SetExternalProtocolHandlerDelegateForTesting( 1129 SetExternalProtocolHandlerDelegateForTesting(
1172 &external_protocol_handler_delegate_); 1130 &external_protocol_handler_delegate_);
1173 1131
1174 PrerenderManager* prerender_manager = GetPrerenderManager(); 1132 PrerenderManager* prerender_manager = GetPrerenderManager();
1175 ASSERT_TRUE(prerender_manager); 1133 ASSERT_TRUE(prerender_manager);
1176 prerender_manager->mutable_config().rate_limit_enabled = false; 1134 prerender_manager->mutable_config().rate_limit_enabled = false;
1177 ASSERT_TRUE(prerender_contents_factory_ == NULL); 1135 ASSERT_TRUE(prerender_contents_factory_ == NULL);
1178 prerender_contents_factory_ = new TestPrerenderContentsFactory; 1136 prerender_contents_factory_ = new TestPrerenderContentsFactory;
1179 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_); 1137 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_);
1138 ASSERT_TRUE(safe_browsing_factory_->test_safe_browsing_service());
1180 } 1139 }
1181 1140
1182 // Convenience function to get the currently active WebContents in 1141 // Convenience function to get the currently active WebContents in
1183 // current_browser(). 1142 // current_browser().
1184 WebContents* GetActiveWebContents() const { 1143 WebContents* GetActiveWebContents() const {
1185 return current_browser()->tab_strip_model()->GetActiveWebContents(); 1144 return current_browser()->tab_strip_model()->GetActiveWebContents();
1186 } 1145 }
1187 1146
1188 // Overload for a single expected final status 1147 // Overload for a single expected final status
1189 std::unique_ptr<TestPrerender> PrerenderTestURL( 1148 std::unique_ptr<TestPrerender> PrerenderTestURL(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 static_cast<base::DictionaryValue*>( 1421 static_cast<base::DictionaryValue*>(
1463 GetPrerenderManager()->GetAsValue())); 1422 GetPrerenderManager()->GetAsValue()));
1464 if (!prerender_dict.get()) 1423 if (!prerender_dict.get())
1465 return -1; 1424 return -1;
1466 base::ListValue* history_list; 1425 base::ListValue* history_list;
1467 if (!prerender_dict->GetList("history", &history_list)) 1426 if (!prerender_dict->GetList("history", &history_list))
1468 return -1; 1427 return -1;
1469 return static_cast<int>(history_list->GetSize()); 1428 return static_cast<int>(history_list->GetSize());
1470 } 1429 }
1471 1430
1472 #if defined(FULL_SAFE_BROWSING)
1473 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() { 1431 FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager() {
1474 return safe_browsing_factory_->most_recent_service()-> 1432 return static_cast<FakeSafeBrowsingDatabaseManager*>(
1475 fake_database_manager(); 1433 safe_browsing_factory_->test_safe_browsing_service()
1434 ->database_manager()
1435 .get());
1476 } 1436 }
1477 #endif
1478 1437
1479 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const { 1438 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const {
1480 PrerenderManager::PrerenderData* prerender_data = 1439 PrerenderManager::PrerenderData* prerender_data =
1481 GetPrerenderManager()->FindPrerenderData(url, NULL); 1440 GetPrerenderManager()->FindPrerenderData(url, NULL);
1482 return static_cast<TestPrerenderContents*>( 1441 return static_cast<TestPrerenderContents*>(
1483 prerender_data ? prerender_data->contents() : NULL); 1442 prerender_data ? prerender_data->contents() : NULL);
1484 } 1443 }
1485 1444
1486 void SetLoaderHostOverride(const std::string& host) { 1445 void SetLoaderHostOverride(const std::string& host) {
1487 loader_host_override_ = host; 1446 loader_host_override_ = host;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 } else { 1663 } else {
1705 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), 1664 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(),
1706 web_contents); 1665 web_contents);
1707 render_frame_host->ExecuteJavaScriptForTests( 1666 render_frame_host->ExecuteJavaScriptForTests(
1708 base::ASCIIToUTF16(javascript)); 1667 base::ASCIIToUTF16(javascript));
1709 observer.Wait(); 1668 observer.Wait();
1710 } 1669 }
1711 } 1670 }
1712 1671
1713 TestPrerenderContentsFactory* prerender_contents_factory_; 1672 TestPrerenderContentsFactory* prerender_contents_factory_;
1714 #if defined(FULL_SAFE_BROWSING) 1673 safe_browsing::TestSafeBrowsingServiceFactory* safe_browsing_factory_;
1715 std::unique_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_;
1716 #endif
1717 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; 1674 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_;
1718 GURL dest_url_; 1675 GURL dest_url_;
1719 std::unique_ptr<net::EmbeddedTestServer> https_src_server_; 1676 std::unique_ptr<net::EmbeddedTestServer> https_src_server_;
1720 bool call_javascript_; 1677 bool call_javascript_;
1721 bool check_load_events_; 1678 bool check_load_events_;
1722 std::string loader_host_override_; 1679 std::string loader_host_override_;
1723 std::string loader_path_; 1680 std::string loader_path_;
1724 std::string loader_query_; 1681 std::string loader_query_;
1725 Browser* explicitly_set_browser_; 1682 Browser* explicitly_set_browser_;
1726 base::HistogramTester histogram_tester_; 1683 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())); 2925 std::make_pair("REPLACE_WITH_URL", https_url.spec()));
2969 std::string replacement_path; 2926 std::string replacement_path;
2970 net::test_server::GetFilePathWithReplacements( 2927 net::test_server::GetFilePathWithReplacements(
2971 "/prerender/prerender_with_iframe.html", replacement_text, 2928 "/prerender/prerender_with_iframe.html", replacement_text,
2972 &replacement_path); 2929 &replacement_path);
2973 PrerenderTestURL(replacement_path, 2930 PrerenderTestURL(replacement_path,
2974 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 2931 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED,
2975 0); 2932 0);
2976 } 2933 }
2977 2934
2978 #if defined(FULL_SAFE_BROWSING)
2979 // Ensures that we do not prerender pages with a safe browsing 2935 // Ensures that we do not prerender pages with a safe browsing
2980 // interstitial. 2936 // interstitial.
2981 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) { 2937 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) {
2982 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html"); 2938 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html");
2983 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( 2939 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl(
2984 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE); 2940 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
2985 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING, 2941 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_SAFE_BROWSING,
2986 0); 2942 0);
2987 } 2943 }
2988 2944
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 std::make_pair("REPLACE_WITH_URL", iframe_url.spec())); 2990 std::make_pair("REPLACE_WITH_URL", iframe_url.spec()));
3035 std::string replacement_path; 2991 std::string replacement_path;
3036 net::test_server::GetFilePathWithReplacements( 2992 net::test_server::GetFilePathWithReplacements(
3037 "/prerender/prerender_with_iframe.html", replacement_text, 2993 "/prerender/prerender_with_iframe.html", replacement_text,
3038 &replacement_path); 2994 &replacement_path);
3039 PrerenderTestURL(replacement_path, 2995 PrerenderTestURL(replacement_path,
3040 FINAL_STATUS_SAFE_BROWSING, 2996 FINAL_STATUS_SAFE_BROWSING,
3041 0); 2997 0);
3042 } 2998 }
3043 2999
3044 #endif
3045
3046 // Checks that a local storage read will not cause prerender to fail. 3000 // Checks that a local storage read will not cause prerender to fail.
3047 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) { 3001 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageRead) {
3048 PrerenderTestURL("/prerender/prerender_localstorage_read.html", 3002 PrerenderTestURL("/prerender/prerender_localstorage_read.html",
3049 FINAL_STATUS_USED, 1); 3003 FINAL_STATUS_USED, 1);
3050 NavigateToDestURL(); 3004 NavigateToDestURL();
3051 } 3005 }
3052 3006
3053 // Checks that a local storage write will not cause prerender to fail. 3007 // Checks that a local storage write will not cause prerender to fail.
3054 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { 3008 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) {
3055 PrerenderTestURL("/prerender/prerender_localstorage_write.html", 3009 PrerenderTestURL("/prerender/prerender_localstorage_write.html",
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 browser()->tab_strip_model()->GetActiveWebContents(); 3924 browser()->tab_strip_model()->GetActiveWebContents();
3971 bool display_test_result = false; 3925 bool display_test_result = false;
3972 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3926 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3973 "DidDisplayReallyPass()", 3927 "DidDisplayReallyPass()",
3974 &display_test_result)); 3928 &display_test_result));
3975 ASSERT_TRUE(display_test_result); 3929 ASSERT_TRUE(display_test_result);
3976 } 3930 }
3977 #endif // !defined(DISABLE_NACL) 3931 #endif // !defined(DISABLE_NACL)
3978 3932
3979 } // namespace prerender 3933 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698