| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/public/browser/interstitial_page.h" |
| 11 #include "content/public/test/browser_test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace chrome_browser_interstitials { |
| 15 |
| 16 bool IsInterstitialDisplayingText(content::InterstitialPage* interstitial, |
| 17 const std::string& text) { |
| 18 // It's valid for |text| to contain "\'", but simply look for "'" instead |
| 19 // since this function is used for searching host names and a predefined |
| 20 // string. |
| 21 DCHECK(text.find("\'") == std::string::npos); |
| 22 std::string command = base::StringPrintf( |
| 23 "var hasText = document.body.textContent.indexOf('%s') >= 0;" |
| 24 "window.domAutomationController.send(hasText ? 1 : 0);", |
| 25 text.c_str()); |
| 26 int result = 0; |
| 27 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(interstitial->GetMainFrame(), |
| 28 command, &result)); |
| 29 return result == 1; |
| 30 } |
| 31 |
| 32 } // namespace chrome_browser_interstitials |
| OLD | NEW |