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

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

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

Powered by Google App Engine
This is Rietveld 408576698