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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 157 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 158 browser->tab_strip_model()->GetActiveWebContents(), | 158 browser->tab_strip_model()->GetActiveWebContents(), |
| 159 "var searchText = document.getElementById('search-box').value;" | 159 "var searchText = document.getElementById('search-box').value;" |
| 160 "domAutomationController.send(searchText == 'search query');", | 160 "domAutomationController.send(searchText == 'search query');", |
| 161 &search_box_populated)); | 161 &search_box_populated)); |
| 162 EXPECT_TRUE(search_box_populated); | 162 EXPECT_TRUE(search_box_populated); |
| 163 | 163 |
| 164 // The diagnostics button isn't displayed when corrections were | 164 // The diagnostics button isn't displayed when corrections were |
| 165 // retrieved from a remote server. | 165 // retrieved from a remote server. |
| 166 EXPECT_FALSE(IsDisplayingDiagnosticsButton(browser)); | 166 EXPECT_FALSE(IsDisplayingDiagnosticsButton(browser)); |
| 167 | |
| 168 // Close help box again, to return page to original state. | |
| 169 ToggleHelpBox(browser); | |
| 167 } | 170 } |
| 168 | 171 |
| 169 std::string GetShowSavedButtonLabel() { | 172 std::string GetShowSavedButtonLabel() { |
| 170 return l10n_util::GetStringUTF8(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY); | 173 return l10n_util::GetStringUTF8(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY); |
| 171 } | 174 } |
| 172 | 175 |
| 173 void AddInterceptorForURL( | 176 void AddInterceptorForURL( |
| 174 const GURL& url, | 177 const GURL& url, |
| 175 scoped_ptr<net::URLRequestInterceptor> handler) { | 178 scoped_ptr<net::URLRequestInterceptor> handler) { |
| 176 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 179 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 nav_observer.Wait(); | 736 nav_observer.Wait(); |
| 734 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); | 737 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); |
| 735 | 738 |
| 736 // There should have two more requests to the correction service: One for the | 739 // There should have two more requests to the correction service: One for the |
| 737 // new error page, and one for tracking purposes. Have to make sure to wait | 740 // new error page, and one for tracking purposes. Have to make sure to wait |
| 738 // for the tracking request, since the new error page does not depend on it. | 741 // for the tracking request, since the new error page does not depend on it. |
| 739 link_doctor_interceptor()->WaitForRequests(3); | 742 link_doctor_interceptor()->WaitForRequests(3); |
| 740 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); | 743 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); |
| 741 } | 744 } |
| 742 | 745 |
| 746 // Test that the reload button on a DNS error page works after a same page | |
| 747 // navigation on the error page. Error pages don't seem to do this, but some | |
| 748 // traces indicate this may actually happen. This test may hang on regression. | |
| 749 IN_PROC_BROWSER_TEST_F(ErrorPageTest, | |
| 750 DNSError_DoReloadAfterSamePageNavigation) { | |
| 751 // The first navigation should fail, and the second one should be the error | |
| 752 // page. | |
| 753 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | |
| 754 browser(), GetDnsErrorURL(), 2); | |
| 755 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); | |
| 756 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); | |
| 757 | |
| 758 content::WebContents* web_contents = | |
| 759 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 760 | |
| 761 // Do a same page navigation. | |
| 762 content::TestNavigationObserver nav_observer1(web_contents, 1); | |
| 763 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | |
| 764 base::ASCIIToUTF16("document.location='#';")); | |
| 765 // The same page navigation counts as a single navigation as far as the | |
| 766 // TestNavigationObserver is concerned. | |
| 767 nav_observer1.Wait(); | |
| 768 // Page being displayed should not change. | |
| 769 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); | |
| 770 // No new requests should have been issues. | |
|
Randy Smith (Not in Mondays)
2015/12/09 21:23:46
nit:issued.
mmenke
2015/12/10 15:52:23
Done.
| |
| 771 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); | |
| 772 | |
| 773 // Clicking the reload button should load the error page again, and there | |
| 774 // should be two commits, as before. | |
| 775 content::TestNavigationObserver nav_observer2(web_contents, 2); | |
| 776 // Can't use content::ExecuteScript because it waits for scripts to send | |
| 777 // notification that they've run, and scripts that trigger a navigation may | |
| 778 // not send that notification. | |
| 779 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | |
| 780 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); | |
| 781 nav_observer2.Wait(); | |
| 782 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); | |
| 783 | |
| 784 // There should have two more requests to the correction service: One for the | |
| 785 // new error page, and one for tracking purposes. Have to make sure to wait | |
| 786 // for the tracking request, since the new error page does not depend on it. | |
| 787 link_doctor_interceptor()->WaitForRequests(3); | |
| 788 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); | |
| 789 } | |
| 790 | |
| 743 // Test that clicking links on a DNS error page works. | 791 // Test that clicking links on a DNS error page works. |
| 744 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoClickLink) { | 792 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoClickLink) { |
| 745 // The first navigation should fail, and the second one should be the error | 793 // The first navigation should fail, and the second one should be the error |
| 746 // page. | 794 // page. |
| 747 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 795 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 748 browser(), GetDnsErrorURL(), 2); | 796 browser(), GetDnsErrorURL(), 2); |
| 749 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); | 797 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); |
| 750 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); | 798 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); |
| 751 | 799 |
| 752 content::WebContents* web_contents = | 800 content::WebContents* web_contents = |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1056 | 1104 |
| 1057 content::WebContents* web_contents = | 1105 content::WebContents* web_contents = |
| 1058 browser()->tab_strip_model()->GetActiveWebContents(); | 1106 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1059 content::TestNavigationObserver nav_observer(web_contents, 1); | 1107 content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1060 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | 1108 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 1061 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); | 1109 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); |
| 1062 nav_observer.Wait(); | 1110 nav_observer.Wait(); |
| 1063 EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload")); | 1111 EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload")); |
| 1064 } | 1112 } |
| 1065 | 1113 |
| 1114 // Make sure that a same page navigation does not cause issues with the | |
| 1115 // auto-reload timer. Note that this test was added due to this case causing | |
| 1116 // a crash. On regression, this test may hang due to a crashed renderer. | |
| 1117 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSamePageNavigation) { | |
|
mmenke
2015/12/09 20:18:33
I'm a big concerned that this may timeout on OSX o
| |
| 1118 GURL test_url("http://error.page.auto.reload"); | |
| 1119 InstallInterceptor(test_url, 2); | |
| 1120 | |
| 1121 // Wait for the error page and first autoreload, which happens immediately. | |
| 1122 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | |
| 1123 browser(), test_url, 2); | |
| 1124 | |
| 1125 EXPECT_EQ(2, interceptor()->failures()); | |
| 1126 EXPECT_EQ(2, interceptor()->requests()); | |
| 1127 | |
| 1128 content::WebContents* web_contents = | |
| 1129 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1130 content::TestNavigationObserver observer(web_contents, 1); | |
| 1131 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | |
| 1132 base::ASCIIToUTF16("document.location='#';")); | |
| 1133 // The same page navigation counts as a navigation as far as the | |
| 1134 // TestNavigationObserver is concerned. | |
| 1135 observer.Wait(); | |
| 1136 | |
| 1137 // No new requests should have been issued. | |
| 1138 EXPECT_EQ(2, interceptor()->failures()); | |
| 1139 EXPECT_EQ(2, interceptor()->requests()); | |
| 1140 | |
| 1141 // Wait for the second auto reload, which succeeds. | |
| 1142 content::TestNavigationObserver observer2(web_contents, 1); | |
| 1143 observer2.Wait(); | |
| 1144 | |
| 1145 EXPECT_EQ(2, interceptor()->failures()); | |
| 1146 EXPECT_EQ(3, interceptor()->requests()); | |
| 1147 } | |
| 1148 | |
| 1066 // Interceptor that fails all requests with net::ERR_ADDRESS_UNREACHABLE. | 1149 // Interceptor that fails all requests with net::ERR_ADDRESS_UNREACHABLE. |
| 1067 class AddressUnreachableInterceptor : public net::URLRequestInterceptor { | 1150 class AddressUnreachableInterceptor : public net::URLRequestInterceptor { |
| 1068 public: | 1151 public: |
| 1069 AddressUnreachableInterceptor() {} | 1152 AddressUnreachableInterceptor() {} |
| 1070 ~AddressUnreachableInterceptor() override {} | 1153 ~AddressUnreachableInterceptor() override {} |
| 1071 | 1154 |
| 1072 // net::URLRequestInterceptor: | 1155 // net::URLRequestInterceptor: |
| 1073 net::URLRequestJob* MaybeInterceptRequest( | 1156 net::URLRequestJob* MaybeInterceptRequest( |
| 1074 net::URLRequest* request, | 1157 net::URLRequest* request, |
| 1075 net::NetworkDelegate* network_delegate) const override { | 1158 net::NetworkDelegate* network_delegate) const override { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1386 ui_test_utils::NavigateToURL( | 1469 ui_test_utils::NavigateToURL( |
| 1387 browser(), | 1470 browser(), |
| 1388 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1471 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1389 kHostname)); | 1472 kHostname)); |
| 1390 | 1473 |
| 1391 ToggleHelpBox(browser()); | 1474 ToggleHelpBox(browser()); |
| 1392 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1475 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1393 } | 1476 } |
| 1394 | 1477 |
| 1395 } // namespace | 1478 } // namespace |
| OLD | NEW |