| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Returns true if |text| is displayed on the page |browser| is currently |
| 93 // displaying. Uses "innerText", so will miss hidden text, and whitespace | 93 // displaying. Uses "innerText", so will miss hidden text, and whitespace |
| 94 // space handling may be weird. | 94 // space handling may be weird. |
| 95 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser, | 95 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser, |
| 96 const std::string& text) { | 96 const std::string& text) { |
| 97 std::string command = base::StringPrintf( | 97 std::string command = base::StringPrintf( |
| 98 "var textContent = document.body.innerText;" | 98 "var textContent = document.body.innerText.toLowerCase();" |
| 99 "var hasText = textContent.indexOf('%s') >= 0;" | 99 "var hasText = textContent.indexOf('%s'.toLowerCase()) >= 0;" |
| 100 "domAutomationController.send(hasText);", | 100 "domAutomationController.send(hasText);", |
| 101 text.c_str()); | 101 text.c_str()); |
| 102 bool result = false; | 102 bool result = false; |
| 103 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 103 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 104 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); | 104 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); |
| 105 return result; | 105 return result; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Expands the more box on the currently displayed error page. | 108 // Expands the more box on the currently displayed error page. |
| 109 void ToggleHelpBox(Browser* browser) { | 109 void ToggleHelpBox(Browser* browser) { |
| (...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 Http09WeirdPortEnabled) { | 1533 Http09WeirdPortEnabled) { |
| 1534 const char kHttp09Response[] = "JumboShrimp"; | 1534 const char kHttp09Response[] = "JumboShrimp"; |
| 1535 ASSERT_TRUE(embedded_test_server()->Start()); | 1535 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1536 ui_test_utils::NavigateToURL( | 1536 ui_test_utils::NavigateToURL( |
| 1537 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + | 1537 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + |
| 1538 kHttp09Response)); | 1538 kHttp09Response)); |
| 1539 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); | 1539 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 } // namespace | 1542 } // namespace |
| OLD | NEW |