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

Side by Side 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: 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 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/captive_portal_blocking_page.h" 5 #include "chrome/browser/ssl/captive_portal_blocking_page.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
19 #include "components/captive_portal/captive_portal_detector.h" 20 #include "components/captive_portal/captive_portal_detector.h"
20 #include "content/public/browser/interstitial_page.h" 21 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
27 using chrome_browser_interstitials::IsInterstitialDisplayingText;
28
26 namespace { 29 namespace {
27 // Partial text in the captive portal interstitial's main paragraph when the 30 // Partial text in the captive portal interstitial's main paragraph when the
28 // login domain isn't displayed. 31 // login domain isn't displayed.
29 const char kGenericLoginURLText[] = "its login page"; 32 const char kGenericLoginURLText[] = "its login page";
30 const char kBrokenSSL[] = "https://broken.ssl"; 33 const char kBrokenSSL[] = "https://broken.ssl";
31 const char kWiFiSSID[] = "WiFiSSID"; 34 const char kWiFiSSID[] = "WiFiSSID";
32 35
33 // Returns true if the interstitial contains |text| in its body.
34 bool IsInterstitialDisplayingText(content::InterstitialPage* interstitial,
35 const std::string& text) {
36 // It's valid for |text| to contain "\'", but simply look for "'" instead
37 // since this function is used for searching host names and a predefined
38 // string.
39 DCHECK(text.find("\'") == std::string::npos);
40 std::string command = base::StringPrintf(
41 "var hasText = document.body.textContent.indexOf('%s') >= 0;"
42 "window.domAutomationController.send(hasText ? 1 : 0);",
43 text.c_str());
44 int result = 0;
45 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
46 interstitial->GetMainFrame(), command, &result));
47 return result == 1;
48 }
49
50 enum ExpectWiFi { 36 enum ExpectWiFi {
51 EXPECT_WIFI_NO, 37 EXPECT_WIFI_NO,
52 EXPECT_WIFI_YES 38 EXPECT_WIFI_YES
53 }; 39 };
54 40
55 enum ExpectWiFiSSID { 41 enum ExpectWiFiSSID {
56 EXPECT_WIFI_SSID_NO, 42 EXPECT_WIFI_SSID_NO,
57 EXPECT_WIFI_SSID_YES 43 EXPECT_WIFI_SSID_YES
58 }; 44 };
59 45
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const char kHostnameJSUnicode[] = 225 const char kHostnameJSUnicode[] =
240 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442." 226 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442."
241 "\\u0440\\u0444"; 227 "\\u0440\\u0444";
242 std::string landing_url_spec = 228 std::string landing_url_spec =
243 base::StringPrintf("http://%s/landing_url", kHostname); 229 base::StringPrintf("http://%s/landing_url", kHostname);
244 GURL landing_url(landing_url_spec); 230 GURL landing_url(landing_url_spec);
245 231
246 TestInterstitial(false, "", landing_url, EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, 232 TestInterstitial(false, "", landing_url, EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO,
247 EXPECT_LOGIN_URL_YES, kHostnameJSUnicode); 233 EXPECT_LOGIN_URL_YES, kHostnameJSUnicode);
248 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698