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

Unified Diff: chrome/browser/interstitials/security_interstitial_page_test_utils.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/interstitials/security_interstitial_page_test_utils.cc
diff --git a/chrome/browser/interstitials/security_interstitial_page_test_utils.cc b/chrome/browser/interstitials/security_interstitial_page_test_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e1a0b1f6749b53718ce92f63095beb58c91f6a4e
--- /dev/null
+++ b/chrome/browser/interstitials/security_interstitial_page_test_utils.cc
@@ -0,0 +1,32 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
+
+#include <string>
+
+#include "base/strings/stringprintf.h"
+#include "content/public/browser/interstitial_page.h"
+#include "content/public/test/browser_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chrome_browser_interstitials {
+
+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;
+}
+
+} // namespace chrome_browser_interstitials

Powered by Google App Engine
This is Rietveld 408576698