| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #endif | 82 #endif |
| 83 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 83 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 84 | 84 |
| 85 using content::BrowserThread; | 85 using content::BrowserThread; |
| 86 using content::NavigationController; | 86 using content::NavigationController; |
| 87 using net::URLRequestFailedJob; | 87 using net::URLRequestFailedJob; |
| 88 using net::URLRequestTestJob; | 88 using net::URLRequestTestJob; |
| 89 | 89 |
| 90 namespace { | 90 namespace { |
| 91 | 91 |
| 92 // Returns true if |text| is displayed on the page |browser| is currently | 92 // Searches for first node containing |text|, and if it finds one, searches |
| 93 // displaying. Uses "innerText", so will miss hidden text, and whitespace | 93 // through all ancestors seeing if any of them is of class "hidden". Since it |
| 94 // space handling may be weird. | 94 // relies on the hidden class used by network error pages, not suitable for |
| 95 // general use. |
| 95 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser, | 96 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser, |
| 96 const std::string& text) { | 97 const std::string& text) { |
| 97 // clang-format off | 98 // clang-format off |
| 98 std::string command = base::StringPrintf(R"( | 99 std::string command = base::StringPrintf(R"( |
| 99 function isNodeVisible(node) { | 100 function isNodeVisible(node) { |
| 100 if (!node || node.classList.contains('hidden')) | 101 if (!node || node.classList.contains('hidden')) |
| 101 return false; | 102 return false; |
| 102 if (!node.parentElement) | 103 if (!node.parentElement) |
| 103 return true; | 104 return true; |
| 104 // Otherwise, we must check all parent nodes | 105 // Otherwise, we must check all parent nodes |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 Http09WeirdPortEnabled) { | 1557 Http09WeirdPortEnabled) { |
| 1557 const char kHttp09Response[] = "JumboShrimp"; | 1558 const char kHttp09Response[] = "JumboShrimp"; |
| 1558 ASSERT_TRUE(embedded_test_server()->Start()); | 1559 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1559 ui_test_utils::NavigateToURL( | 1560 ui_test_utils::NavigateToURL( |
| 1560 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + | 1561 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + |
| 1561 kHttp09Response)); | 1562 kHttp09Response)); |
| 1562 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); | 1563 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); |
| 1563 } | 1564 } |
| 1564 | 1565 |
| 1565 } // namespace | 1566 } // namespace |
| OLD | NEW |