OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/time.h" | 5 #include "base/time.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
9 #include "chrome/browser/tab_contents/interstitial_page.h" | 9 #include "chrome/browser/tab_contents/interstitial_page.h" |
10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Substitute the generated frame_left URL into the top_frame page. | 157 // Substitute the generated frame_left URL into the top_frame page. |
158 std::vector<net::TestServer::StringPair> replacement_text_top_frame; | 158 std::vector<net::TestServer::StringPair> replacement_text_top_frame; |
159 replacement_text_top_frame.push_back( | 159 replacement_text_top_frame.push_back( |
160 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); | 160 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); |
161 return net::TestServer::GetFilePathWithReplacements( | 161 return net::TestServer::GetFilePathWithReplacements( |
162 "files/ssl/top_frame.html", | 162 "files/ssl/top_frame.html", |
163 replacement_text_top_frame, | 163 replacement_text_top_frame, |
164 top_frame_path); | 164 top_frame_path); |
165 } | 165 } |
166 | 166 |
| 167 static bool GetPageWithUnsafeWorkerPath( |
| 168 const net::TestServer& expired_https_server, |
| 169 std::string* page_with_unsafe_worker_path) { |
| 170 // Get the "imported.js" URL from the expired https server and |
| 171 // substitute it into the unsafe_worker.js file. |
| 172 GURL imported_js_url = expired_https_server.GetURL("files/ssl/imported.js"); |
| 173 std::vector<net::TestServer::StringPair> replacement_text_for_unsafe_worker; |
| 174 replacement_text_for_unsafe_worker.push_back( |
| 175 make_pair("REPLACE_WITH_IMPORTED_JS_URL", imported_js_url.spec())); |
| 176 std::string unsafe_worker_path; |
| 177 if (!net::TestServer::GetFilePathWithReplacements( |
| 178 "unsafe_worker.js", |
| 179 replacement_text_for_unsafe_worker, |
| 180 &unsafe_worker_path)) |
| 181 return false; |
| 182 |
| 183 // Now, substitute this into the page with unsafe worker. |
| 184 std::vector<net::TestServer::StringPair> |
| 185 replacement_text_for_page_with_unsafe_worker; |
| 186 replacement_text_for_page_with_unsafe_worker.push_back( |
| 187 make_pair("REPLACE_WITH_UNSAFE_WORKER_PATH", unsafe_worker_path)); |
| 188 return net::TestServer::GetFilePathWithReplacements( |
| 189 "files/ssl/page_with_unsafe_worker.html", |
| 190 replacement_text_for_page_with_unsafe_worker, |
| 191 page_with_unsafe_worker_path); |
| 192 } |
| 193 |
167 net::TestServer https_server_; | 194 net::TestServer https_server_; |
168 net::TestServer https_server_expired_; | 195 net::TestServer https_server_expired_; |
169 net::TestServer https_server_mismatched_; | 196 net::TestServer https_server_mismatched_; |
170 | 197 |
171 private: | 198 private: |
172 DISALLOW_COPY_AND_ASSIGN(SSLUITest); | 199 DISALLOW_COPY_AND_ASSIGN(SSLUITest); |
173 }; | 200 }; |
174 | 201 |
175 // Visits a regular page over http. | 202 // Visits a regular page over http. |
176 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { | 203 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 EXPECT_FALSE(is_content_evil); | 1051 EXPECT_FALSE(is_content_evil); |
1025 } | 1052 } |
1026 | 1053 |
1027 // Marked as flaky, see bug 40932. | 1054 // Marked as flaky, see bug 40932. |
1028 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContentsInWorkerFiltered) { | 1055 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContentsInWorkerFiltered) { |
1029 ASSERT_TRUE(https_server_.Start()); | 1056 ASSERT_TRUE(https_server_.Start()); |
1030 ASSERT_TRUE(https_server_expired_.Start()); | 1057 ASSERT_TRUE(https_server_expired_.Start()); |
1031 | 1058 |
1032 // This page will spawn a Worker which will try to load content from | 1059 // This page will spawn a Worker which will try to load content from |
1033 // BadCertServer. | 1060 // BadCertServer. |
| 1061 std::string page_with_unsafe_worker_path; |
| 1062 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_, |
| 1063 &page_with_unsafe_worker_path)); |
1034 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1064 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( |
1035 "files/ssl/page_with_unsafe_worker.html")); | 1065 page_with_unsafe_worker_path)); |
1036 TabContents* tab = browser()->GetSelectedTabContents(); | 1066 TabContents* tab = browser()->GetSelectedTabContents(); |
1037 // Expect Worker not to load insecure content. | 1067 // Expect Worker not to load insecure content. |
1038 CheckWorkerLoadResult(tab, false); | 1068 CheckWorkerLoadResult(tab, false); |
1039 // The bad content is filtered, expect the state to be authenticated. | 1069 // The bad content is filtered, expect the state to be authenticated. |
1040 CheckAuthenticatedState(tab, false); | 1070 CheckAuthenticatedState(tab, false); |
1041 } | 1071 } |
1042 | 1072 |
1043 // Marked as flaky, see bug 40932. | 1073 // Marked as flaky, see bug 40932. |
1044 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContentsInWorker) { | 1074 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContentsInWorker) { |
1045 ASSERT_TRUE(https_server_.Start()); | 1075 ASSERT_TRUE(https_server_.Start()); |
1046 ASSERT_TRUE(https_server_expired_.Start()); | 1076 ASSERT_TRUE(https_server_expired_.Start()); |
1047 | 1077 |
1048 // Navigate to an unsafe site. Proceed with interstitial page to indicate | 1078 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
1049 // the user approves the bad certificate. | 1079 // the user approves the bad certificate. |
1050 ui_test_utils::NavigateToURL(browser(), | 1080 ui_test_utils::NavigateToURL(browser(), |
1051 https_server_expired_.GetURL("files/ssl/blank_page.html")); | 1081 https_server_expired_.GetURL("files/ssl/blank_page.html")); |
1052 TabContents* tab = browser()->GetSelectedTabContents(); | 1082 TabContents* tab = browser()->GetSelectedTabContents(); |
1053 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1083 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
1054 true); // Interstitial showing | 1084 true); // Interstitial showing |
1055 ProceedThroughInterstitial(tab); | 1085 ProceedThroughInterstitial(tab); |
1056 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1086 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
1057 false); // No Interstitial | 1087 false); // No Interstitial |
1058 | 1088 |
1059 // Navigate to safe page that has Worker loading unsafe content. | 1089 // Navigate to safe page that has Worker loading unsafe content. |
1060 // Expect content to load but be marked as auth broken due to running insecure | 1090 // Expect content to load but be marked as auth broken due to running insecure |
1061 // content. | 1091 // content. |
| 1092 std::string page_with_unsafe_worker_path; |
| 1093 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_, |
| 1094 &page_with_unsafe_worker_path)); |
1062 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1095 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( |
1063 "files/ssl/page_with_unsafe_worker.html")); | 1096 page_with_unsafe_worker_path)); |
1064 CheckWorkerLoadResult(tab, true); // Worker loads insecure content | 1097 CheckWorkerLoadResult(tab, true); // Worker loads insecure content |
1065 CheckAuthenticationBrokenState(tab, 0, true, false); | 1098 CheckAuthenticationBrokenState(tab, 0, true, false); |
1066 } | 1099 } |
1067 | 1100 |
1068 // TODO(jcampan): more tests to do below. | 1101 // TODO(jcampan): more tests to do below. |
1069 | 1102 |
1070 // Visit a page over https that contains a frame with a redirect. | 1103 // Visit a page over https that contains a frame with a redirect. |
1071 | 1104 |
1072 // XMLHttpRequest insecure content in synchronous mode. | 1105 // XMLHttpRequest insecure content in synchronous mode. |
1073 | 1106 |
1074 // XMLHttpRequest insecure content in asynchronous mode. | 1107 // XMLHttpRequest insecure content in asynchronous mode. |
1075 | 1108 |
1076 // XMLHttpRequest over bad ssl in synchronous mode. | 1109 // XMLHttpRequest over bad ssl in synchronous mode. |
1077 | 1110 |
1078 // XMLHttpRequest over OK ssl in synchronous mode. | 1111 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |