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/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
7 #include "chrome/browser/pref_service.h" | 7 #include "chrome/browser/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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 scoped_refptr<HTTPSTestServer> GoodCertServer() { | 28 scoped_refptr<HTTPSTestServer> GoodCertServer() { |
29 return HTTPSTestServer::CreateGoodServer(kDocRoot); | 29 return HTTPSTestServer::CreateGoodServer(kDocRoot); |
30 } | 30 } |
31 | 31 |
32 scoped_refptr<HTTPSTestServer> BadCertServer() { | 32 scoped_refptr<HTTPSTestServer> BadCertServer() { |
33 return HTTPSTestServer::CreateExpiredServer(kDocRoot); | 33 return HTTPSTestServer::CreateExpiredServer(kDocRoot); |
34 } | 34 } |
35 | 35 |
36 void CheckAuthenticatedState(TabContents* tab, | 36 void CheckAuthenticatedState(TabContents* tab, |
37 bool mixed_content) { | 37 bool displayed_mixed_content) { |
38 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 38 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
39 ASSERT_TRUE(entry); | 39 ASSERT_TRUE(entry); |
40 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, entry->page_type()); | 40 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, entry->page_type()); |
41 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, entry->ssl().security_style()); | 41 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, entry->ssl().security_style()); |
42 EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); | 42 EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); |
43 EXPECT_EQ(mixed_content, entry->ssl().has_mixed_content()); | 43 EXPECT_EQ(displayed_mixed_content, entry->ssl().displayed_mixed_content()); |
| 44 EXPECT_FALSE(entry->ssl().ran_mixed_content()); |
44 } | 45 } |
45 | 46 |
46 void CheckUnauthenticatedState(TabContents* tab) { | 47 void CheckUnauthenticatedState(TabContents* tab) { |
47 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 48 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
48 ASSERT_TRUE(entry); | 49 ASSERT_TRUE(entry); |
49 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, entry->page_type()); | 50 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, entry->page_type()); |
50 EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, entry->ssl().security_style()); | 51 EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, entry->ssl().security_style()); |
51 EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); | 52 EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); |
52 EXPECT_FALSE(entry->ssl().has_mixed_content()); | 53 EXPECT_FALSE(entry->ssl().displayed_mixed_content()); |
| 54 EXPECT_FALSE(entry->ssl().ran_mixed_content()); |
53 } | 55 } |
54 | 56 |
55 void CheckAuthenticationBrokenState(TabContents* tab, | 57 void CheckAuthenticationBrokenState(TabContents* tab, |
56 int error, | 58 int error, |
| 59 bool ran_mixed_content, |
57 bool interstitial) { | 60 bool interstitial) { |
58 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 61 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
59 ASSERT_TRUE(entry); | 62 ASSERT_TRUE(entry); |
60 EXPECT_EQ(interstitial ? NavigationEntry::INTERSTITIAL_PAGE : | 63 EXPECT_EQ(interstitial ? NavigationEntry::INTERSTITIAL_PAGE : |
61 NavigationEntry::NORMAL_PAGE, | 64 NavigationEntry::NORMAL_PAGE, |
62 entry->page_type()); | 65 entry->page_type()); |
63 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, | 66 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, |
64 entry->ssl().security_style()); | 67 entry->ssl().security_style()); |
65 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security style | 68 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security style |
66 // to SECURITY_STYLE_AUTHENTICATION_BROKEN. | 69 // to SECURITY_STYLE_AUTHENTICATION_BROKEN. |
67 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error); | 70 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error); |
68 EXPECT_EQ(error, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); | 71 EXPECT_EQ(error, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); |
69 EXPECT_FALSE(entry->ssl().has_mixed_content()); | 72 EXPECT_FALSE(entry->ssl().displayed_mixed_content()); |
| 73 EXPECT_EQ(ran_mixed_content, entry->ssl().ran_mixed_content()); |
70 } | 74 } |
71 | 75 |
72 void CheckWorkerLoadResult(TabContents* tab, bool expectLoaded) { | 76 void CheckWorkerLoadResult(TabContents* tab, bool expectLoaded) { |
73 // Workers are async and we don't have notifications for them passing | 77 // Workers are async and we don't have notifications for them passing |
74 // messages since they do it between renderer and worker processes. | 78 // messages since they do it between renderer and worker processes. |
75 // So have a polling loop, check every 200ms, timeout at 30s. | 79 // So have a polling loop, check every 200ms, timeout at 30s. |
76 const int timeout_ms = 200; | 80 const int timeout_ms = 200; |
77 base::Time timeToQuit = base::Time::Now() + | 81 base::Time timeToQuit = base::Time::Now() + |
78 base::TimeDelta::FromMilliseconds(30000); | 82 base::TimeDelta::FromMilliseconds(30000); |
79 | 83 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 157 |
154 // Visits a page with https error and proceed: | 158 // Visits a page with https error and proceed: |
155 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndProceed) { | 159 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndProceed) { |
156 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 160 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
157 ASSERT_TRUE(bad_https_server.get() != NULL); | 161 ASSERT_TRUE(bad_https_server.get() != NULL); |
158 | 162 |
159 ui_test_utils::NavigateToURL(browser(), | 163 ui_test_utils::NavigateToURL(browser(), |
160 bad_https_server->TestServerPage("files/ssl/google.html")); | 164 bad_https_server->TestServerPage("files/ssl/google.html")); |
161 | 165 |
162 TabContents* tab = browser()->GetSelectedTabContents(); | 166 TabContents* tab = browser()->GetSelectedTabContents(); |
163 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 167 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
164 true); // Interstitial showing | 168 true); // Interstitial showing |
165 | 169 |
166 ProceedThroughInterstitial(tab); | 170 ProceedThroughInterstitial(tab); |
167 | 171 |
168 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 172 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
169 false); // No interstitial showing | 173 false); // No interstitial showing |
170 } | 174 } |
171 | 175 |
172 // Visits a page with https error and don't proceed (and ensure we can still | 176 // Visits a page with https error and don't proceed (and ensure we can still |
173 // navigate at that point): | 177 // navigate at that point): |
174 // Marked as flaky, see bug 40932. | 178 // Marked as flaky, see bug 40932. |
175 // Disabled, flakily exceeds test timeout, http://crbug.com/43575. | 179 // Disabled, flakily exceeds test timeout, http://crbug.com/43575. |
176 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestHTTPSExpiredCertAndDontProceed) { | 180 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestHTTPSExpiredCertAndDontProceed) { |
177 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 181 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
178 ASSERT_TRUE(http_server.get() != NULL); | 182 ASSERT_TRUE(http_server.get() != NULL); |
(...skipping 18 matching lines...) Expand all Loading... |
197 GURL::Replacements replacements; | 201 GURL::Replacements replacements; |
198 std::string new_host("localhost"); | 202 std::string new_host("localhost"); |
199 replacements.SetHostStr(new_host); | 203 replacements.SetHostStr(new_host); |
200 cross_site_url = cross_site_url.ReplaceComponents(replacements); | 204 cross_site_url = cross_site_url.ReplaceComponents(replacements); |
201 | 205 |
202 // Now go to a bad HTTPS page. | 206 // Now go to a bad HTTPS page. |
203 ui_test_utils::NavigateToURL(browser(), cross_site_url); | 207 ui_test_utils::NavigateToURL(browser(), cross_site_url); |
204 | 208 |
205 // An interstitial should be showing. | 209 // An interstitial should be showing. |
206 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 210 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
207 true); // Interstitial showing. | 211 false, true); |
208 | 212 |
209 // Simulate user clicking "Take me back". | 213 // Simulate user clicking "Take me back". |
210 InterstitialPage* interstitial_page = tab->interstitial_page(); | 214 InterstitialPage* interstitial_page = tab->interstitial_page(); |
211 ASSERT_TRUE(interstitial_page); | 215 ASSERT_TRUE(interstitial_page); |
212 interstitial_page->DontProceed(); | 216 interstitial_page->DontProceed(); |
213 | 217 |
214 // We should be back to the original good page. | 218 // We should be back to the original good page. |
215 CheckAuthenticatedState(tab, false); | 219 CheckAuthenticatedState(tab, false); |
216 | 220 |
217 // Try to navigate to a new page. (to make sure bug 5800 is fixed). | 221 // Try to navigate to a new page. (to make sure bug 5800 is fixed). |
(...skipping 12 matching lines...) Expand all Loading... |
230 // First navigate to an HTTP page. | 234 // First navigate to an HTTP page. |
231 ui_test_utils::NavigateToURL(browser(), | 235 ui_test_utils::NavigateToURL(browser(), |
232 http_server->TestServerPage("files/ssl/google.html")); | 236 http_server->TestServerPage("files/ssl/google.html")); |
233 TabContents* tab = browser()->GetSelectedTabContents(); | 237 TabContents* tab = browser()->GetSelectedTabContents(); |
234 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 238 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
235 ASSERT_TRUE(entry); | 239 ASSERT_TRUE(entry); |
236 | 240 |
237 // Now go to a bad HTTPS page that shows an interstitial. | 241 // Now go to a bad HTTPS page that shows an interstitial. |
238 ui_test_utils::NavigateToURL(browser(), | 242 ui_test_utils::NavigateToURL(browser(), |
239 bad_https_server->TestServerPage("files/ssl/google.html")); | 243 bad_https_server->TestServerPage("files/ssl/google.html")); |
240 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 244 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
241 true); // Interstitial showing | 245 true); // Interstitial showing |
242 | 246 |
243 // Simulate user clicking on back button (crbug.com/39248). | 247 // Simulate user clicking on back button (crbug.com/39248). |
244 browser()->GoBack(CURRENT_TAB); | 248 browser()->GoBack(CURRENT_TAB); |
245 | 249 |
246 // We should be back at the original good page. | 250 // We should be back at the original good page. |
247 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 251 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
248 CheckUnauthenticatedState(tab); | 252 CheckUnauthenticatedState(tab); |
249 } | 253 } |
250 | 254 |
251 // Visits a page with https error and then goes back using GoToOffset. | 255 // Visits a page with https error and then goes back using GoToOffset. |
252 // Marked as flaky, see bug 40932. | 256 // Marked as flaky, see bug 40932. |
253 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestHTTPSExpiredCertAndGoBackViaMenu) { | 257 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestHTTPSExpiredCertAndGoBackViaMenu) { |
254 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 258 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
255 ASSERT_TRUE(http_server.get() != NULL); | 259 ASSERT_TRUE(http_server.get() != NULL); |
256 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 260 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
257 ASSERT_TRUE(bad_https_server.get() != NULL); | 261 ASSERT_TRUE(bad_https_server.get() != NULL); |
258 | 262 |
259 // First navigate to an HTTP page. | 263 // First navigate to an HTTP page. |
260 ui_test_utils::NavigateToURL(browser(), | 264 ui_test_utils::NavigateToURL(browser(), |
261 http_server->TestServerPage("files/ssl/google.html")); | 265 http_server->TestServerPage("files/ssl/google.html")); |
262 TabContents* tab = browser()->GetSelectedTabContents(); | 266 TabContents* tab = browser()->GetSelectedTabContents(); |
263 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 267 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
264 ASSERT_TRUE(entry); | 268 ASSERT_TRUE(entry); |
265 | 269 |
266 // Now go to a bad HTTPS page that shows an interstitial. | 270 // Now go to a bad HTTPS page that shows an interstitial. |
267 ui_test_utils::NavigateToURL(browser(), | 271 ui_test_utils::NavigateToURL(browser(), |
268 bad_https_server->TestServerPage("files/ssl/google.html")); | 272 bad_https_server->TestServerPage("files/ssl/google.html")); |
269 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 273 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
270 true); // Interstitial showing | 274 true); // Interstitial showing |
271 | 275 |
272 // Simulate user clicking and holding on back button (crbug.com/37215). | 276 // Simulate user clicking and holding on back button (crbug.com/37215). |
273 tab->controller().GoToOffset(-1); | 277 tab->controller().GoToOffset(-1); |
274 | 278 |
275 // We should be back at the original good page. | 279 // We should be back at the original good page. |
276 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 280 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
277 CheckUnauthenticatedState(tab); | 281 CheckUnauthenticatedState(tab); |
278 } | 282 } |
279 | 283 |
(...skipping 19 matching lines...) Expand all Loading... |
299 // Now go back so that a page is in the forward history. | 303 // Now go back so that a page is in the forward history. |
300 tab->controller().GoBack(); | 304 tab->controller().GoBack(); |
301 ui_test_utils::WaitForNavigation(&(tab->controller())); | 305 ui_test_utils::WaitForNavigation(&(tab->controller())); |
302 ASSERT_TRUE(tab->controller().CanGoForward()); | 306 ASSERT_TRUE(tab->controller().CanGoForward()); |
303 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); | 307 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); |
304 ASSERT_TRUE(entry1 == entry3); | 308 ASSERT_TRUE(entry1 == entry3); |
305 | 309 |
306 // Now go to a bad HTTPS page that shows an interstitial. | 310 // Now go to a bad HTTPS page that shows an interstitial. |
307 ui_test_utils::NavigateToURL(browser(), | 311 ui_test_utils::NavigateToURL(browser(), |
308 bad_https_server->TestServerPage("files/ssl/google.html")); | 312 bad_https_server->TestServerPage("files/ssl/google.html")); |
309 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 313 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
310 true); // Interstitial showing | 314 true); // Interstitial showing |
311 | 315 |
312 // Simulate user clicking and holding on forward button. | 316 // Simulate user clicking and holding on forward button. |
313 tab->controller().GoToOffset(1); | 317 tab->controller().GoToOffset(1); |
314 ui_test_utils::WaitForNavigation(&(tab->controller())); | 318 ui_test_utils::WaitForNavigation(&(tab->controller())); |
315 | 319 |
316 // We should be showing the second good page. | 320 // We should be showing the second good page. |
317 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 321 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
318 CheckUnauthenticatedState(tab); | 322 CheckUnauthenticatedState(tab); |
319 EXPECT_FALSE(tab->controller().CanGoForward()); | 323 EXPECT_FALSE(tab->controller().CanGoForward()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 &(browser()->GetSelectedTabContents()->controller())); | 365 &(browser()->GetSelectedTabContents()->controller())); |
362 | 366 |
363 // We should have an interstitial page showing. | 367 // We should have an interstitial page showing. |
364 ASSERT_TRUE(browser()->GetSelectedTabContents()->interstitial_page()); | 368 ASSERT_TRUE(browser()->GetSelectedTabContents()->interstitial_page()); |
365 } | 369 } |
366 | 370 |
367 // | 371 // |
368 // Mixed contents | 372 // Mixed contents |
369 // | 373 // |
370 | 374 |
371 // Visits a page with mixed content. | 375 // Visits a page that displays mixed content. |
372 IN_PROC_BROWSER_TEST_F(SSLUITest, TestMixedContents) { | 376 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysMixedContent) { |
373 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 377 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
374 ASSERT_TRUE(https_server.get() != NULL); | 378 ASSERT_TRUE(https_server.get() != NULL); |
375 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 379 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
376 ASSERT_TRUE(http_server.get() != NULL); | 380 ASSERT_TRUE(http_server.get() != NULL); |
377 | 381 |
378 // Load a page with mixed-content, the default behavior is to show the mixed | 382 // Load a page that displays mixed content. |
379 // content. | |
380 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( | 383 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( |
381 "files/ssl/page_with_mixed_contents.html")); | 384 "files/ssl/page_displays_mixed_content.html")); |
382 | 385 |
383 CheckAuthenticatedState(browser()->GetSelectedTabContents(), true); | 386 CheckAuthenticatedState(browser()->GetSelectedTabContents(), true); |
384 } | 387 } |
385 | 388 |
386 // Visits a page with an http script that tries to suppress our mixed content | 389 // Visits a page that runs mixed content and tries to suppress the mixed content |
387 // warnings by randomize location.hash. | 390 // warnings by randomizing location.hash. |
388 // Based on http://crbug.com/8706 | 391 // Based on http://crbug.com/8706 |
389 IN_PROC_BROWSER_TEST_F(SSLUITest, TestMixedContentsRandomizeHash) { | 392 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsMixedContentRandomizeHash) { |
390 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 393 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
391 ASSERT_TRUE(https_server.get() != NULL); | 394 ASSERT_TRUE(https_server.get() != NULL); |
392 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 395 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
393 ASSERT_TRUE(http_server.get() != NULL); | 396 ASSERT_TRUE(http_server.get() != NULL); |
394 | 397 |
395 ui_test_utils::NavigateToURL(browser(), | 398 ui_test_utils::NavigateToURL(browser(), |
396 https_server->TestServerPage("files/ssl/page_with_http_script.html")); | 399 https_server->TestServerPage("files/ssl/page_runs_mixed_content.html")); |
397 | 400 |
398 CheckAuthenticatedState(browser()->GetSelectedTabContents(), true); | 401 CheckAuthenticationBrokenState(browser()->GetSelectedTabContents(), 0, true, |
| 402 false); |
399 } | 403 } |
400 | 404 |
401 // Visits a page with unsafe content and make sure that: | 405 // Visits a page with unsafe content and make sure that: |
402 // - frames content is replaced with warning | 406 // - frames content is replaced with warning |
403 // - images and scripts are filtered out entirely | 407 // - images and scripts are filtered out entirely |
404 // Marked as flaky, see bug 40932. | 408 // Marked as flaky, see bug 40932. |
405 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContents) { | 409 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContents) { |
406 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 410 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
407 ASSERT_TRUE(good_https_server.get() != NULL); | 411 ASSERT_TRUE(good_https_server.get() != NULL); |
408 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 412 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
(...skipping 18 matching lines...) Expand all Loading... |
427 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 431 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
428 tab->render_view_host(), std::wstring(), | 432 tab->render_view_host(), std::wstring(), |
429 L"window.domAutomationController.send(ImageWidth());", &img_width)); | 433 L"window.domAutomationController.send(ImageWidth());", &img_width)); |
430 // In order to check that the image was not loaded, we check its width. | 434 // In order to check that the image was not loaded, we check its width. |
431 // The actual image (Google logo) is 114 pixels wide, we assume the broken | 435 // The actual image (Google logo) is 114 pixels wide, we assume the broken |
432 // image is less than 100. | 436 // image is less than 100. |
433 EXPECT_LT(img_width, 100); | 437 EXPECT_LT(img_width, 100); |
434 | 438 |
435 bool js_result = false; | 439 bool js_result = false; |
436 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 440 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
437 tab->render_view_host(), L"", | 441 tab->render_view_host(), std::wstring(), |
438 L"window.domAutomationController.send(IsFooSet());", &js_result)); | 442 L"window.domAutomationController.send(IsFooSet());", &js_result)); |
439 EXPECT_FALSE(js_result); | 443 EXPECT_FALSE(js_result); |
440 } | 444 } |
441 | 445 |
442 // Visits a page with mixed content loaded by JS (after the initial page load). | 446 // Visits a page with mixed content loaded by JS (after the initial page load). |
443 IN_PROC_BROWSER_TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) { | 447 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysMixedContentLoadedFromJS) { |
444 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 448 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
445 ASSERT_TRUE(https_server.get() != NULL); | 449 ASSERT_TRUE(https_server.get() != NULL); |
446 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 450 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
447 ASSERT_TRUE(http_server.get() != NULL); | 451 ASSERT_TRUE(http_server.get() != NULL); |
448 | 452 |
449 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( | 453 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( |
450 "files/ssl/page_with_dynamic_mixed_contents.html")); | 454 "files/ssl/page_with_dynamic_mixed_contents.html")); |
451 | 455 |
452 TabContents* tab = browser()->GetSelectedTabContents(); | 456 TabContents* tab = browser()->GetSelectedTabContents(); |
453 CheckAuthenticatedState(tab, false); | 457 CheckAuthenticatedState(tab, false); |
454 | 458 |
455 // Load the insecure image. | 459 // Load the insecure image. |
456 bool js_result = false; | 460 bool js_result = false; |
457 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 461 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
458 tab->render_view_host(), std::wstring(), L"loadBadImage();", &js_result)); | 462 tab->render_view_host(), std::wstring(), L"loadBadImage();", &js_result)); |
459 EXPECT_TRUE(js_result); | 463 EXPECT_TRUE(js_result); |
460 | 464 |
461 // We should now have mixed-contents. | 465 // We should now have mixed-contents. |
462 CheckAuthenticatedState(tab, true); | 466 CheckAuthenticatedState(tab, true); |
463 } | 467 } |
464 | 468 |
465 // Visits two pages from the same origin: one with mixed content and one | 469 // Visits two pages from the same origin: one that displays mixed content and |
466 // without. The test checks that we propagate the mixed content state from one | 470 // one that doesn't. The test checks that we do not propagate the mixed content |
467 // to the other. | 471 // state from one to the other. |
468 // TODO(jcampan): http://crbug.com/15072 this test fails. | 472 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysMixedContentTwoTabs) { |
469 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestMixedContentsTwoTabs) { | |
470 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 473 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
471 ASSERT_TRUE(https_server.get() != NULL); | 474 ASSERT_TRUE(https_server.get() != NULL); |
472 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 475 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
473 ASSERT_TRUE(http_server.get() != NULL); | 476 ASSERT_TRUE(http_server.get() != NULL); |
474 | 477 |
475 ui_test_utils::NavigateToURL(browser(), | 478 ui_test_utils::NavigateToURL(browser(), |
476 https_server->TestServerPage("files/ssl/blank_page.html")); | 479 https_server->TestServerPage("files/ssl/blank_page.html")); |
477 | 480 |
478 TabContents* tab1 = browser()->GetSelectedTabContents(); | 481 TabContents* tab1 = browser()->GetSelectedTabContents(); |
479 | 482 |
480 // This tab should be fine. | 483 // This tab should be fine. |
481 CheckAuthenticatedState(tab1, false); | 484 CheckAuthenticatedState(tab1, false); |
482 | 485 |
483 // Create a new tab. | 486 // Create a new tab. |
484 GURL url = | 487 GURL url = https_server->TestServerPage( |
485 https_server->TestServerPage("files/ssl/page_with_http_script.html"); | 488 "files/ssl/page_displays_mixed_content.html"); |
486 TabContents* tab2 = browser()->AddTabWithURL(url, GURL(), | 489 TabContents* tab2 = browser()->AddTabWithURL(url, GURL(), |
487 PageTransition::TYPED, 0, Browser::ADD_SELECTED, NULL, std::string()); | 490 PageTransition::TYPED, 0, Browser::ADD_SELECTED, tab1->GetSiteInstance(), |
| 491 std::string()); |
488 ui_test_utils::WaitForNavigation(&(tab2->controller())); | 492 ui_test_utils::WaitForNavigation(&(tab2->controller())); |
489 | 493 |
490 // The new tab has mixed content. | 494 // The new tab has mixed content. |
491 CheckAuthenticatedState(tab2, true); | 495 CheckAuthenticatedState(tab2, true); |
492 | 496 |
| 497 // The original tab should not be contaminated. |
| 498 CheckAuthenticatedState(tab1, false); |
| 499 } |
| 500 |
| 501 // Visits two pages from the same origin: one that runs mixed content and one |
| 502 // that doesn't. The test checks that we propagate the mixed content state from |
| 503 // one to the other. |
| 504 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsMixedContentTwoTabs) { |
| 505 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
| 506 ASSERT_TRUE(https_server.get() != NULL); |
| 507 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
| 508 ASSERT_TRUE(http_server.get() != NULL); |
| 509 |
| 510 ui_test_utils::NavigateToURL(browser(), |
| 511 https_server->TestServerPage("files/ssl/blank_page.html")); |
| 512 |
| 513 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 514 |
| 515 // This tab should be fine. |
| 516 CheckAuthenticatedState(tab1, false); |
| 517 |
| 518 // Create a new tab. |
| 519 GURL url = |
| 520 https_server->TestServerPage("files/ssl/page_runs_mixed_content.html"); |
| 521 TabContents* tab2 = browser()->AddTabWithURL(url, GURL(), |
| 522 PageTransition::TYPED, 0, Browser::ADD_SELECTED, tab1->GetSiteInstance(), |
| 523 std::string()); |
| 524 ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| 525 |
| 526 // The new tab has mixed content. |
| 527 CheckAuthenticationBrokenState(tab2, 0, true, false); |
| 528 |
493 // Which means the origin for the first tab has also been contaminated with | 529 // Which means the origin for the first tab has also been contaminated with |
494 // mixed content. | 530 // mixed content. |
495 CheckAuthenticatedState(tab1, true); | 531 CheckAuthenticationBrokenState(tab1, 0, true, false); |
496 } | 532 } |
497 | 533 |
498 // Visits a page with an image over http. Visits another page over https | 534 // Visits a page with an image over http. Visits another page over https |
499 // referencing that same image over http (hoping it is coming from the webcore | 535 // referencing that same image over http (hoping it is coming from the webcore |
500 // memory cache). | 536 // memory cache). |
501 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCachedMixedContents) { | 537 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysCachedMixedContent) { |
502 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 538 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
503 ASSERT_TRUE(https_server.get() != NULL); | 539 ASSERT_TRUE(https_server.get() != NULL); |
504 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 540 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
505 ASSERT_TRUE(http_server.get() != NULL); | 541 ASSERT_TRUE(http_server.get() != NULL); |
506 | 542 |
507 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 543 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
508 "files/ssl/page_with_mixed_contents.html")); | 544 "files/ssl/page_displays_mixed_content.html")); |
509 TabContents* tab = browser()->GetSelectedTabContents(); | 545 TabContents* tab = browser()->GetSelectedTabContents(); |
510 CheckUnauthenticatedState(tab); | 546 CheckUnauthenticatedState(tab); |
511 | 547 |
512 // Load again but over SSL. It should have mixed-contents (even though the | 548 // Load again but over SSL. It should be marked as displaying mixed content |
513 // image comes from the WebCore memory cache). | 549 // (even though the image comes from the WebCore memory cache). |
514 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( | 550 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPage( |
515 "files/ssl/page_with_mixed_contents.html")); | 551 "files/ssl/page_displays_mixed_content.html")); |
516 CheckAuthenticatedState(tab, true); | 552 CheckAuthenticatedState(tab, true); |
517 } | 553 } |
518 | 554 |
| 555 // Visits a page with script over http. Visits another page over https |
| 556 // referencing that same script over http (hoping it is coming from the webcore |
| 557 // memory cache). |
| 558 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsCachedMixedContent) { |
| 559 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
| 560 ASSERT_TRUE(https_server.get() != NULL); |
| 561 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
| 562 ASSERT_TRUE(http_server.get() != NULL); |
| 563 |
| 564 ui_test_utils::NavigateToURL(browser(), |
| 565 http_server->TestServerPage("files/ssl/page_runs_mixed_content.html")); |
| 566 TabContents* tab = browser()->GetSelectedTabContents(); |
| 567 CheckUnauthenticatedState(tab); |
| 568 |
| 569 // Load again but over SSL. It should be marked as displaying mixed content |
| 570 // (even though the image comes from the WebCore memory cache). |
| 571 ui_test_utils::NavigateToURL(browser(), |
| 572 https_server->TestServerPage("files/ssl/page_runs_mixed_content.html")); |
| 573 CheckAuthenticationBrokenState(tab, 0, true, false); |
| 574 } |
| 575 |
519 // This test ensures the CN invalid status does not 'stick' to a certificate | 576 // This test ensures the CN invalid status does not 'stick' to a certificate |
520 // (see bug #1044942) and that it depends on the host-name. | 577 // (see bug #1044942) and that it depends on the host-name. |
521 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCNInvalidStickiness) { | 578 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCNInvalidStickiness) { |
522 const std::string kLocalHost = "localhost"; | 579 const std::string kLocalHost = "localhost"; |
523 scoped_refptr<HTTPSTestServer> https_server = | 580 scoped_refptr<HTTPSTestServer> https_server = |
524 HTTPSTestServer::CreateMismatchedServer(kDocRoot); | 581 HTTPSTestServer::CreateMismatchedServer(kDocRoot); |
525 ASSERT_TRUE(https_server.get() != NULL); | 582 ASSERT_TRUE(https_server.get() != NULL); |
526 | 583 |
527 // First we hit the server with hostname, this generates an invalid policy | 584 // First we hit the server with hostname, this generates an invalid policy |
528 // error. | 585 // error. |
529 ui_test_utils::NavigateToURL(browser(), | 586 ui_test_utils::NavigateToURL(browser(), |
530 https_server->TestServerPage("files/ssl/google.html")); | 587 https_server->TestServerPage("files/ssl/google.html")); |
531 | 588 |
532 // We get an interstitial page as a result. | 589 // We get an interstitial page as a result. |
533 TabContents* tab = browser()->GetSelectedTabContents(); | 590 TabContents* tab = browser()->GetSelectedTabContents(); |
534 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 591 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
535 true); // Interstitial showing. | 592 false, true); // Interstitial showing. |
536 | 593 |
537 ProceedThroughInterstitial(tab); | 594 ProceedThroughInterstitial(tab); |
538 | 595 |
539 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 596 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
540 false); // No interstitial showing. | 597 false, false); // No interstitial showing. |
541 | 598 |
542 // Now we try again with the right host name this time. | 599 // Now we try again with the right host name this time. |
543 | 600 |
544 // Let's change the host-name in the url. | 601 // Let's change the host-name in the url. |
545 GURL url = https_server->TestServerPage("files/ssl/google.html"); | 602 GURL url = https_server->TestServerPage("files/ssl/google.html"); |
546 std::string::size_type hostname_index = url.spec().find(kLocalHost); | 603 std::string::size_type hostname_index = url.spec().find(kLocalHost); |
547 ASSERT_TRUE(hostname_index != std::string::npos); // Test sanity check. | 604 ASSERT_TRUE(hostname_index != std::string::npos); // Test sanity check. |
548 std::string new_url; | 605 std::string new_url; |
549 new_url.append(url.spec().substr(0, hostname_index)); | 606 new_url.append(url.spec().substr(0, hostname_index)); |
550 new_url.append(net::TestServerLauncher::kHostName); | 607 new_url.append(net::TestServerLauncher::kHostName); |
551 new_url.append(url.spec().substr(hostname_index + kLocalHost.size())); | 608 new_url.append(url.spec().substr(hostname_index + kLocalHost.size())); |
552 | 609 |
553 ui_test_utils::NavigateToURL(browser(), GURL(new_url)); | 610 ui_test_utils::NavigateToURL(browser(), GURL(new_url)); |
554 | 611 |
555 // Security state should be OK. | 612 // Security state should be OK. |
556 CheckAuthenticatedState(tab, false); | 613 CheckAuthenticatedState(tab, false); |
557 | 614 |
558 // Now try again the broken one to make sure it is still broken. | 615 // Now try again the broken one to make sure it is still broken. |
559 ui_test_utils::NavigateToURL(browser(), | 616 ui_test_utils::NavigateToURL(browser(), |
560 https_server->TestServerPage("files/ssl/google.html")); | 617 https_server->TestServerPage("files/ssl/google.html")); |
561 | 618 |
562 // Since we OKed the interstitial last time, we get right to the page. | 619 // Since we OKed the interstitial last time, we get right to the page. |
563 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 620 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
564 false); // No interstitial showing. | 621 false, false); // No interstitial showing. |
565 } | 622 } |
566 | 623 |
567 // Test that navigating to a #ref does not change a bad security state. | 624 // Test that navigating to a #ref does not change a bad security state. |
568 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { | 625 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { |
569 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 626 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
570 ASSERT_TRUE(bad_https_server.get() != NULL); | 627 ASSERT_TRUE(bad_https_server.get() != NULL); |
571 | 628 |
572 ui_test_utils::NavigateToURL(browser(), | 629 ui_test_utils::NavigateToURL(browser(), |
573 bad_https_server->TestServerPage("files/ssl/page_with_refs.html")); | 630 bad_https_server->TestServerPage("files/ssl/page_with_refs.html")); |
574 | 631 |
575 TabContents* tab = browser()->GetSelectedTabContents(); | 632 TabContents* tab = browser()->GetSelectedTabContents(); |
576 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 633 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
577 true); // Interstitial showing. | 634 true); // Interstitial showing. |
578 | 635 |
579 ProceedThroughInterstitial(tab); | 636 ProceedThroughInterstitial(tab); |
580 | 637 |
581 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 638 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
582 false); // No interstitial showing. | 639 false); // No interstitial showing. |
583 | 640 |
584 // Now navigate to a ref in the page, the security state should not have | 641 // Now navigate to a ref in the page, the security state should not have |
585 // changed. | 642 // changed. |
586 ui_test_utils::NavigateToURL(browser(), | 643 ui_test_utils::NavigateToURL(browser(), |
587 bad_https_server->TestServerPage("files/ssl/page_with_refs.html#jp")); | 644 bad_https_server->TestServerPage("files/ssl/page_with_refs.html#jp")); |
588 | 645 |
589 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 646 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
590 false); // No interstitial showing. | 647 false); // No interstitial showing. |
591 } | 648 } |
592 | 649 |
593 // Tests that closing a page that has a unsafe pop-up does not crash the | 650 // Tests that closing a page that has a unsafe pop-up does not crash the |
594 // browser (bug #1966). | 651 // browser (bug #1966). |
595 // TODO(jcampan): http://crbug.com/2136 disabled because the popup is not | 652 // TODO(jcampan): http://crbug.com/2136 disabled because the popup is not |
596 // opened as it is not initiated by a user gesture. | 653 // opened as it is not initiated by a user gesture. |
597 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { | 654 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { |
598 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 655 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
599 ASSERT_TRUE(http_server.get() != NULL); | 656 ASSERT_TRUE(http_server.get() != NULL); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 692 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
636 ASSERT_TRUE(bad_https_server.get() != NULL); | 693 ASSERT_TRUE(bad_https_server.get() != NULL); |
637 | 694 |
638 GURL url1 = bad_https_server->TestServerPage("server-redirect?"); | 695 GURL url1 = bad_https_server->TestServerPage("server-redirect?"); |
639 GURL url2 = good_https_server->TestServerPage("files/ssl/google.html"); | 696 GURL url2 = good_https_server->TestServerPage("files/ssl/google.html"); |
640 | 697 |
641 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); | 698 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); |
642 | 699 |
643 TabContents* tab = browser()->GetSelectedTabContents(); | 700 TabContents* tab = browser()->GetSelectedTabContents(); |
644 | 701 |
645 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 702 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
646 true); // Interstitial showing. | 703 true); // Interstitial showing. |
647 | 704 |
648 ProceedThroughInterstitial(tab); | 705 ProceedThroughInterstitial(tab); |
649 | 706 |
650 // We have been redirected to the good page. | 707 // We have been redirected to the good page. |
651 CheckAuthenticatedState(tab, false); | 708 CheckAuthenticatedState(tab, false); |
652 } | 709 } |
653 | 710 |
654 // Visit a page over good https that is a redirect to a page with bad https. | 711 // Visit a page over good https that is a redirect to a page with bad https. |
655 // Marked as flaky, see bug 40932. | 712 // Marked as flaky, see bug 40932. |
656 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectGoodToBadHTTPS) { | 713 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectGoodToBadHTTPS) { |
657 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 714 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
658 ASSERT_TRUE(good_https_server.get() != NULL); | 715 ASSERT_TRUE(good_https_server.get() != NULL); |
659 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 716 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
660 ASSERT_TRUE(bad_https_server.get() != NULL); | 717 ASSERT_TRUE(bad_https_server.get() != NULL); |
661 | 718 |
662 GURL url1 = good_https_server->TestServerPage("server-redirect?"); | 719 GURL url1 = good_https_server->TestServerPage("server-redirect?"); |
663 GURL url2 = bad_https_server->TestServerPage("files/ssl/google.html"); | 720 GURL url2 = bad_https_server->TestServerPage("files/ssl/google.html"); |
664 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); | 721 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); |
665 | 722 |
666 TabContents* tab = browser()->GetSelectedTabContents(); | 723 TabContents* tab = browser()->GetSelectedTabContents(); |
667 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 724 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
668 true); // Interstitial showing. | 725 true); // Interstitial showing. |
669 | 726 |
670 ProceedThroughInterstitial(tab); | 727 ProceedThroughInterstitial(tab); |
671 | 728 |
672 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 729 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
673 false); // No interstitial showing. | 730 false); // No interstitial showing. |
674 } | 731 } |
675 | 732 |
676 // Visit a page over http that is a redirect to a page with good HTTPS. | 733 // Visit a page over http that is a redirect to a page with good HTTPS. |
677 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) { | 734 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) { |
678 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 735 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
679 ASSERT_TRUE(http_server.get() != NULL); | 736 ASSERT_TRUE(http_server.get() != NULL); |
680 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 737 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
681 ASSERT_TRUE(good_https_server.get() != NULL); | 738 ASSERT_TRUE(good_https_server.get() != NULL); |
682 | 739 |
(...skipping 16 matching lines...) Expand all Loading... |
699 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 756 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
700 ASSERT_TRUE(bad_https_server.get() != NULL); | 757 ASSERT_TRUE(bad_https_server.get() != NULL); |
701 | 758 |
702 TabContents* tab = browser()->GetSelectedTabContents(); | 759 TabContents* tab = browser()->GetSelectedTabContents(); |
703 | 760 |
704 GURL http_url = http_server->TestServerPage("server-redirect?"); | 761 GURL http_url = http_server->TestServerPage("server-redirect?"); |
705 GURL bad_https_url = | 762 GURL bad_https_url = |
706 bad_https_server->TestServerPage("files/ssl/google.html"); | 763 bad_https_server->TestServerPage("files/ssl/google.html"); |
707 ui_test_utils::NavigateToURL(browser(), | 764 ui_test_utils::NavigateToURL(browser(), |
708 GURL(http_url.spec() + bad_https_url.spec())); | 765 GURL(http_url.spec() + bad_https_url.spec())); |
709 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 766 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
710 true); // Interstitial showing. | 767 true); // Interstitial showing. |
711 | 768 |
712 ProceedThroughInterstitial(tab); | 769 ProceedThroughInterstitial(tab); |
713 | 770 |
714 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 771 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
715 false); // No interstitial showing. | 772 false); // No interstitial showing. |
716 } | 773 } |
717 | 774 |
718 // Visit a page over https that is a redirect to a page with http (to make sure | 775 // Visit a page over https that is a redirect to a page with http (to make sure |
719 // we don't keep the secure state). | 776 // we don't keep the secure state). |
720 // Marked as flaky, see bug 40932. | 777 // Marked as flaky, see bug 40932. |
721 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectHTTPSToHTTP) { | 778 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectHTTPSToHTTP) { |
722 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 779 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
723 ASSERT_TRUE(http_server.get() != NULL); | 780 ASSERT_TRUE(http_server.get() != NULL); |
724 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 781 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
(...skipping 20 matching lines...) Expand all Loading... |
745 | 802 |
746 // | 803 // |
747 // Frame navigation | 804 // Frame navigation |
748 // | 805 // |
749 | 806 |
750 // From a good HTTPS top frame: | 807 // From a good HTTPS top frame: |
751 // - navigate to an OK HTTPS frame | 808 // - navigate to an OK HTTPS frame |
752 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then | 809 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then |
753 // back | 810 // back |
754 // - navigate to HTTP (expect mixed content), then back | 811 // - navigate to HTTP (expect mixed content), then back |
755 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestGoodFrameNavigation) { | 812 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestGoodFrameNavigation) { |
756 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 813 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
757 ASSERT_TRUE(http_server.get() != NULL); | 814 ASSERT_TRUE(http_server.get() != NULL); |
758 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 815 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
759 ASSERT_TRUE(good_https_server.get() != NULL); | 816 ASSERT_TRUE(good_https_server.get() != NULL); |
760 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 817 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
761 ASSERT_TRUE(bad_https_server.get() != NULL); | 818 ASSERT_TRUE(bad_https_server.get() != NULL); |
762 | 819 |
763 TabContents* tab = browser()->GetSelectedTabContents(); | 820 TabContents* tab = browser()->GetSelectedTabContents(); |
764 ui_test_utils::NavigateToURL(browser(), | 821 ui_test_utils::NavigateToURL(browser(), |
765 good_https_server->TestServerPage("files/ssl/top_frame.html")); | 822 good_https_server->TestServerPage("files/ssl/top_frame.html")); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 // Marked as flaky, see bug 40932. | 883 // Marked as flaky, see bug 40932. |
827 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { | 884 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { |
828 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 885 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
829 ASSERT_TRUE(good_https_server.get() != NULL); | 886 ASSERT_TRUE(good_https_server.get() != NULL); |
830 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 887 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
831 ASSERT_TRUE(bad_https_server.get() != NULL); | 888 ASSERT_TRUE(bad_https_server.get() != NULL); |
832 | 889 |
833 TabContents* tab = browser()->GetSelectedTabContents(); | 890 TabContents* tab = browser()->GetSelectedTabContents(); |
834 ui_test_utils::NavigateToURL(browser(), | 891 ui_test_utils::NavigateToURL(browser(), |
835 bad_https_server->TestServerPage("files/ssl/top_frame.html")); | 892 bad_https_server->TestServerPage("files/ssl/top_frame.html")); |
836 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 893 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
837 true); // Interstitial showing | 894 true); // Interstitial showing |
838 | 895 |
839 ProceedThroughInterstitial(tab); | 896 ProceedThroughInterstitial(tab); |
840 | 897 |
841 // Navigate to a good frame. | 898 // Navigate to a good frame. |
842 bool success = false; | 899 bool success = false; |
843 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 900 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
844 tab->render_view_host(), std::wstring(), | 901 tab->render_view_host(), std::wstring(), |
845 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 902 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
846 &success)); | 903 &success)); |
847 EXPECT_TRUE(success); | 904 EXPECT_TRUE(success); |
848 ui_test_utils::WaitForNavigation(&tab->controller()); | 905 ui_test_utils::WaitForNavigation(&tab->controller()); |
849 | 906 |
850 // We should still be authentication broken. | 907 // We should still be authentication broken. |
851 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false); | 908 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
| 909 false); |
852 } | 910 } |
853 | 911 |
854 // From an HTTP top frame, navigate to good and bad HTTPS (security state should | 912 // From an HTTP top frame, navigate to good and bad HTTPS (security state should |
855 // stay unauthenticated). | 913 // stay unauthenticated). |
856 // Marked as flaky, see bug 40932. | 914 // Marked as flaky, see bug 40932. |
857 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. | 915 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. |
858 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { | 916 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { |
859 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 917 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
860 ASSERT_TRUE(http_server.get() != NULL); | 918 ASSERT_TRUE(http_server.get() != NULL); |
861 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 919 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 983 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
926 ASSERT_TRUE(good_https_server.get() != NULL); | 984 ASSERT_TRUE(good_https_server.get() != NULL); |
927 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 985 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
928 ASSERT_TRUE(bad_https_server.get() != NULL); | 986 ASSERT_TRUE(bad_https_server.get() != NULL); |
929 | 987 |
930 // Navigate to an unsafe site. Proceed with interstitial page to indicate | 988 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
931 // the user approves the bad certificate. | 989 // the user approves the bad certificate. |
932 ui_test_utils::NavigateToURL(browser(), | 990 ui_test_utils::NavigateToURL(browser(), |
933 bad_https_server->TestServerPage("files/ssl/blank_page.html")); | 991 bad_https_server->TestServerPage("files/ssl/blank_page.html")); |
934 TabContents* tab = browser()->GetSelectedTabContents(); | 992 TabContents* tab = browser()->GetSelectedTabContents(); |
935 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 993 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
936 true); // Interstitial showing | 994 true); // Interstitial showing |
937 ProceedThroughInterstitial(tab); | 995 ProceedThroughInterstitial(tab); |
938 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 996 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
939 false); // No Interstitial | 997 false); // No Interstitial |
940 | 998 |
941 // Navigate to safe page that has Worker loading unsafe content. | 999 // Navigate to safe page that has Worker loading unsafe content. |
942 // Expect content to load but 'mixed' indicators show up. | 1000 // Expect content to load but be marked as auth broken due to running mixed |
| 1001 // content. |
943 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPage( | 1002 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPage( |
944 "files/ssl/page_with_unsafe_worker.html")); | 1003 "files/ssl/page_with_unsafe_worker.html")); |
945 CheckWorkerLoadResult(tab, true); // Worker loads mixed content | 1004 CheckWorkerLoadResult(tab, true); // Worker loads mixed content |
946 CheckAuthenticatedState(tab, true); | 1005 CheckAuthenticationBrokenState(tab, 0, true, false); |
947 } | 1006 } |
948 | 1007 |
949 // TODO(jcampan): more tests to do below. | 1008 // TODO(jcampan): more tests to do below. |
950 | 1009 |
951 // Visit a page over https that contains a frame with a redirect. | 1010 // Visit a page over https that contains a frame with a redirect. |
952 | 1011 |
953 // XMLHttpRequest mixed in synchronous mode. | 1012 // XMLHttpRequest mixed in synchronous mode. |
954 | 1013 |
955 // XMLHttpRequest mixed in asynchronous mode. | 1014 // XMLHttpRequest mixed in asynchronous mode. |
956 | 1015 |
957 // XMLHttpRequest over bad ssl in synchronous mode. | 1016 // XMLHttpRequest over bad ssl in synchronous mode. |
958 | 1017 |
959 // XMLHttpRequest over OK ssl in synchronous mode. | 1018 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |