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

Unified Diff: chrome/browser/ui/browser_browsertest.cc

Issue 1181293003: Expand SecurityStyleChanged interfaces to include explanations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments, style tweaks Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser_browsertest.cc
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 73ae3e2e1446401fadebc506a17095c46c4f383d..4add40085c94ef7f539ca22745e2f13c3d9b1655 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -92,6 +92,7 @@
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
+#include "net/base/net_errors.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "ui/base/l10n/l10n_util.h"
@@ -341,7 +342,8 @@ bool GetFilePathWithHostAndPortReplacement(
}
// A WebContentsObserver useful for testing the SecurityStyleChanged()
-// method: it keeps track of the latest security style that was fired.
+// method: it keeps track of the latest security style and explanation
+// that was fired.
class SecurityStyleTestObserver : public WebContentsObserver {
public:
explicit SecurityStyleTestObserver(content::WebContents* web_contents)
@@ -349,16 +351,25 @@ class SecurityStyleTestObserver : public WebContentsObserver {
latest_security_style_(content::SECURITY_STYLE_UNKNOWN) {}
~SecurityStyleTestObserver() override {}
- void SecurityStyleChanged(content::SecurityStyle security_style) override {
+ void SecurityStyleChanged(content::SecurityStyle security_style,
+ const content::SecurityStyleExplanation&
+ security_style_explanation) override {
latest_security_style_ = security_style;
+ latest_security_style_explanation_ = security_style_explanation;
}
content::SecurityStyle latest_security_style() const {
return latest_security_style_;
}
+ const content::SecurityStyleExplanation& latest_security_style_explanation()
Peter Kasting 2015/06/16 06:29:11 Nit: Prefer to break before the function name rath
estark 2015/06/16 15:32:35 Done.
+ const {
+ return latest_security_style_explanation_;
+ }
+
private:
content::SecurityStyle latest_security_style_;
+ content::SecurityStyleExplanation latest_security_style_explanation_;
DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver);
};
@@ -2858,6 +2869,15 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) {
ui_test_utils::NavigateToURL(browser(), mixed_content_url);
EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style());
+ const content::SecurityStyleExplanation& mixed_content_explanation =
+ observer.latest_security_style_explanation();
+ ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size());
+ EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT),
+ mixed_content_explanation.warning_explanations[0].summary);
+ EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION),
+ mixed_content_explanation.warning_explanations[0].description);
+ EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size());
+
// Visit a broken HTTPS url. Other conditions cannot be tested after
// this one because once the interstitial is clicked through, all URLs
// for this host will remain in a broken state.
@@ -2867,4 +2887,16 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) {
ProceedThroughInterstitial(web_contents);
EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
observer.latest_security_style());
+
+ const content::SecurityStyleExplanation& expired_explanation =
+ observer.latest_security_style_explanation();
+ EXPECT_EQ(0u, expired_explanation.warning_explanations.size());
+ ASSERT_EQ(1u, expired_explanation.broken_explanations.size());
+ EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
+ expired_explanation.broken_explanations[0].summary);
+ base::string16 error_string =
+ base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
+ EXPECT_EQ(l10n_util::GetStringFUTF8(
+ IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
+ expired_explanation.broken_explanations[0].description);
}

Powered by Google App Engine
This is Rietveld 408576698