Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
|
mmenke
2017/06/05 18:31:34
--(c)
satorux1
2017/06/06 08:52:37
done - but this file is gone.
| |
| 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/net/errorpage_test_util.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/browser.h" | |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 9 #include "content/public/browser/web_contents.h" | |
| 10 #include "content/public/test/browser_test_utils.h" | |
| 11 #include "net/base/net_errors.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace errorpage_test_util { | |
| 15 | |
| 16 bool IsDisplayingText(Browser* browser, const std::string& text) { | |
| 17 // clang-format off | |
| 18 std::string command = base::StringPrintf(R"( | |
| 19 function isNodeVisible(node) { | |
| 20 if (!node || node.classList.contains('hidden')) | |
| 21 return false; | |
| 22 if (!node.parentElement) | |
| 23 return true; | |
| 24 // Otherwise, we must check all parent nodes | |
| 25 return isNodeVisible(node.parentElement); | |
| 26 } | |
| 27 var node = document.evaluate("//*[contains(text(),'%s')]", document, | |
| 28 null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| 29 domAutomationController.send(isNodeVisible(node)); | |
| 30 )", text.c_str()); | |
| 31 // clang-format on | |
| 32 bool result = false; | |
| 33 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 34 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); | |
| 35 return result; | |
| 36 } | |
| 37 | |
| 38 } // namespace errorpage_test_util | |
| OLD | NEW |