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

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

Issue 42314: SSLPolicy fix: Step 9. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/ssl/ssl_policy.cc ('k') | chrome/browser/tab_contents/navigation_controller.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <Windows.h> 5 #include <Windows.h>
6 #include <Wincrypt.h> 6 #include <Wincrypt.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/filter_policy.h" 10 #include "chrome/common/filter_policy.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 SecurityStyle security_style; 236 SecurityStyle security_style;
237 int cert_status; 237 int cert_status;
238 int mixed_content_state; 238 int mixed_content_state;
239 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 239 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
240 &mixed_content_state)); 240 &mixed_content_state));
241 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 241 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
242 EXPECT_EQ(0, 242 EXPECT_EQ(0,
243 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected. 243 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
244 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state); 244 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
245 }
246
247 // Visits a page with mixed content.
248 TEST_F(SSLUITest, TestMixedContentsFilterAll) {
249 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer();
250 scoped_refptr<HTTPTestServer> http_server = PlainServer();
245 251
246 // Now select the block mixed-content pref and reload the page. 252 // Now select the block mixed-content pref and reload the page.
247 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 253 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
248 EXPECT_TRUE(browser_proxy.get()); 254 EXPECT_TRUE(browser_proxy.get());
249 EXPECT_TRUE(browser_proxy->SetIntPreference(prefs::kMixedContentFiltering, 255 EXPECT_TRUE(browser_proxy->SetIntPreference(prefs::kMixedContentFiltering,
250 FilterPolicy::FILTER_ALL)); 256 FilterPolicy::FILTER_ALL));
251 EXPECT_TRUE(tab->Reload()); 257
258 // Load a page with mixed-content, we've overridden our filtering policy so
259 // we won't load the mixed content by default.
260 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
261 NavigateTab(
262 tab.get(),
263 https_server->TestServerPageW(
264 L"files/ssl/page_with_mixed_contents.html"));
265 NavigationEntry::PageType page_type;
266 EXPECT_TRUE(tab->GetPageType(&page_type));
267 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
252 268
253 // The image should be filtered. 269 // The image should be filtered.
254 int img_width; 270 int img_width;
255 EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", 271 EXPECT_TRUE(tab->ExecuteAndExtractInt(L"",
256 L"window.domAutomationController.send(ImageWidth());", 272 L"window.domAutomationController.send(ImageWidth());",
257 &img_width)); 273 &img_width));
258 // In order to check that the image was not loaded, we check its width. 274 // In order to check that the image was not loaded, we check its width.
259 // The actual image (Google logo) is 114 pixels wide, we assume the broken 275 // The actual image (Google logo) is 114 pixels wide, we assume the broken
260 // image is less than 100. 276 // image is less than 100.
261 EXPECT_GT(100, img_width); 277 EXPECT_GT(100, img_width);
262 278
279 SecurityStyle security_style;
280 int cert_status;
281 int mixed_content_state;
263 // The state should be OK since we are not showing the resource. 282 // The state should be OK since we are not showing the resource.
264 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 283 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
265 &mixed_content_state)); 284 &mixed_content_state));
266 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 285 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
267 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS); 286 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
268 EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state); 287 EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
269 288
270 // There should be one info-bar to show the mixed-content. 289 // There should be one info-bar to show the mixed-content.
271 int info_bar_count = 0; 290 int info_bar_count = 0;
272 EXPECT_TRUE(tab->GetSSLInfoBarCount(&info_bar_count)); 291 EXPECT_TRUE(tab->GetSSLInfoBarCount(&info_bar_count));
273 EXPECT_EQ(1, info_bar_count); 292 EXPECT_EQ(1, info_bar_count);
274 293
275 // Activate the link on the info-bar to show the mixed-content. 294 // Activate the link on the info-bar to show the mixed-content.
276 EXPECT_TRUE(tab->ClickSSLInfoBarLink(0, true)); 295 EXPECT_TRUE(tab->ClickSSLInfoBarLink(0, true));
277 296
278 // The image should show now. 297 // The image should show now.
279 EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", 298 EXPECT_TRUE(tab->ExecuteAndExtractInt(L"",
280 L"window.domAutomationController.send(ImageWidth());", 299 L"window.domAutomationController.send(ImageWidth());",
281 &img_width)); 300 &img_width));
282 EXPECT_LT(100, img_width); 301 EXPECT_LT(100, img_width);
283 302
284 // And our status should be mixed-content. 303 // And our status should be mixed-content.
285 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 304 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
286 &mixed_content_state)); 305 &mixed_content_state));
287 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 306 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
288 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS); 307 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
289 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state); 308 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
290 } 309 }
291 310
311 // Visits a page with an http script that tries to suppress our mixed content
312 // warnings by randomize location.hash.
313 // Based on http://crbug.com/8706
314 TEST_F(SSLUITest, TestMixedContentsRandomizeHash) {
315 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer();
316 scoped_refptr<HTTPTestServer> http_server = PlainServer();
317
318 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
319 NavigateTab(
320 tab.get(),
321 https_server->TestServerPageW(
322 L"files/ssl/page_with_http_script.html"));
323 NavigationEntry::PageType page_type;
324 EXPECT_TRUE(tab->GetPageType(&page_type));
325 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
326
327 SecurityStyle security_style;
328 int cert_status;
329 int mixed_content_state;
330 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
331 &mixed_content_state));
332 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
333 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
334 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
335 }
336
292 // Visits a page with unsafe content and make sure that: 337 // Visits a page with unsafe content and make sure that:
293 // - frames content is replaced with warning 338 // - frames content is replaced with warning
294 // - images and scripts are filtered out entirely 339 // - images and scripts are filtered out entirely
295 TEST_F(SSLUITest, TestUnsafeContents) { 340 TEST_F(SSLUITest, TestUnsafeContents) {
296 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); 341 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer();
297 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); 342 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer();
298 343
299 scoped_ptr<TabProxy> tab(GetActiveTabProxy()); 344 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
300 NavigateTab(tab.get(), 345 NavigateTab(tab.get(),
301 good_https_server->TestServerPageW( 346 good_https_server->TestServerPageW(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 416
372 // We should now have mixed-contents. 417 // We should now have mixed-contents.
373 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 418 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
374 &mixed_content_state)); 419 &mixed_content_state));
375 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 420 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
376 EXPECT_EQ(0, 421 EXPECT_EQ(0,
377 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected. 422 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
378 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state); 423 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
379 } 424 }
380 425
426 // Visits two pages from the same origin: one with mixed content and one
427 // without. The test checks that we propagate the mixed content state from one
428 // to the other.
429 TEST_F(SSLUITest, TestMixedContentsTwoTabs) {
430 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer();
431 scoped_refptr<HTTPTestServer> http_server = PlainServer();
432
433 scoped_ptr<TabProxy> tab1(GetActiveTabProxy());
434 NavigateTab(
435 tab1.get(),
436 https_server->TestServerPageW(
437 L"files/ssl/blank_page.html"));
438 NavigationEntry::PageType page_type;
439 EXPECT_TRUE(tab1->GetPageType(&page_type));
440 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
441
442 // This tab should be fine.
443 SecurityStyle security_style;
444 int cert_status;
445 int mixed_content_state;
446 EXPECT_TRUE(tab1->GetSecurityState(&security_style, &cert_status,
447 &mixed_content_state));
448 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
449 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
450 EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
451
452 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
453 EXPECT_TRUE(browser_proxy.get());
454 EXPECT_TRUE(browser_proxy->AppendTab(
455 https_server->TestServerPageW(L"files/ssl/page_with_http_script.html")));
456
457 scoped_ptr<TabProxy> tab2(GetActiveTabProxy());
458 EXPECT_TRUE(tab2->GetPageType(&page_type));
459 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
460
461 // The new tab has mixed content.
462 EXPECT_TRUE(tab2->GetSecurityState(&security_style, &cert_status,
463 &mixed_content_state));
464 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
465 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
466 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
467
468 // Which means the origin for the first tab has also been contaminated with
469 // mixed content.
470 EXPECT_TRUE(tab1->GetSecurityState(&security_style, &cert_status,
471 &mixed_content_state));
472 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
473 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
474 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
475 }
476
381 // Visits a page with an image over http. Visits another page over https 477 // Visits a page with an image over http. Visits another page over https
382 // referencing that same image over http (hoping it is coming from the webcore 478 // referencing that same image over http (hoping it is coming from the webcore
383 // memory cache). 479 // memory cache).
384 TEST_F(SSLUITest, TestCachedMixedContents) { 480 TEST_F(SSLUITest, TestCachedMixedContents) {
385 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); 481 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer();
386 scoped_refptr<HTTPTestServer> http_server = PlainServer(); 482 scoped_refptr<HTTPTestServer> http_server = PlainServer();
387 483
388 scoped_ptr<TabProxy> tab(GetActiveTabProxy()); 484 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
389 NavigateTab(tab.get(), http_server->TestServerPageW( 485 NavigateTab(tab.get(), http_server->TestServerPageW(
390 L"files/ssl/page_with_mixed_contents.html")); 486 L"files/ssl/page_with_mixed_contents.html"));
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); 892 EXPECT_TRUE(tab->WaitForNavigation(last_nav_time));
797 893
798 // Our state should be mixed-content. 894 // Our state should be mixed-content.
799 // Status should be "contains bad contents". 895 // Status should be "contains bad contents".
800 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 896 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
801 &mixed_content_state)); 897 &mixed_content_state));
802 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 898 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
803 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS); 899 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
804 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state); 900 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
805 901
806 // Go back, our state should be back to OK. 902 // Go back, our state should be unchanged.
807 EXPECT_TRUE(tab->GoBack()); 903 EXPECT_TRUE(tab->GoBack());
808 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 904 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
809 &mixed_content_state)); 905 &mixed_content_state));
810 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 906 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
811 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS); 907 EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
812 EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state); 908 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
813 } 909 }
814 910
815 // From a bad HTTPS top frame: 911 // From a bad HTTPS top frame:
816 // - navigate to an OK HTTPS frame (expected to be still authentication broken). 912 // - navigate to an OK HTTPS frame (expected to be still authentication broken).
817 TEST_F(SSLUITest, TestBadFrameNavigation) { 913 TEST_F(SSLUITest, TestBadFrameNavigation) {
818 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); 914 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer();
819 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); 915 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer();
820 916
821 scoped_ptr<TabProxy> tab(GetActiveTabProxy()); 917 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
822 NavigateTab(tab.get(), 918 NavigateTab(tab.get(),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 1019
924 // Visit a page over https that contains a frame with a redirect. 1020 // Visit a page over https that contains a frame with a redirect.
925 1021
926 // XMLHttpRequest mixed in synchronous mode. 1022 // XMLHttpRequest mixed in synchronous mode.
927 1023
928 // XMLHttpRequest mixed in asynchronous mode. 1024 // XMLHttpRequest mixed in asynchronous mode.
929 1025
930 // XMLHttpRequest over bad ssl in synchronous mode. 1026 // XMLHttpRequest over bad ssl in synchronous mode.
931 1027
932 // XMLHttpRequest over OK ssl in synchronous mode. 1028 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_policy.cc ('k') | chrome/browser/tab_contents/navigation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698