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

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

Issue 1639953002: Network error interstitial update - add suggestions list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
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 <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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)); 128 EXPECT_TRUE(IsDisplayingNetError(browser, error_code));
129 129
130 // 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.
131 ToggleHelpBox(browser); 131 ToggleHelpBox(browser);
mmenke 2016/02/18 19:51:18 Not needed any more, since the next function doesn
edwardjung 2016/02/19 18:18:21 Done.
132 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://mock.http/title2.html"));
135 EXPECT_FALSE(IsDisplayingText(browser, "http://correction2/"));
136 135
137 // Locally generated error pages should not have a populated search box. 136 // Locally generated error pages should not have a link with search terms.
138 bool search_box_populated = false; 137 EXPECT_FALSE(IsDisplayingText(browser, "search query"));
139 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
140 browser->tab_strip_model()->GetActiveWebContents(),
141 "var searchText = document.getElementById('search-box').value;"
142 "domAutomationController.send(searchText == 'search query');",
143 &search_box_populated));
144 EXPECT_FALSE(search_box_populated);
145 } 138 }
146 139
147 // Checks that an error page with information retrieved from the navigation 140 // Checks that an error page with information retrieved from the navigation
148 // correction service is being displayed, with the specified specified error 141 // correction service is being displayed, with the specified specified error
149 // code. 142 // code.
150 void ExpectDisplayingNavigationCorrections(Browser* browser, 143 void ExpectDisplayingNavigationCorrections(Browser* browser,
151 net::Error error_code) { 144 net::Error error_code) {
152 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); 145 EXPECT_TRUE(IsDisplayingNetError(browser, error_code));
153 146
154 // Expand the help box so innerText will include text below the fold. 147 // Check that the mock navigation corrections are displayed.
155 ToggleHelpBox(browser); 148 EXPECT_TRUE(IsDisplayingText(browser, "http://mock.http/title2.html"));
156 149
157 // Check that the mock navigation corrections are displayed. 150 // Check that the search terms are displayed as a link.
158 EXPECT_TRUE(IsDisplayingText(browser, "http://correction1/")); 151 EXPECT_TRUE(IsDisplayingText(browser, "search query"));
159 EXPECT_TRUE(IsDisplayingText(browser, "http://correction2/"));
160
161 // Check that the search box is populated correctly.
162 bool search_box_populated = false;
163 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
164 browser->tab_strip_model()->GetActiveWebContents(),
165 "var searchText = document.getElementById('search-box').value;"
166 "domAutomationController.send(searchText == 'search query');",
167 &search_box_populated));
168 EXPECT_TRUE(search_box_populated);
169 152
170 // The diagnostics button isn't displayed when corrections were 153 // The diagnostics button isn't displayed when corrections were
171 // retrieved from a remote server. 154 // retrieved from a remote server.
172 EXPECT_FALSE(IsDisplayingDiagnosticsButton(browser)); 155 EXPECT_FALSE(IsDisplayingDiagnosticsButton(browser));
173
174 // Close help box again, to return page to original state.
175 ToggleHelpBox(browser);
176 } 156 }
177 157
178 std::string GetShowSavedButtonLabel() { 158 std::string GetShowSavedButtonLabel() {
179 return l10n_util::GetStringUTF8(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY); 159 return l10n_util::GetStringUTF8(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY);
180 } 160 }
181 161
182 void AddInterceptorForURL( 162 void AddInterceptorForURL(
183 const GURL& url, 163 const GURL& url,
184 scoped_ptr<net::URLRequestInterceptor> handler) { 164 scoped_ptr<net::URLRequestInterceptor> handler) {
185 DCHECK_CURRENTLY_ON(BrowserThread::IO); 165 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 GoBackAndWaitForTitle("Title Of More Awesomeness", 1); 646 GoBackAndWaitForTitle("Title Of More Awesomeness", 1);
667 647
668 GoForwardAndWaitForNavigations(2); 648 GoForwardAndWaitForNavigations(2);
669 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); 649 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
670 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); 650 EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
671 651
672 GoForwardAndWaitForTitle("Title Of Awesomeness", 1); 652 GoForwardAndWaitForTitle("Title Of Awesomeness", 1);
673 EXPECT_EQ(3, link_doctor_interceptor()->num_requests()); 653 EXPECT_EQ(3, link_doctor_interceptor()->num_requests());
674 } 654 }
675 655
676 // Test that the search button on a DNS error page works. 656 // Test that the search link on a DNS error page works.
677 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoSearch) { 657 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_DoSearch) {
678 // The first navigation should fail, and the second one should be the error 658 // The first navigation should fail, and the second one should be the error
679 // page. 659 // page.
680 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 660 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
681 browser(), GetDnsErrorURL(), 2); 661 browser(), GetDnsErrorURL(), 2);
682 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED); 662 ExpectDisplayingNavigationCorrections(browser(), net::ERR_NAME_NOT_RESOLVED);
683 EXPECT_EQ(1, link_doctor_interceptor()->num_requests()); 663 EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
684 664
685 content::WebContents* web_contents = 665 content::WebContents* web_contents =
686 browser()->tab_strip_model()->GetActiveWebContents(); 666 browser()->tab_strip_model()->GetActiveWebContents();
687 667
688 // Do a search and make sure the browser ends up at the right page. 668 // Do a search and make sure the browser ends up at the right page.
689 content::TestNavigationObserver nav_observer(web_contents, 1); 669 content::TestNavigationObserver nav_observer(web_contents, 1);
690 content::TitleWatcher title_watcher( 670 content::TitleWatcher title_watcher(
691 web_contents, 671 web_contents,
692 base::ASCIIToUTF16("Title Of More Awesomeness")); 672 base::ASCIIToUTF16("Title Of More Awesomeness"));
693 // Can't use content::ExecuteScript because it waits for scripts to send 673 // Can't use content::ExecuteScript because it waits for scripts to send
694 // notification that they've run, and scripts that trigger a navigation may 674 // notification that they've run, and scripts that trigger a navigation may
695 // not send that notification. 675 // not send that notification.
696 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( 676 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
697 base::ASCIIToUTF16("document.getElementById('search-button').click();")); 677 base::ASCIIToUTF16("document.getElementById('search-link').click();"));
698 nav_observer.Wait(); 678 nav_observer.Wait();
699 EXPECT_EQ(base::ASCIIToUTF16("Title Of More Awesomeness"), 679 EXPECT_EQ(base::ASCIIToUTF16("Title Of More Awesomeness"),
700 title_watcher.WaitAndGetTitle()); 680 title_watcher.WaitAndGetTitle());
701 681
702 // There should have been another Link Doctor request, for tracking purposes. 682 // There should have been another Link Doctor request, for tracking purposes.
703 // Have to wait for it, since the search page does not depend on having 683 // Have to wait for it, since the search page does not depend on having
704 // sent the tracking request. 684 // sent the tracking request.
705 link_doctor_interceptor()->WaitForRequests(2); 685 link_doctor_interceptor()->WaitForRequests(2);
706 EXPECT_EQ(2, link_doctor_interceptor()->num_requests()); 686 EXPECT_EQ(2, link_doctor_interceptor()->num_requests());
707 687
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { 1460 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) {
1481 // ERR_UNSAFE_PORT will not trigger navigation corrections. 1461 // ERR_UNSAFE_PORT will not trigger navigation corrections.
1482 ui_test_utils::NavigateToURL( 1462 ui_test_utils::NavigateToURL(
1483 browser(), 1463 browser(),
1484 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1464 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1485 kHostname)); 1465 kHostname));
1486 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1466 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode));
1487 } 1467 }
1488 1468
1489 } // namespace 1469 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/resources/neterror.css » ('j') | components/error_page/common/localized_error.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698