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

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: Redefine event parameter (optional instead of nullable) for Closure Compiler 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.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.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.empty());
1596 EXPECT_TRUE(observer.latest_explanations().summary.empty());
estark 2016/12/07 01:00:09 redundant
1593 1597
1594 // Before clicking through, navigate to a different page, and then go 1598 // Before clicking through, navigate to a different page, and then go
1595 // back to the interstitial. 1599 // back to the interstitial.
1596 GURL valid_https_url(https_server_.GetURL("/title1.html")); 1600 GURL valid_https_url(https_server_.GetURL("/title1.html"));
1597 ui_test_utils::NavigateToURL(browser(), valid_https_url); 1601 ui_test_utils::NavigateToURL(browser(), valid_https_url);
1598 EXPECT_EQ(blink::WebSecurityStyleAuthenticated, 1602 EXPECT_EQ(blink::WebSecurityStyleAuthenticated,
1599 observer.latest_security_style()); 1603 observer.latest_security_style());
1600 EXPECT_EQ(0u, 1604 EXPECT_EQ(0u,
1601 observer.latest_explanations().unauthenticated_explanations.size()); 1605 observer.latest_explanations().unauthenticated_explanations.size());
1602 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 1606 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
1603 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1607 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1604 VALID_CERTIFICATE, browser(), 1608 VALID_CERTIFICATE, browser(),
1605 https_server_.GetCertificate().get()); 1609 https_server_.GetCertificate().get());
1606 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1610 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1607 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1611 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1608 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1612 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1609 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1613 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1610 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());
1611 1616
1612 // 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
1613 // icon should fire again. 1618 // icon should fire again.
1614 ui_test_utils::NavigateToURL(browser(), expired_url); 1619 ui_test_utils::NavigateToURL(browser(), expired_url);
1615 content::WaitForInterstitialAttach(web_contents); 1620 content::WaitForInterstitialAttach(web_contents);
1616 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); 1621 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
1617 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(), 1622 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(),
1618 https_test_server_expired.GetCertificate().get()); 1623 https_test_server_expired.GetCertificate().get());
1619 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1624 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1620 INVALID_CERTIFICATE, browser(), 1625 INVALID_CERTIFICATE, browser(),
1621 https_test_server_expired.GetCertificate().get()); 1626 https_test_server_expired.GetCertificate().get());
1622 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1627 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1623 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1628 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1624 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1629 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1625 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1630 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1626 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());
1627 1633
1628 // 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
1629 // 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
1630 // just see the previous event's style). 1636 // just see the previous event's style).
1631 observer.ClearLatestSecurityStyleAndExplanations(); 1637 observer.ClearLatestSecurityStyleAndExplanations();
1632 1638
1633 // Other conditions cannot be tested on this host after clicking 1639 // Other conditions cannot be tested on this host after clicking
1634 // through because once the interstitial is clicked through, all URLs 1640 // through because once the interstitial is clicked through, all URLs
1635 // for this host will remain in a broken state. 1641 // for this host will remain in a broken state.
1636 ProceedThroughInterstitial(web_contents); 1642 ProceedThroughInterstitial(web_contents);
1637 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(), 1643 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser(),
1638 https_test_server_expired.GetCertificate().get()); 1644 https_test_server_expired.GetCertificate().get());
1639 CheckSecureExplanations(observer.latest_explanations().secure_explanations, 1645 CheckSecureExplanations(observer.latest_explanations().secure_explanations,
1640 INVALID_CERTIFICATE, browser(), 1646 INVALID_CERTIFICATE, browser(),
1641 https_test_server_expired.GetCertificate().get()); 1647 https_test_server_expired.GetCertificate().get());
1642 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1648 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
1643 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1649 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
1644 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1650 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
1645 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); 1651 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content);
1646 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());
1647 } 1654 }
1648 1655
1649 // 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,
1650 // and test that the observed security style matches. 1657 // and test that the observed security style matches.
1651 #if defined(OS_CHROMEOS) 1658 #if defined(OS_CHROMEOS)
1652 // Flaky on Chrome OS. See https://crbug.com/638576. 1659 // Flaky on Chrome OS. See https://crbug.com/638576.
1653 #define MAYBE_SecurityStyleChangedObserverGoBack \ 1660 #define MAYBE_SecurityStyleChangedObserverGoBack \
1654 DISABLED_SecurityStyleChangedObserverGoBack 1661 DISABLED_SecurityStyleChangedObserverGoBack
1655 #else 1662 #else
1656 #define MAYBE_SecurityStyleChangedObserverGoBack \ 1663 #define MAYBE_SecurityStyleChangedObserverGoBack \
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 SecurityStateTabHelper* helper = 2038 SecurityStateTabHelper* helper =
2032 SecurityStateTabHelper::FromWebContents(web_contents); 2039 SecurityStateTabHelper::FromWebContents(web_contents);
2033 ASSERT_TRUE(helper); 2040 ASSERT_TRUE(helper);
2034 security_state::SecurityInfo security_info; 2041 security_state::SecurityInfo security_info;
2035 helper->GetSecurityInfo(&security_info); 2042 helper->GetSecurityInfo(&security_info);
2036 EXPECT_EQ(security_state::SECURE, security_info.security_level); 2043 EXPECT_EQ(security_state::SECURE, security_info.security_level);
2037 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 2044 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
2038 } 2045 }
2039 2046
2040 } // namespace 2047 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698