Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: chrome/browser/errorpage_browsertest.cc

Issue 1516623002: Attempt to fix a renderer crash in NetErrorHelperCore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/renderer/net/net_error_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // should be two commits, as before. 729 // should be two commits, as before.
727 content::TestNavigationObserver nav_observer(web_contents, 2); 730 content::TestNavigationObserver nav_observer(web_contents, 2);
728 // Can't use content::ExecuteScript because it waits for scripts to send 731 // Can't use content::ExecuteScript because it waits for scripts to send
729 // notification that they've run, and scripts that trigger a navigation may 732 // notification that they've run, and scripts that trigger a navigation may
730 // not send that notification. 733 // not send that notification.
731 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( 734 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
732 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); 735 base::ASCIIToUTF16("document.getElementById('reload-button').click();"));
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 been two more requests to the correction service: One
737 // new error page, and one for tracking purposes. Have to make sure to wait 740 // for the new error page, and one for tracking purposes. Have to make sure
738 // for the tracking request, since the new error page does not depend on it. 741 // to wait for the tracking request, since the new error page does not depend
742 // on it.
739 link_doctor_interceptor()->WaitForRequests(3); 743 link_doctor_interceptor()->WaitForRequests(3);
740 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); 744 EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
741 } 745 }
746
747 // Test that the reload button on a DNS error page works after a same page
748 // navigation on the error page. Error pages don't seem to do this, but some
749 // traces indicate this may actually happen. This test may hang on regression.
750 IN_PROC_BROWSER_TEST_F(ErrorPageTest,
751 DNSError_DoReloadAfterSamePageNavigation) {
752 // The first navigation should fail, and the second one should be the error
753 // page.
754 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
755 browser(), GetDnsErrorURL(), 2);
756 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
757 EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
758
759 content::WebContents* web_contents =
760 browser()->tab_strip_model()->GetActiveWebContents();
761
762 // Do a same page navigation.
763 content::TestNavigationObserver nav_observer1(web_contents, 1);
764 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
765 base::ASCIIToUTF16("document.location='#';"));
766 // The same page navigation counts as a single navigation as far as the
767 // TestNavigationObserver is concerned.
768 nav_observer1.Wait();
769 // Page being displayed should not change.
770 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
771 // No new requests should have been issued.
772 EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
773
774 // Clicking the reload button should load the error page again, and there
775 // should be two commits, as before.
776 content::TestNavigationObserver nav_observer2(web_contents, 2);
777 // Can't use content::ExecuteScript because it waits for scripts to send
778 // notification that they've run, and scripts that trigger a navigation may
779 // not send that notification.
780 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
781 base::ASCIIToUTF16("document.getElementById('reload-button').click();"));
782 nav_observer2.Wait();
783 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
784
785 // There should have been two more requests to the correction service: One
786 // for the new error page, and one for tracking purposes. Have to make sure
787 // to wait for the tracking request, since the new error page does not depend
788 // on it.
789 link_doctor_interceptor()->WaitForRequests(3);
790 EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
791 }
742 792
743 // Test that clicking links on a DNS error page works. 793 // Test that clicking links on a DNS error page works.
744 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoClickLink) { 794 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoClickLink) {
745 // The first navigation should fail, and the second one should be the error 795 // The first navigation should fail, and the second one should be the error
746 // page. 796 // page.
747 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 797 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
748 browser(), GetDnsErrorURL(), 2); 798 browser(), GetDnsErrorURL(), 2);
749 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); 799 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
750 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); 800 EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
751 801
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 1106
1057 content::WebContents* web_contents = 1107 content::WebContents* web_contents =
1058 browser()->tab_strip_model()->GetActiveWebContents(); 1108 browser()->tab_strip_model()->GetActiveWebContents();
1059 content::TestNavigationObserver nav_observer(web_contents, 1); 1109 content::TestNavigationObserver nav_observer(web_contents, 1);
1060 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( 1110 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
1061 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); 1111 base::ASCIIToUTF16("document.getElementById('reload-button').click();"));
1062 nav_observer.Wait(); 1112 nav_observer.Wait();
1063 EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload")); 1113 EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload"));
1064 } 1114 }
1065 1115
1116 // Make sure that a same page navigation does not cause issues with the
1117 // auto-reload timer. Note that this test was added due to this case causing
1118 // a crash. On regression, this test may hang due to a crashed renderer.
1119 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSamePageNavigation) {
1120 GURL test_url("http://error.page.auto.reload");
1121 InstallInterceptor(test_url, 2);
1122
1123 // Wait for the error page and first autoreload, which happens immediately.
1124 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
1125 browser(), test_url, 2);
1126
1127 EXPECT_EQ(2, interceptor()->failures());
1128 EXPECT_EQ(2, interceptor()->requests());
1129
1130 content::WebContents* web_contents =
1131 browser()->tab_strip_model()->GetActiveWebContents();
1132 content::TestNavigationObserver observer(web_contents, 1);
1133 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
1134 base::ASCIIToUTF16("document.location='#';"));
1135 // The same page navigation counts as a navigation as far as the
1136 // TestNavigationObserver is concerned.
1137 observer.Wait();
1138
1139 // No new requests should have been issued.
1140 EXPECT_EQ(2, interceptor()->failures());
1141 EXPECT_EQ(2, interceptor()->requests());
1142
1143 // Wait for the second auto reload, which succeeds.
1144 content::TestNavigationObserver observer2(web_contents, 1);
1145 observer2.Wait();
1146
1147 EXPECT_EQ(2, interceptor()->failures());
1148 EXPECT_EQ(3, interceptor()->requests());
1149 }
1150
1066 // Interceptor that fails all requests with net::ERR_ADDRESS_UNREACHABLE. 1151 // Interceptor that fails all requests with net::ERR_ADDRESS_UNREACHABLE.
1067 class AddressUnreachableInterceptor : public net::URLRequestInterceptor { 1152 class AddressUnreachableInterceptor : public net::URLRequestInterceptor {
1068 public: 1153 public:
1069 AddressUnreachableInterceptor() {} 1154 AddressUnreachableInterceptor() {}
1070 ~AddressUnreachableInterceptor() override {} 1155 ~AddressUnreachableInterceptor() override {}
1071 1156
1072 // net::URLRequestInterceptor: 1157 // net::URLRequestInterceptor:
1073 net::URLRequestJob* MaybeInterceptRequest( 1158 net::URLRequestJob* MaybeInterceptRequest(
1074 net::URLRequest* request, 1159 net::URLRequest* request,
1075 net::NetworkDelegate* network_delegate) const override { 1160 net::NetworkDelegate* network_delegate) const override {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 ui_test_utils::NavigateToURL( 1471 ui_test_utils::NavigateToURL(
1387 browser(), 1472 browser(),
1388 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1473 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1389 kHostname)); 1474 kHostname));
1390 1475
1391 ToggleHelpBox(browser()); 1476 ToggleHelpBox(browser());
1392 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1477 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode));
1393 } 1478 }
1394 1479
1395 } // namespace 1480 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/net/net_error_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698