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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/renderer/net/net_error_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/errorpage_browsertest.cc
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index 763d5f9d1b72210e3afd4ffa5b0cab5de330fec7..08005f89b84ef5c6e443fff23392b95e5de4deac 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -164,6 +164,9 @@ void ExpectDisplayingNavigationCorrections(Browser* browser,
// The diagnostics button isn't displayed when corrections were
// retrieved from a remote server.
EXPECT_FALSE(IsDisplayingDiagnosticsButton(browser));
+
+ // Close help box again, to return page to original state.
+ ToggleHelpBox(browser);
}
std::string GetShowSavedButtonLabel() {
@@ -733,9 +736,56 @@ IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoReload) {
nav_observer.Wait();
ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
- // There should have two more requests to the correction service: One for the
- // new error page, and one for tracking purposes. Have to make sure to wait
- // for the tracking request, since the new error page does not depend on it.
+ // There should have been two more requests to the correction service: One
+ // for the new error page, and one for tracking purposes. Have to make sure
+ // to wait for the tracking request, since the new error page does not depend
+ // on it.
+ link_doctor_interceptor()->WaitForRequests(3);
+ EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
+}
+
+// Test that the reload button on a DNS error page works after a same page
+// navigation on the error page. Error pages don't seem to do this, but some
+// traces indicate this may actually happen. This test may hang on regression.
+IN_PROC_BROWSER_TEST_F(ErrorPageTest,
+ DNSError_DoReloadAfterSamePageNavigation) {
+ // The first navigation should fail, and the second one should be the error
+ // page.
+ ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
+ browser(), GetDnsErrorURL(), 2);
+ ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
+ EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ // Do a same page navigation.
+ content::TestNavigationObserver nav_observer1(web_contents, 1);
+ web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
+ base::ASCIIToUTF16("document.location='#';"));
+ // The same page navigation counts as a single navigation as far as the
+ // TestNavigationObserver is concerned.
+ nav_observer1.Wait();
+ // Page being displayed should not change.
+ ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
+ // No new requests should have been issued.
+ EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
+
+ // Clicking the reload button should load the error page again, and there
+ // should be two commits, as before.
+ content::TestNavigationObserver nav_observer2(web_contents, 2);
+ // Can't use content::ExecuteScript because it waits for scripts to send
+ // notification that they've run, and scripts that trigger a navigation may
+ // not send that notification.
+ web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
+ base::ASCIIToUTF16("document.getElementById('reload-button').click();"));
+ nav_observer2.Wait();
+ ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
+
+ // There should have been two more requests to the correction service: One
+ // for the new error page, and one for tracking purposes. Have to make sure
+ // to wait for the tracking request, since the new error page does not depend
+ // on it.
link_doctor_interceptor()->WaitForRequests(3);
EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
}
@@ -1063,6 +1113,41 @@ IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, ManualReloadNotSuppressed) {
EXPECT_FALSE(IsDisplayingText(browser(), "error.page.auto.reload"));
}
+// Make sure that a same page navigation does not cause issues with the
+// auto-reload timer. Note that this test was added due to this case causing
+// a crash. On regression, this test may hang due to a crashed renderer.
+IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSamePageNavigation) {
+ GURL test_url("http://error.page.auto.reload");
+ InstallInterceptor(test_url, 2);
+
+ // Wait for the error page and first autoreload, which happens immediately.
+ ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
+ browser(), test_url, 2);
+
+ EXPECT_EQ(2, interceptor()->failures());
+ EXPECT_EQ(2, interceptor()->requests());
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ content::TestNavigationObserver observer(web_contents, 1);
+ web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
+ base::ASCIIToUTF16("document.location='#';"));
+ // The same page navigation counts as a navigation as far as the
+ // TestNavigationObserver is concerned.
+ observer.Wait();
+
+ // No new requests should have been issued.
+ EXPECT_EQ(2, interceptor()->failures());
+ EXPECT_EQ(2, interceptor()->requests());
+
+ // Wait for the second auto reload, which succeeds.
+ content::TestNavigationObserver observer2(web_contents, 1);
+ observer2.Wait();
+
+ EXPECT_EQ(2, interceptor()->failures());
+ EXPECT_EQ(3, interceptor()->requests());
+}
+
// Interceptor that fails all requests with net::ERR_ADDRESS_UNREACHABLE.
class AddressUnreachableInterceptor : public net::URLRequestInterceptor {
public:
« 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