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