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

Unified Diff: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc

Issue 887573002: Add Wi-Fi SSID to captive portal interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: felt comments Created 5 years, 11 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
« no previous file with comments | « chrome/browser/ssl/captive_portal_blocking_page.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
diff --git a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
index 73de3c8843e4f1438e9b024c3a7bef841ece6c12..857d469ab9015cc94a465a259ca2bb5d4749f8c8 100644
--- a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
+++ b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
@@ -23,10 +23,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+namespace {
// Partial text in the captive portal interstitial's main paragraph when the
// login domain isn't displayed.
const char kGenericLoginURLText[] = "its login page";
const char kBrokenSSL[] = "https://broken.ssl";
+const char kWiFiSSID[] = "WiFiSSID";
// Returns true if the interstitial contains |text| in its body.
bool IsInterstitialDisplayingText(content::InterstitialPage* interstitial,
@@ -45,107 +47,146 @@ bool IsInterstitialDisplayingText(content::InterstitialPage* interstitial,
return result;
}
+enum ExpectWiFi {
+ EXPECT_WIFI_NO,
+ EXPECT_WIFI_YES
+};
+
+enum ExpectWiFiSSID {
+ EXPECT_WIFI_SSID_NO,
+ EXPECT_WIFI_SSID_YES
+};
+
+enum ExpectLoginURL {
+ EXPECT_LOGIN_URL_NO,
+ EXPECT_LOGIN_URL_YES
+};
+
+} // namespace
+
class CaptivePortalBlockingPageTest : public InProcessBrowserTest {
public:
CaptivePortalBlockingPageTest() {}
+ void TestInterstitial(bool is_wifi_connection,
+ const std::string& wifi_ssid,
+ const GURL& login_url,
+ ExpectWiFi expect_wifi,
+ ExpectWiFiSSID expect_wifi_ssid,
+ ExpectLoginURL expect_login_url,
+ const std::string& expected_login_hostname);
+
+ void TestInterstitial(bool is_wifi_connection,
+ const std::string& wifi_ssid,
+ const GURL& login_url,
+ ExpectWiFi expect_wifi,
+ ExpectWiFiSSID expect_wifi_ssid,
+ ExpectLoginURL expect_login_url);
+
private:
DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPageTest);
};
-// If the connection is not a Wi-Fi connection, the wired network version of the
-// captive portal interstitial should be displayed.
-IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
- ShowWiredNetworkInterstitial) {
- const GURL kLandingUrl("http://captive.portal/landing_url");
+void CaptivePortalBlockingPageTest::TestInterstitial(
+ bool is_wifi_connection,
+ const std::string& wifi_ssid,
+ const GURL& login_url,
+ ExpectWiFi expect_wifi,
+ ExpectWiFiSSID expect_wifi_ssid,
+ ExpectLoginURL expect_login_url,
+ const std::string& expected_login_hostname) {
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
DCHECK(contents);
// Blocking page is owned by the interstitial.
CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
- contents, GURL(kBrokenSSL), kLandingUrl, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(false);
+ contents, GURL(kBrokenSSL), login_url, base::Callback<void(bool)>());
+ blocking_page->SetWiFiConnectionForTesting(is_wifi_connection);
+ blocking_page->SetWiFiSSIDForTesting(wifi_ssid);
blocking_page->Show();
WaitForInterstitialAttach(contents);
EXPECT_TRUE(
WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame()));
- EXPECT_FALSE(
- IsInterstitialDisplayingText(contents->GetInterstitialPage(), "Wi-Fi"));
+ EXPECT_EQ(expect_wifi == EXPECT_WIFI_YES,
+ IsInterstitialDisplayingText(contents->GetInterstitialPage(),
+ "Wi-Fi"));
+ if (!wifi_ssid.empty()) {
+ EXPECT_EQ(expect_wifi_ssid == EXPECT_WIFI_SSID_YES,
+ IsInterstitialDisplayingText(contents->GetInterstitialPage(),
+ wifi_ssid));
+ }
+ EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_YES,
+ IsInterstitialDisplayingText(contents->GetInterstitialPage(),
+ expected_login_hostname));
+ EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_NO,
+ IsInterstitialDisplayingText(contents->GetInterstitialPage(),
+ kGenericLoginURLText));
}
-// If the connection is a Wi-Fi connection, the Wi-Fi version of the captive
-// portal interstitial should be displayed.
+void CaptivePortalBlockingPageTest::TestInterstitial(
+ bool is_wifi_connection,
+ const std::string& wifi_ssid,
+ const GURL& login_url,
+ ExpectWiFi expect_wifi,
+ ExpectWiFiSSID expect_wifi_ssid,
+ ExpectLoginURL expect_login_url) {
+ TestInterstitial(is_wifi_connection, wifi_ssid, login_url,
+ expect_wifi, expect_wifi_ssid, expect_login_url,
+ login_url.host());
+}
+
+// If the connection is not a Wi-Fi connection, the wired network version of the
+// captive portal interstitial should be displayed.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
- ShowWiFiInterstitial) {
- const GURL kLandingUrl("http://captive.portal/landing_url");
- content::WebContents* contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- DCHECK(contents);
- // Blocking page is owned by the interstitial.
- CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
- contents, GURL(kBrokenSSL), kLandingUrl, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(true);
- blocking_page->Show();
+ WiredNetwork_LoginURL) {
+ TestInterstitial(false, kWiFiSSID, GURL("http://captive.portal/landing_url"),
+ EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_YES);
- WaitForInterstitialAttach(contents);
- EXPECT_TRUE(
- WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame()));
- EXPECT_TRUE(
- IsInterstitialDisplayingText(contents->GetInterstitialPage(), "Wi-Fi"));
}
-// The captive portal interstitial should show the login url if the login url
-// is different than the captive portal ping url (i.e. the portal intercepts
-// requests via HTTP redirects).
+// Same as above, expect the login URL is the same as the captive portal ping
+// url (i.e. the portal intercepts requests without using HTTP redirects), in
+// which case the login URL shouldn't be displayed.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
- ShowLoginDomainIfPortalRedirectsDetectionURL) {
- const GURL kLandingUrl("http://captive.portal/landing_url");
- content::WebContents* contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- DCHECK(contents);
- // Blocking page is owned by the interstitial.
- CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
- contents, GURL(kBrokenSSL), kLandingUrl, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(false);
- blocking_page->Show();
+ WiredNetwork_NoLoginURL) {
+ const GURL kLandingUrl(captive_portal::CaptivePortalDetector::kDefaultURL);
+ TestInterstitial(false, kWiFiSSID, kLandingUrl,
+ EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_NO);
+}
- WaitForInterstitialAttach(contents);
- EXPECT_TRUE(
- WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame()));
+// If the connection is a Wi-Fi connection, the Wi-Fi version of the captive
+// portal interstitial should be displayed.
+IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
+ WiFi_SSID_LoginURL) {
+ TestInterstitial(true, kWiFiSSID, GURL("http://captive.portal/landing_url"),
+ EXPECT_WIFI_YES, EXPECT_WIFI_SSID_YES, EXPECT_LOGIN_URL_YES);
+}
- EXPECT_TRUE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kLandingUrl.host()));
- EXPECT_FALSE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kGenericLoginURLText));
+// Same as above, with login URL but no SSID.
+IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
+ WiFi_NoSSID_LoginURL) {
+ TestInterstitial(true, "", GURL("http://captive.portal/landing_url"),
+ EXPECT_WIFI_YES, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_YES);
}
-// The captive portal interstitial should show a generic text if the login url
-// is the same as the captive portal ping url (i.e. the portal intercepts
-// requests without using HTTP redirects).
+// Same as above, with SSID but no login URL.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
- DontShowLoginDomainIfPortalDoesntRedirectDetectionURL) {
+ WiFi_SSID_NoLoginURL) {
const GURL kLandingUrl(captive_portal::CaptivePortalDetector::kDefaultURL);
- content::WebContents* contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- DCHECK(contents);
- // Blocking page is owned by the interstitial.
- CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
- contents, GURL(kBrokenSSL), kLandingUrl, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(false);
- blocking_page->Show();
-
- WaitForInterstitialAttach(contents);
- EXPECT_TRUE(
- WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame()));
+ TestInterstitial(true, kWiFiSSID, kLandingUrl,
+ EXPECT_WIFI_YES, EXPECT_WIFI_SSID_YES, EXPECT_LOGIN_URL_NO);
+}
- EXPECT_FALSE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kLandingUrl.host()));
- EXPECT_TRUE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kGenericLoginURLText));
+// Same as above, with no SSID and no login URL.
+IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
+ WiFi_NoSSID_NoLoginURL) {
+ const GURL kLandingUrl(captive_portal::CaptivePortalDetector::kDefaultURL);
+ TestInterstitial(true, "", kLandingUrl,
+ EXPECT_WIFI_YES, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_NO);
}
-class CaptivePortalBlockingPageIDNTest : public InProcessBrowserTest {
+class CaptivePortalBlockingPageIDNTest : public CaptivePortalBlockingPageTest {
public:
// InProcessBrowserTest:
void SetUpOnMainThread() override {
@@ -155,7 +196,7 @@ public:
}
};
-// Same as ShowLoginDomainIfPortalRedirectsDetectionURL, except the login
+// Same as CaptivePortalBlockingPageTest.WiredNetwork_LoginURL, except the login
// domain is an IDN.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest,
ShowLoginIDNIfPortalRedirectsDetectionURL) {
@@ -168,21 +209,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest,
base::StringPrintf("http://%s/landing_url", kHostname);
GURL landing_url(landing_url_spec);
- content::WebContents* contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- DCHECK(contents);
- // Blocking page is owned by the interstitial.
- CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
- contents, GURL(kBrokenSSL), landing_url, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(false);
- blocking_page->Show();
-
- WaitForInterstitialAttach(contents);
- EXPECT_TRUE(
- WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame()));
-
- EXPECT_TRUE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kHostnameJSUnicode));
- EXPECT_FALSE(IsInterstitialDisplayingText(contents->GetInterstitialPage(),
- kGenericLoginURLText));
+ TestInterstitial(false, kWiFiSSID, landing_url,
+ EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_YES,
+ kHostnameJSUnicode);
}
« no previous file with comments | « chrome/browser/ssl/captive_portal_blocking_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698