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

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

Issue 1000333003: Properly decode IDN in interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move test commands to negative values, and control flow nit Created 5 years, 9 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/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 ec7402c4aab6ec90f242dfee36ab86105715f7cd..00bc1a9daaef36c43c000fb8a0ce58f559803345 100644
--- a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
+++ b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/prefs/pref_service.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -23,6 +24,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+using chrome_browser_interstitials::IsInterstitialDisplayingText;
+using chrome_browser_interstitials::SecurityInterstitialIDNTest;
+
namespace {
// Partial text in the captive portal interstitial's main paragraph when the
// login domain isn't displayed.
@@ -30,23 +34,6 @@ 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,
- const std::string& text) {
- // It's valid for |text| to contain "\'", but simply look for "'" instead
- // since this function is used for searching host names and a predefined
- // string.
- DCHECK(text.find("\'") == std::string::npos);
- std::string command = base::StringPrintf(
- "var hasText = document.body.textContent.indexOf('%s') >= 0;"
- "window.domAutomationController.send(hasText ? 1 : 0);",
- text.c_str());
- int result = 0;
- EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
- interstitial->GetMainFrame(), command, &result));
- return result == 1;
-}
-
enum ExpectWiFi {
EXPECT_WIFI_NO,
EXPECT_WIFI_YES
@@ -220,29 +207,25 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
EXPECT_WIFI_YES, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_NO);
}
-class CaptivePortalBlockingPageIDNTest : public CaptivePortalBlockingPageTest {
-public:
- // InProcessBrowserTest:
- void SetUpOnMainThread() override {
- // Clear AcceptLanguages to force punycode decoding.
- browser()->profile()->GetPrefs()->SetString(prefs::kAcceptLanguages,
- std::string());
+class CaptivePortalBlockingPageIDNTest : public SecurityInterstitialIDNTest {
+ protected:
+ // SecurityInterstitialIDNTest implementation
+ SecurityInterstitialPage* CreateInterstitial(
+ content::WebContents* contents,
+ const GURL& request_url) const override {
+ // Delegate is owned by the blocking page.
+ FakeConnectionInfoDelegate* delegate =
+ new FakeConnectionInfoDelegate(false, "");
+ // Blocking page is owned by the interstitial.
+ CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
+ contents, GURL(kBrokenSSL), request_url, base::Callback<void(bool)>());
+ blocking_page->SetDelegateForTesting(delegate);
+ return blocking_page;
}
};
-// Same as CaptivePortalBlockingPageTest.WiredNetwork_LoginURL, except the login
-// domain is an IDN.
+// Test that an IDN login domain is decoded properly.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest,
ShowLoginIDNIfPortalRedirectsDetectionURL) {
- const char kHostname[] =
- "xn--d1abbgf6aiiy.xn--p1ai";
- const char kHostnameJSUnicode[] =
- "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442."
- "\\u0440\\u0444";
- std::string landing_url_spec =
- base::StringPrintf("http://%s/landing_url", kHostname);
- GURL landing_url(landing_url_spec);
-
- TestInterstitial(false, "", landing_url, EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO,
- EXPECT_LOGIN_URL_YES, kHostnameJSUnicode);
+ EXPECT_TRUE(VerifyIDNDecoded());
}
« no previous file with comments | « chrome/browser/interstitials/security_interstitial_page_test_utils.cc ('k') | chrome/browser/ssl/ssl_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698