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

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

Issue 2542533004: Override DevTools security summary when a Safe Browsing warning shows. (Closed)
Patch Set: Parameters for the securityStatusChanged event and related objects are not optional Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ssl/security_state_tab_helper.h" 5 #include "chrome/browser/ssl/security_state_tab_helper.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 observer.latest_security_style()); 1536 observer.latest_security_style());
1537 EXPECT_EQ(0u, 1537 EXPECT_EQ(0u,
1538 observer.latest_explanations().unauthenticated_explanations.size()); 1538 observer.latest_explanations().unauthenticated_explanations.size());
1539 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 1539 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
1540 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); 1540 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size());
1541 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); 1541 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic);
1542 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1542 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1543 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1543 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1544 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); 1544 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
1545 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1545 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1546 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1546 1547
1547 // Visit an (otherwise valid) HTTPS page that displays mixed content. 1548 // Visit an (otherwise valid) HTTPS page that displays mixed content.
1548 std::string replacement_path; 1549 std::string replacement_path;
1549 GetFilePathWithHostAndPortReplacement( 1550 GetFilePathWithHostAndPortReplacement(
1550 "/ssl/page_displays_insecure_content.html", 1551 "/ssl/page_displays_insecure_content.html",
1551 embedded_test_server()->host_port_pair(), &replacement_path); 1552 embedded_test_server()->host_port_pair(), &replacement_path);
1552 1553
1553 GURL mixed_content_url(https_server_.GetURL(replacement_path)); 1554 GURL mixed_content_url(https_server_.GetURL(replacement_path));
1554 ui_test_utils::NavigateToURL(browser(), mixed_content_url); 1555 ui_test_utils::NavigateToURL(browser(), mixed_content_url);
1555 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, 1556 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated,
1556 observer.latest_security_style()); 1557 observer.latest_security_style());
1557 1558
1558 const content::SecurityStyleExplanations& mixed_content_explanation = 1559 const content::SecurityStyleExplanations& mixed_content_explanation =
1559 observer.latest_explanations(); 1560 observer.latest_explanations();
1560 ASSERT_EQ(0u, mixed_content_explanation.unauthenticated_explanations.size()); 1561 ASSERT_EQ(0u, mixed_content_explanation.unauthenticated_explanations.size());
1561 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); 1562 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size());
1562 CheckSecureExplanations(mixed_content_explanation.secure_explanations, 1563 CheckSecureExplanations(mixed_content_explanation.secure_explanations,
1563 VALID_CERTIFICATE, browser(), 1564 VALID_CERTIFICATE, browser(),
1564 https_server_.GetCertificate().get()); 1565 https_server_.GetCertificate().get());
1565 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); 1566 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic);
1566 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1567 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1567 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1568 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1569 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1568 EXPECT_TRUE(mixed_content_explanation.displayed_mixed_content); 1570 EXPECT_TRUE(mixed_content_explanation.displayed_mixed_content);
1569 EXPECT_FALSE(mixed_content_explanation.ran_mixed_content); 1571 EXPECT_FALSE(mixed_content_explanation.ran_mixed_content);
1570 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, 1572 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated,
1571 mixed_content_explanation.displayed_insecure_content_style); 1573 mixed_content_explanation.displayed_insecure_content_style);
1572 EXPECT_EQ(blink::WebSecurityStyleAuthenticationBroken, 1574 EXPECT_EQ(blink::WebSecurityStyleAuthenticationBroken,
1573 mixed_content_explanation.ran_insecure_content_style); 1575 mixed_content_explanation.ran_insecure_content_style);
1574 1576
1575 // Visit a broken HTTPS url. 1577 // Visit a broken HTTPS url.
1576 GURL expired_url(https_test_server_expired.GetURL("/title1.html")); 1578 GURL expired_url(https_test_server_expired.GetURL("/title1.html"));
1577 ui_test_utils::NavigateToURL(browser(), expired_url); 1579 ui_test_utils::NavigateToURL(browser(), expired_url);
1578 1580
1579 // An interstitial should show, and an event for the lock icon on the 1581 // An interstitial should show, and an event for the lock icon on the
1580 // interstitial should fire. 1582 // interstitial should fire.
1581 content::WaitForInterstitialAttach(web_contents); 1583 content::WaitForInterstitialAttach(web_contents);
1582 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); 1584 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
1583 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(), 1585 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(),
1584 https_test_server_expired.GetCertificate().get()); 1586 https_test_server_expired.GetCertificate().get());
1585 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1587 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1586 INVALID_CERTIFICATE, browser(), 1588 INVALID_CERTIFICATE, browser(),
1587 https_test_server_expired.GetCertificate().get()); 1589 https_test_server_expired.GetCertificate().get());
1588 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1590 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1589 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1591 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1590 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1592 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1591 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1593 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1592 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); 1594 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
1595 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1593 1596
1594 // Before clicking through, navigate to a different page, and then go 1597 // Before clicking through, navigate to a different page, and then go
1595 // back to the interstitial. 1598 // back to the interstitial.
1596 GURL valid_https_url(https_server_.GetURL("/title1.html")); 1599 GURL valid_https_url(https_server_.GetURL("/title1.html"));
1597 ui_test_utils::NavigateToURL(browser(), valid_https_url); 1600 ui_test_utils::NavigateToURL(browser(), valid_https_url);
1598 EXPECT_EQ(blink::WebSecurityStyleAuthenticated, 1601 EXPECT_EQ(blink::WebSecurityStyleAuthenticated,
1599 observer.latest_security_style()); 1602 observer.latest_security_style());
1600 EXPECT_EQ(0u, 1603 EXPECT_EQ(0u,
1601 observer.latest_explanations().unauthenticated_explanations.size()); 1604 observer.latest_explanations().unauthenticated_explanations.size());
1602 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 1605 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
1603 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1606 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1604 VALID_CERTIFICATE, browser(), 1607 VALID_CERTIFICATE, browser(),
1605 https_server_.GetCertificate().get()); 1608 https_server_.GetCertificate().get());
1606 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1609 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1607 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1610 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1608 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1611 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1609 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1612 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1610 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); 1613 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
1614 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1611 1615
1612 // After going back to the interstitial, an event for a broken lock 1616 // After going back to the interstitial, an event for a broken lock
1613 // icon should fire again. 1617 // icon should fire again.
1614 ui_test_utils::NavigateToURL(browser(), expired_url); 1618 ui_test_utils::NavigateToURL(browser(), expired_url);
1615 content::WaitForInterstitialAttach(web_contents); 1619 content::WaitForInterstitialAttach(web_contents);
1616 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); 1620 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
1617 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(), 1621 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(),
1618 https_test_server_expired.GetCertificate().get()); 1622 https_test_server_expired.GetCertificate().get());
1619 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1623 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1620 INVALID_CERTIFICATE, browser(), 1624 INVALID_CERTIFICATE, browser(),
1621 https_test_server_expired.GetCertificate().get()); 1625 https_test_server_expired.GetCertificate().get());
1622 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1626 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1623 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1627 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1624 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1628 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1625 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1629 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1626 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); 1630 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
1631 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1627 1632
1628 // Since the next expected style is the same as the previous, clear 1633 // Since the next expected style is the same as the previous, clear
1629 // the observer (to make sure that the event fires twice and we don't 1634 // the observer (to make sure that the event fires twice and we don't
1630 // just see the previous event's style). 1635 // just see the previous event's style).
1631 observer.ClearLatestSecurityStyleAndExplanations(); 1636 observer.ClearLatestSecurityStyleAndExplanations();
1632 1637
1633 // Other conditions cannot be tested on this host after clicking 1638 // Other conditions cannot be tested on this host after clicking
1634 // through because once the interstitial is clicked through, all URLs 1639 // through because once the interstitial is clicked through, all URLs
1635 // for this host will remain in a broken state. 1640 // for this host will remain in a broken state.
1636 ProceedThroughInterstitial(web_contents); 1641 ProceedThroughInterstitial(web_contents);
1637 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(), 1642 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(),
1638 https_test_server_expired.GetCertificate().get()); 1643 https_test_server_expired.GetCertificate().get());
1639 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1644 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1640 INVALID_CERTIFICATE, browser(), 1645 INVALID_CERTIFICATE, browser(),
1641 https_test_server_expired.GetCertificate().get()); 1646 https_test_server_expired.GetCertificate().get());
1642 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1647 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1643 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1648 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1644 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1649 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1645 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1650 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1646 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); 1651 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
1652 EXPECT_TRUE(observer.latest_explanations().summary_override.empty());
1647 } 1653 }
1648 1654
1649 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back, 1655 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back,
1650 // and test that the observed security style matches. 1656 // and test that the observed security style matches.
1651 #if defined(OS_CHROMEOS) 1657 #if defined(OS_CHROMEOS)
1652 // Flaky on Chrome OS. See https://crbug.com/638576. 1658 // Flaky on Chrome OS. See https://crbug.com/638576.
1653 #define MAYBE_SecurityStyleChangedObserverGoBack \ 1659 #define MAYBE_SecurityStyleChangedObserverGoBack \
1654 DISABLED_SecurityStyleChangedObserverGoBack 1660 DISABLED_SecurityStyleChangedObserverGoBack
1655 #else 1661 #else
1656 #define MAYBE_SecurityStyleChangedObserverGoBack \ 1662 #define MAYBE_SecurityStyleChangedObserverGoBack \
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 SecurityStateTabHelper* helper = 2037 SecurityStateTabHelper* helper =
2032 SecurityStateTabHelper::FromWebContents(web_contents); 2038 SecurityStateTabHelper::FromWebContents(web_contents);
2033 ASSERT_TRUE(helper); 2039 ASSERT_TRUE(helper);
2034 security_state::SecurityInfo security_info; 2040 security_state::SecurityInfo security_info;
2035 helper->GetSecurityInfo(&security_info); 2041 helper->GetSecurityInfo(&security_info);
2036 EXPECT_EQ(security_state::SECURE, security_info.security_level); 2042 EXPECT_EQ(security_state::SECURE, security_info.security_level);
2037 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 2043 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
2038 } 2044 }
2039 2045
2040 } // namespace 2046 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698