Chromium Code Reviews| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 "var textContent = document.body.innerText.toLowerCase();" | 98 "var textContent = document.body.innerText.toLowerCase();" |
| 99 "var hasText = textContent.indexOf('%s'.toLowerCase()) >= 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 // Returns true if #details is displayed on the page |browser| is currently | |
| 109 // displaying. | |
| 110 bool WARN_UNUSED_RESULT IsDisplayingDetails(Browser* browser) { | |
|
mmenke
2017/05/03 15:10:59
Could we instead make IsDiplayingText check if any
Nate Fischer
2017/05/03 17:54:43
In general, it seems rather difficult to get a nod
mmenke
2017/05/04 19:03:33
I don't suppose something like this would work:
v
| |
| 111 std::string command = R"( | |
| 112 var node = document.getElementById('details'); | |
| 113 var isVisible = !node.classList.contains('hidden'); | |
| 114 domAutomationController.send(isVisible); | |
| 115 )"; | |
| 116 bool result = false; | |
| 117 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 118 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); | |
| 119 return result; | |
| 120 } | |
| 121 | |
| 108 // Expands the more box on the currently displayed error page. | 122 // Expands the more box on the currently displayed error page. |
| 109 void ToggleHelpBox(Browser* browser) { | 123 void ToggleHelpBox(Browser* browser) { |
| 110 EXPECT_TRUE(content::ExecuteScript( | 124 EXPECT_TRUE(content::ExecuteScript( |
| 111 browser->tab_strip_model()->GetActiveWebContents(), | 125 browser->tab_strip_model()->GetActiveWebContents(), |
| 112 "document.getElementById('details-button').click();")); | 126 "document.getElementById('details-button').click();")); |
| 113 } | 127 } |
| 114 | 128 |
| 115 // Returns true if the diagnostics link suggestion is displayed. | 129 // Returns true if the diagnostics link suggestion is displayed. |
| 116 bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) { | 130 bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) { |
| 117 std::string command = base::StringPrintf( | 131 std::string command = base::StringPrintf( |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1116 GURL test_url("http://error.page.auto.reload"); | 1130 GURL test_url("http://error.page.auto.reload"); |
| 1117 const int kRequestsToFail = 3; | 1131 const int kRequestsToFail = 3; |
| 1118 InstallInterceptor(test_url, kRequestsToFail); | 1132 InstallInterceptor(test_url, kRequestsToFail); |
| 1119 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 1133 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 1120 browser(), test_url, 2); | 1134 browser(), test_url, 2); |
| 1121 | 1135 |
| 1122 EXPECT_EQ(2, interceptor()->failures()); | 1136 EXPECT_EQ(2, interceptor()->failures()); |
| 1123 EXPECT_EQ(2, interceptor()->requests()); | 1137 EXPECT_EQ(2, interceptor()->requests()); |
| 1124 | 1138 |
| 1125 ToggleHelpBox(browser()); | 1139 ToggleHelpBox(browser()); |
| 1126 EXPECT_TRUE(IsDisplayingText(browser(), l10n_util::GetStringUTF8( | 1140 EXPECT_TRUE( |
| 1127 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); | 1141 IsDisplayingText( |
| 1142 browser(), l10n_util::GetStringUTF8( | |
| 1143 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER)) && | |
| 1144 IsDisplayingDetails(browser())); | |
| 1128 | 1145 |
| 1129 content::WebContents* web_contents = | 1146 content::WebContents* web_contents = |
| 1130 browser()->tab_strip_model()->GetActiveWebContents(); | 1147 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1131 content::TestNavigationObserver nav_observer(web_contents, 1); | 1148 content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1132 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | 1149 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 1133 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); | 1150 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); |
| 1134 nav_observer.Wait(); | 1151 nav_observer.Wait(); |
| 1135 EXPECT_FALSE(IsDisplayingText(browser(), l10n_util::GetStringUTF8( | 1152 EXPECT_FALSE( |
| 1136 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); | 1153 IsDisplayingText( |
| 1154 browser(), l10n_util::GetStringUTF8( | |
| 1155 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER)) && | |
| 1156 IsDisplayingDetails(browser())); | |
| 1137 } | 1157 } |
| 1138 | 1158 |
| 1139 // Make sure that a same document navigation does not cause issues with the | 1159 // Make sure that a same document navigation does not cause issues with the |
| 1140 // auto-reload timer. Note that this test was added due to this case causing | 1160 // auto-reload timer. Note that this test was added due to this case causing |
| 1141 // a crash. On regression, this test may hang due to a crashed renderer. | 1161 // a crash. On regression, this test may hang due to a crashed renderer. |
| 1142 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSameDocumentNavigation) { | 1162 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSameDocumentNavigation) { |
| 1143 GURL test_url("http://error.page.auto.reload"); | 1163 GURL test_url("http://error.page.auto.reload"); |
| 1144 InstallInterceptor(test_url, 2); | 1164 InstallInterceptor(test_url, 2); |
| 1145 | 1165 |
| 1146 // Wait for the error page and first autoreload, which happens immediately. | 1166 // Wait for the error page and first autoreload, which happens immediately. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1533 Http09WeirdPortEnabled) { | 1553 Http09WeirdPortEnabled) { |
| 1534 const char kHttp09Response[] = "JumboShrimp"; | 1554 const char kHttp09Response[] = "JumboShrimp"; |
| 1535 ASSERT_TRUE(embedded_test_server()->Start()); | 1555 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1536 ui_test_utils::NavigateToURL( | 1556 ui_test_utils::NavigateToURL( |
| 1537 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + | 1557 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + |
| 1538 kHttp09Response)); | 1558 kHttp09Response)); |
| 1539 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); | 1559 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); |
| 1540 } | 1560 } |
| 1541 | 1561 |
| 1542 } // namespace | 1562 } // namespace |
| OLD | NEW |