| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 "domAutomationController.send(diagnose_button.style.display != 'none');"); | 118 "domAutomationController.send(diagnose_button.style.display != 'none');"); |
| 119 bool result = false; | 119 bool result = false; |
| 120 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 120 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 121 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); | 121 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); |
| 122 return result; | 122 return result; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Checks that the local error page is being displayed, without remotely | 125 // Checks that the local error page is being displayed, without remotely |
| 126 // retrieved navigation corrections, and with the specified error code. | 126 // retrieved navigation corrections, and with the specified error code. |
| 127 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { | 127 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { |
| 128 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); |
| 129 |
| 128 // Expand the help box so innerText will include text below the fold. | 130 // Expand the help box so innerText will include text below the fold. |
| 129 ToggleHelpBox(browser); | 131 ToggleHelpBox(browser); |
| 130 | 132 |
| 131 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); | |
| 132 | |
| 133 // Locally generated error pages should not have navigation corrections. | 133 // Locally generated error pages should not have navigation corrections. |
| 134 EXPECT_FALSE(IsDisplayingText(browser, "http://correction1/")); | 134 EXPECT_FALSE(IsDisplayingText(browser, "http://correction1/")); |
| 135 EXPECT_FALSE(IsDisplayingText(browser, "http://correction2/")); | 135 EXPECT_FALSE(IsDisplayingText(browser, "http://correction2/")); |
| 136 | 136 |
| 137 // Locally generated error pages should not have a populated search box. | 137 // Locally generated error pages should not have a populated search box. |
| 138 bool search_box_populated = false; | 138 bool search_box_populated = false; |
| 139 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 139 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 140 browser->tab_strip_model()->GetActiveWebContents(), | 140 browser->tab_strip_model()->GetActiveWebContents(), |
| 141 "var searchText = document.getElementById('search-box').value;" | 141 "var searchText = document.getElementById('search-box').value;" |
| 142 "domAutomationController.send(searchText == 'search query');", | 142 "domAutomationController.send(searchText == 'search query');", |
| 143 &search_box_populated)); | 143 &search_box_populated)); |
| 144 EXPECT_FALSE(search_box_populated); | 144 EXPECT_FALSE(search_box_populated); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Checks that an error page with information retrieved from the navigation | 147 // Checks that an error page with information retrieved from the navigation |
| 148 // correction service is being displayed, with the specified specified error | 148 // correction service is being displayed, with the specified specified error |
| 149 // code. | 149 // code. |
| 150 void ExpectDisplayingNavigationCorrections(Browser* browser, | 150 void ExpectDisplayingNavigationCorrections(Browser* browser, |
| 151 net::Error error_code) { | 151 net::Error error_code) { |
| 152 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); |
| 153 |
| 152 // Expand the help box so innerText will include text below the fold. | 154 // Expand the help box so innerText will include text below the fold. |
| 153 ToggleHelpBox(browser); | 155 ToggleHelpBox(browser); |
| 154 | 156 |
| 155 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); | |
| 156 | |
| 157 // Check that the mock navigation corrections are displayed. | 157 // Check that the mock navigation corrections are displayed. |
| 158 EXPECT_TRUE(IsDisplayingText(browser, "http://correction1/")); | 158 EXPECT_TRUE(IsDisplayingText(browser, "http://correction1/")); |
| 159 EXPECT_TRUE(IsDisplayingText(browser, "http://correction2/")); | 159 EXPECT_TRUE(IsDisplayingText(browser, "http://correction2/")); |
| 160 | 160 |
| 161 // Check that the search box is populated correctly. | 161 // Check that the search box is populated correctly. |
| 162 bool search_box_populated = false; | 162 bool search_box_populated = false; |
| 163 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 163 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 164 browser->tab_strip_model()->GetActiveWebContents(), | 164 browser->tab_strip_model()->GetActiveWebContents(), |
| 165 "var searchText = document.getElementById('search-box').value;" | 165 "var searchText = document.getElementById('search-box').value;" |
| 166 "domAutomationController.send(searchText == 'search query');", | 166 "domAutomationController.send(searchText == 'search query');", |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 GURL test_url("http://error.page.auto.reload"); | 1103 GURL test_url("http://error.page.auto.reload"); |
| 1104 const int kRequestsToFail = 3; | 1104 const int kRequestsToFail = 3; |
| 1105 InstallInterceptor(test_url, kRequestsToFail); | 1105 InstallInterceptor(test_url, kRequestsToFail); |
| 1106 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 1106 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 1107 browser(), test_url, 2); | 1107 browser(), test_url, 2); |
| 1108 | 1108 |
| 1109 EXPECT_EQ(2, interceptor()->failures()); | 1109 EXPECT_EQ(2, interceptor()->failures()); |
| 1110 EXPECT_EQ(2, interceptor()->requests()); | 1110 EXPECT_EQ(2, interceptor()->requests()); |
| 1111 | 1111 |
| 1112 ToggleHelpBox(browser()); | 1112 ToggleHelpBox(browser()); |
| 1113 EXPECT_TRUE(IsDisplayingText(browser(), "error.page.auto.reload")); | 1113 EXPECT_TRUE(IsDisplayingText(browser(), l10n_util::GetStringUTF8( |
| 1114 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); |
| 1114 | 1115 |
| 1115 content::WebContents* web_contents = | 1116 content::WebContents* web_contents = |
| 1116 browser()->tab_strip_model()->GetActiveWebContents(); | 1117 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1117 content::TestNavigationObserver nav_observer(web_contents, 1); | 1118 content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1118 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | 1119 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 1119 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); | 1120 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); |
| 1120 nav_observer.Wait(); | 1121 nav_observer.Wait(); |
| 1121 EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload")); | 1122 EXPECT_FALSE(IsDisplayingText(browser(), l10n_util::GetStringUTF8( |
| 1123 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| 1124 // Make sure that a same page navigation does not cause issues with the | 1126 // Make sure that a same page navigation does not cause issues with the |
| 1125 // auto-reload timer. Note that this test was added due to this case causing | 1127 // auto-reload timer. Note that this test was added due to this case causing |
| 1126 // a crash. On regression, this test may hang due to a crashed renderer. | 1128 // a crash. On regression, this test may hang due to a crashed renderer. |
| 1127 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSamePageNavigation) { | 1129 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSamePageNavigation) { |
| 1128 GURL test_url("http://error.page.auto.reload"); | 1130 GURL test_url("http://error.page.auto.reload"); |
| 1129 InstallInterceptor(test_url, 2); | 1131 InstallInterceptor(test_url, 2); |
| 1130 | 1132 |
| 1131 // Wait for the error page and first autoreload, which happens immediately. | 1133 // Wait for the error page and first autoreload, which happens immediately. |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442." | 1476 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442." |
| 1475 "\\u0440\\u0444"; | 1477 "\\u0440\\u0444"; |
| 1476 | 1478 |
| 1477 // Make sure error page shows correct unicode for IDN. | 1479 // Make sure error page shows correct unicode for IDN. |
| 1478 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { | 1480 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { |
| 1479 // ERR_UNSAFE_PORT will not trigger navigation corrections. | 1481 // ERR_UNSAFE_PORT will not trigger navigation corrections. |
| 1480 ui_test_utils::NavigateToURL( | 1482 ui_test_utils::NavigateToURL( |
| 1481 browser(), | 1483 browser(), |
| 1482 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1484 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1483 kHostname)); | 1485 kHostname)); |
| 1484 | |
| 1485 ToggleHelpBox(browser()); | |
| 1486 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1486 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 } // namespace | 1489 } // namespace |
| OLD | NEW |