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

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

Issue 2304953002: NoState Prefetch: nostate prefetch browser tests. (Closed)
Patch Set: Remove final_status.cc as it had only formatting changes. Created 4 years, 2 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 | chrome/browser/prerender/prerender_contents.h » ('j') | 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <deque> 6 #include <deque>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "base/scoped_observer.h" 22 #include "base/scoped_observer.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "base/test/histogram_tester.h"
29 #include "base/test/scoped_feature_list.h" 28 #include "base/test/scoped_feature_list.h"
30 #include "base/test/test_timeouts.h" 29 #include "base/test/test_timeouts.h"
31 #include "base/values.h" 30 #include "base/values.h"
32 #include "build/build_config.h" 31 #include "build/build_config.h"
33 #include "chrome/browser/browsing_data/browsing_data_helper.h" 32 #include "chrome/browser/browsing_data/browsing_data_helper.h"
34 #include "chrome/browser/browsing_data/browsing_data_remover.h" 33 #include "chrome/browser/browsing_data/browsing_data_remover.h"
35 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" 34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
36 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
37 #include "chrome/browser/chrome_content_browser_client.h" 36 #include "chrome/browser/chrome_content_browser_client.h"
38 #include "chrome/browser/chrome_notification_types.h" 37 #include "chrome/browser/chrome_notification_types.h"
(...skipping 20 matching lines...) Expand all
59 #include "chrome/browser/ui/browser.h" 58 #include "chrome/browser/ui/browser.h"
60 #include "chrome/browser/ui/browser_commands.h" 59 #include "chrome/browser/ui/browser_commands.h"
61 #include "chrome/browser/ui/browser_finder.h" 60 #include "chrome/browser/ui/browser_finder.h"
62 #include "chrome/browser/ui/browser_window.h" 61 #include "chrome/browser/ui/browser_window.h"
63 #include "chrome/browser/ui/location_bar/location_bar.h" 62 #include "chrome/browser/ui/location_bar/location_bar.h"
64 #include "chrome/browser/ui/tabs/tab_strip_model.h" 63 #include "chrome/browser/ui/tabs/tab_strip_model.h"
65 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 64 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
66 #include "chrome/common/chrome_features.h" 65 #include "chrome/common/chrome_features.h"
67 #include "chrome/common/chrome_paths.h" 66 #include "chrome/common/chrome_paths.h"
68 #include "chrome/common/chrome_switches.h" 67 #include "chrome/common/chrome_switches.h"
69 #include "chrome/grit/generated_resources.h"
70 #include "chrome/test/base/ui_test_utils.h" 68 #include "chrome/test/base/ui_test_utils.h"
71 #include "components/content_settings/core/browser/host_content_settings_map.h" 69 #include "components/content_settings/core/browser/host_content_settings_map.h"
72 #include "components/favicon/content/content_favicon_driver.h" 70 #include "components/favicon/content/content_favicon_driver.h"
73 #include "components/favicon/core/favicon_driver_observer.h" 71 #include "components/favicon/core/favicon_driver_observer.h"
74 #include "components/omnibox/browser/omnibox_edit_model.h" 72 #include "components/omnibox/browser/omnibox_edit_model.h"
75 #include "components/omnibox/browser/omnibox_popup_model.h" 73 #include "components/omnibox/browser/omnibox_popup_model.h"
76 #include "components/omnibox/browser/omnibox_view.h" 74 #include "components/omnibox/browser/omnibox_view.h"
77 #include "components/safe_browsing_db/database_manager.h" 75 #include "components/safe_browsing_db/database_manager.h"
78 #include "components/safe_browsing_db/util.h" 76 #include "components/safe_browsing_db/util.h"
79 #include "components/variations/entropy_provider.h" 77 #include "components/variations/entropy_provider.h"
(...skipping 30 matching lines...) Expand all
110 #include "net/test/cert_test_util.h" 108 #include "net/test/cert_test_util.h"
111 #include "net/test/embedded_test_server/embedded_test_server.h" 109 #include "net/test/embedded_test_server/embedded_test_server.h"
112 #include "net/test/embedded_test_server/request_handler_util.h" 110 #include "net/test/embedded_test_server/request_handler_util.h"
113 #include "net/test/test_data_directory.h" 111 #include "net/test/test_data_directory.h"
114 #include "net/url_request/url_request_context.h" 112 #include "net/url_request/url_request_context.h"
115 #include "net/url_request/url_request_context_getter.h" 113 #include "net/url_request/url_request_context_getter.h"
116 #include "net/url_request/url_request_filter.h" 114 #include "net/url_request/url_request_filter.h"
117 #include "net/url_request/url_request_job.h" 115 #include "net/url_request/url_request_job.h"
118 #include "testing/gmock/include/gmock/gmock.h" 116 #include "testing/gmock/include/gmock/gmock.h"
119 #include "testing/gtest/include/gtest/gtest.h" 117 #include "testing/gtest/include/gtest/gtest.h"
120 #include "ui/base/l10n/l10n_util.h"
121 #include "url/gurl.h" 118 #include "url/gurl.h"
122 119
123 using chrome_browser_net::NetworkPredictionOptions; 120 using chrome_browser_net::NetworkPredictionOptions;
124 using content::BrowserThread; 121 using content::BrowserThread;
125 using content::DevToolsAgentHost; 122 using content::DevToolsAgentHost;
126 using content::NavigationController; 123 using content::NavigationController;
127 using content::OpenURLParams; 124 using content::OpenURLParams;
128 using content::Referrer; 125 using content::Referrer;
129 using content::RenderFrameHost; 126 using content::RenderFrameHost;
130 using content::RenderViewHost; 127 using content::RenderViewHost;
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 chrome::GoBack(current_browser(), WindowOpenDisposition::CURRENT_TAB); 735 chrome::GoBack(current_browser(), WindowOpenDisposition::CURRENT_TAB);
739 back_nav_observer.Wait(); 736 back_nav_observer.Wait();
740 bool js_result; 737 bool js_result;
741 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 738 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
742 tab, 739 tab,
743 "window.domAutomationController.send(DidBackToOriginalPagePass())", 740 "window.domAutomationController.send(DidBackToOriginalPagePass())",
744 &js_result)); 741 &js_result));
745 EXPECT_TRUE(js_result); 742 EXPECT_TRUE(js_result);
746 } 743 }
747 744
748 void UseHttpsSrcServer() {
749 if (https_src_server_)
750 return;
751 https_src_server_.reset(
752 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
753 https_src_server_->ServeFilesFromSourceDirectory("chrome/test/data");
754 CHECK(https_src_server_->Start());
755 }
756
757 void DisableJavascriptCalls() { 745 void DisableJavascriptCalls() {
758 call_javascript_ = false; 746 call_javascript_ = false;
759 } 747 }
760 748
761 void DisableLoadEventCheck() { 749 void DisableLoadEventCheck() {
762 check_load_events_ = false; 750 check_load_events_ = false;
763 } 751 }
764 752
765 const PrerenderLinkManager* GetPrerenderLinkManager() const { 753 const PrerenderLinkManager* GetPrerenderLinkManager() const {
766 PrerenderLinkManager* prerender_link_manager = 754 PrerenderLinkManager* prerender_link_manager =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 std::unique_ptr<base::DictionaryValue> prerender_dict = 833 std::unique_ptr<base::DictionaryValue> prerender_dict =
846 GetPrerenderManager()->GetAsValue(); 834 GetPrerenderManager()->GetAsValue();
847 if (!prerender_dict) 835 if (!prerender_dict)
848 return std::numeric_limits<size_t>::max(); 836 return std::numeric_limits<size_t>::max();
849 base::ListValue* history_list; 837 base::ListValue* history_list;
850 if (!prerender_dict->GetList("history", &history_list)) 838 if (!prerender_dict->GetList("history", &history_list))
851 return std::numeric_limits<size_t>::max(); 839 return std::numeric_limits<size_t>::max();
852 return history_list->GetSize(); 840 return history_list->GetSize();
853 } 841 }
854 842
855 test_utils::FakeSafeBrowsingDatabaseManager*
856 GetFakeSafeBrowsingDatabaseManager() {
857 return static_cast<test_utils::FakeSafeBrowsingDatabaseManager*>(
858 safe_browsing_factory()
859 ->test_safe_browsing_service()
860 ->database_manager()
861 .get());
862 }
863
864 void SetLoaderHostOverride(const std::string& host) { 843 void SetLoaderHostOverride(const std::string& host) {
865 loader_host_override_ = host; 844 loader_host_override_ = host;
866 host_resolver()->AddRule(host, "127.0.0.1"); 845 host_resolver()->AddRule(host, "127.0.0.1");
867 } 846 }
868 847
869 void set_loader_path(const std::string& path) { 848 void set_loader_path(const std::string& path) {
870 loader_path_ = path; 849 loader_path_ = path;
871 } 850 }
872 851
873 void set_loader_query(const std::string& query) { 852 void set_loader_query(const std::string& query) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 } 893 }
915 894
916 void AddPrerender(const GURL& url, int index) { 895 void AddPrerender(const GURL& url, int index) {
917 std::string javascript = base::StringPrintf( 896 std::string javascript = base::StringPrintf(
918 "AddPrerender('%s', %d)", url.spec().c_str(), index); 897 "AddPrerender('%s', %d)", url.spec().c_str(), index);
919 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); 898 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame();
920 render_frame_host->ExecuteJavaScriptForTests( 899 render_frame_host->ExecuteJavaScriptForTests(
921 base::ASCIIToUTF16(javascript)); 900 base::ASCIIToUTF16(javascript));
922 } 901 }
923 902
924 // Returns a string for pattern-matching TaskManager tab entries.
925 base::string16 MatchTaskManagerTab(const char* page_title) {
926 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX,
927 base::ASCIIToUTF16(page_title));
928 }
929
930 // Returns a string for pattern-matching TaskManager prerender entries.
931 base::string16 MatchTaskManagerPrerender(const char* page_title) {
932 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX,
933 base::ASCIIToUTF16(page_title));
934 }
935
936 const base::HistogramTester& histogram_tester() { return histogram_tester_; }
937
938 private: 903 private:
939 // TODO(davidben): Remove this altogether so the tests don't globally assume 904 // TODO(davidben): Remove this altogether so the tests don't globally assume
940 // only one prerender. 905 // only one prerender.
941 TestPrerenderContents* GetPrerenderContents() const { 906 TestPrerenderContents* GetPrerenderContents() const {
942 return GetPrerenderContentsFor(dest_url_); 907 return GetPrerenderContentsFor(dest_url_);
943 } 908 }
944 909
945 ScopedVector<TestPrerender> PrerenderTestURLImpl( 910 ScopedVector<TestPrerender> PrerenderTestURLImpl(
946 const GURL& prerender_url, 911 const GURL& prerender_url,
947 const std::vector<FinalStatus>& expected_final_status_queue, 912 const std::vector<FinalStatus>& expected_final_status_queue,
948 int expected_number_of_loads) override { 913 int expected_number_of_loads) override {
949 dest_url_ = prerender_url; 914 dest_url_ = prerender_url;
950 915
951 base::StringPairs replacement_text; 916 base::StringPairs replacement_text;
952 replacement_text.push_back( 917 replacement_text.push_back(
953 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); 918 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec()));
954 std::string replacement_path; 919 std::string replacement_path;
955 net::test_server::GetFilePathWithReplacements( 920 net::test_server::GetFilePathWithReplacements(
956 loader_path_, replacement_text, &replacement_path); 921 loader_path_, replacement_text, &replacement_path);
957 922
958 const net::EmbeddedTestServer* src_server = embedded_test_server(); 923 GURL loader_url =
959 if (https_src_server_) 924 src_server()->GetURL(replacement_path + "&" + loader_query_);
960 src_server = https_src_server_.get();
961 GURL loader_url = src_server->GetURL(
962 replacement_path + "&" + loader_query_);
963 925
964 GURL::Replacements loader_replacements; 926 GURL::Replacements loader_replacements;
965 if (!loader_host_override_.empty()) 927 if (!loader_host_override_.empty())
966 loader_replacements.SetHostStr(loader_host_override_); 928 loader_replacements.SetHostStr(loader_host_override_);
967 loader_url = loader_url.ReplaceComponents(loader_replacements); 929 loader_url = loader_url.ReplaceComponents(loader_replacements);
968 930
969 CHECK(!expected_final_status_queue.empty()); 931 ScopedVector<TestPrerender> prerenders = NavigateWithPrerenders(
970 ScopedVector<TestPrerender> prerenders; 932 loader_url, expected_final_status_queue, expected_number_of_loads);
971 for (size_t i = 0; i < expected_final_status_queue.size(); i++) {
972 prerenders.push_back(
973 prerender_contents_factory()
974 ->ExpectPrerenderContents(expected_final_status_queue[i])
975 .release());
976 }
977 933
978 FinalStatus expected_final_status = expected_final_status_queue.front(); 934 FinalStatus expected_final_status = expected_final_status_queue.front();
979
980 // Navigate to the loader URL and then wait for the first prerender to be
981 // created.
982 ui_test_utils::NavigateToURL(current_browser(), loader_url);
983 prerenders[0]->WaitForCreate();
984 prerenders[0]->WaitForLoads(expected_number_of_loads);
985
986 if (ShouldAbortPrerenderBeforeSwap(expected_final_status)) { 935 if (ShouldAbortPrerenderBeforeSwap(expected_final_status)) {
987 // The prerender will abort on its own. Assert it does so correctly. 936 // The prerender will abort on its own. Assert it does so correctly.
988 prerenders[0]->WaitForStop(); 937 prerenders[0]->WaitForStop();
989 EXPECT_FALSE(prerenders[0]->contents()); 938 EXPECT_FALSE(prerenders[0]->contents());
990 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0)); 939 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0));
991 } else { 940 } else {
992 // Otherwise, check that it prerendered correctly. 941 // Otherwise, check that it prerendered correctly.
993 TestPrerenderContents* prerender_contents = prerenders[0]->contents(); 942 TestPrerenderContents* prerender_contents = prerenders[0]->contents();
994 CHECK(prerender_contents); 943 CHECK(prerender_contents);
995 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status()); 944 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } else { 1010 } else {
1062 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), 1011 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(),
1063 web_contents); 1012 web_contents);
1064 render_frame_host->ExecuteJavaScriptForTests( 1013 render_frame_host->ExecuteJavaScriptForTests(
1065 base::ASCIIToUTF16(javascript)); 1014 base::ASCIIToUTF16(javascript));
1066 observer.Wait(); 1015 observer.Wait();
1067 } 1016 }
1068 } 1017 }
1069 1018
1070 GURL dest_url_; 1019 GURL dest_url_;
1071 std::unique_ptr<net::EmbeddedTestServer> https_src_server_;
1072 bool call_javascript_; 1020 bool call_javascript_;
1073 bool check_load_events_; 1021 bool check_load_events_;
1074 std::string loader_host_override_; 1022 std::string loader_host_override_;
1075 std::string loader_path_; 1023 std::string loader_path_;
1076 std::string loader_query_; 1024 std::string loader_query_;
1077 base::HistogramTester histogram_tester_;
1078 base::test::ScopedFeatureList feature_list_; 1025 base::test::ScopedFeatureList feature_list_;
1079 }; 1026 };
1080 1027
1081 // Checks that a page is correctly prerendered in the case of a 1028 // Checks that a page is correctly prerendered in the case of a
1082 // <link rel=prerender> tag and then loaded into a tab in response to a 1029 // <link rel=prerender> tag and then loaded into a tab in response to a
1083 // navigation. 1030 // navigation.
1084 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { 1031 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) {
1085 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 1032 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
1086 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); 1033 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0));
1087 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); 1034 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 } 1625 }
1679 1626
1680 // Checks that the referrer is set when prerendering. 1627 // Checks that the referrer is set when prerendering.
1681 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReferrer) { 1628 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReferrer) {
1682 PrerenderTestURL("/prerender/prerender_referrer.html", FINAL_STATUS_USED, 1); 1629 PrerenderTestURL("/prerender/prerender_referrer.html", FINAL_STATUS_USED, 1);
1683 NavigateToDestURL(); 1630 NavigateToDestURL();
1684 } 1631 }
1685 1632
1686 // Checks that the referrer is not set when prerendering and the source page is 1633 // Checks that the referrer is not set when prerendering and the source page is
1687 // HTTPS. 1634 // HTTPS.
1688 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 1635 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNoSSLReferrer) {
1689 PrerenderNoSSLReferrer) { 1636 // Use http:// url for the prerendered page main resource.
1637 GURL url(
1638 embedded_test_server()->GetURL("/prerender/prerender_no_referrer.html"));
1639
1640 // Use https:// for all other resources.
1690 UseHttpsSrcServer(); 1641 UseHttpsSrcServer();
1691 PrerenderTestURL("/prerender/prerender_no_referrer.html", FINAL_STATUS_USED, 1642
1692 1); 1643 PrerenderTestURL(url, FINAL_STATUS_USED, 1);
1693 NavigateToDestURL(); 1644 NavigateToDestURL();
1694 } 1645 }
1695 1646
1696 // Checks that the referrer is set when prerendering is cancelled. 1647 // Checks that the referrer is set when prerendering is cancelled.
1697 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrer) { 1648 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrer) {
1698 std::unique_ptr<TestContentBrowserClient> test_content_browser_client( 1649 std::unique_ptr<TestContentBrowserClient> test_content_browser_client(
1699 new TestContentBrowserClient); 1650 new TestContentBrowserClient);
1700 content::ContentBrowserClient* original_browser_client = 1651 content::ContentBrowserClient* original_browser_client =
1701 content::SetBrowserClientForTesting(test_content_browser_client.get()); 1652 content::SetBrowserClientForTesting(test_content_browser_client.get());
1702 1653
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 PrerenderTestURL("/prerender/prerender_xhr_put.html", 2116 PrerenderTestURL("/prerender/prerender_xhr_put.html",
2166 FINAL_STATUS_INVALID_HTTP_METHOD, 1); 2117 FINAL_STATUS_INVALID_HTTP_METHOD, 1);
2167 } 2118 }
2168 2119
2169 // Checks that xhr DELETE cancels prerenders. 2120 // Checks that xhr DELETE cancels prerenders.
2170 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderXhrDelete) { 2121 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderXhrDelete) {
2171 PrerenderTestURL("/prerender/prerender_xhr_delete.html", 2122 PrerenderTestURL("/prerender/prerender_xhr_delete.html",
2172 FINAL_STATUS_INVALID_HTTP_METHOD, 1); 2123 FINAL_STATUS_INVALID_HTTP_METHOD, 1);
2173 } 2124 }
2174 2125
2175 // Checks that a top-level page which would trigger an SSL error is canceled. 2126 // Sets up HTTPS server for prerendered page, and checks that an SSL error will
2127 // cancel the prerender. The prerenderer loader will be served through HTTP.
2176 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLErrorTopLevel) { 2128 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLErrorTopLevel) {
2177 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 2129 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
2178 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); 2130 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME);
2179 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); 2131 https_server.ServeFilesFromSourceDirectory("chrome/test/data");
2180 ASSERT_TRUE(https_server.Start()); 2132 ASSERT_TRUE(https_server.Start());
2181 GURL https_url = https_server.GetURL("/prerender/prerender_page.html"); 2133 GURL https_url = https_server.GetURL("/prerender/prerender_page.html");
2182 PrerenderTestURL(https_url, 2134 PrerenderTestURL(https_url, FINAL_STATUS_SSL_ERROR, 0);
2183 FINAL_STATUS_SSL_ERROR,
2184 0);
2185 } 2135 }
2186 2136
2187 // Checks that an SSL error that comes from a subresource does not cancel 2137 // Checks that an SSL error that comes from a subresource does not cancel
2188 // the page. Non-main-frame requests are simply cancelled if they run into 2138 // the page. Non-main-frame requests are simply cancelled if they run into
2189 // an SSL problem. 2139 // an SSL problem.
2190 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLErrorSubresource) { 2140 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLErrorSubresource) {
2191 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 2141 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
2192 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); 2142 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME);
2193 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); 2143 https_server.ServeFilesFromSourceDirectory("chrome/test/data");
2194 ASSERT_TRUE(https_server.Start()); 2144 ASSERT_TRUE(https_server.Start());
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 browser()->tab_strip_model()->GetActiveWebContents(); 3336 browser()->tab_strip_model()->GetActiveWebContents();
3387 bool display_test_result = false; 3337 bool display_test_result = false;
3388 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3338 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3389 "DidDisplayReallyPass()", 3339 "DidDisplayReallyPass()",
3390 &display_test_result)); 3340 &display_test_result));
3391 ASSERT_TRUE(display_test_result); 3341 ASSERT_TRUE(display_test_result);
3392 } 3342 }
3393 #endif // !defined(DISABLE_NACL) 3343 #endif // !defined(DISABLE_NACL)
3394 3344
3395 } // namespace prerender 3345 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698