| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 browser->tab_strip_model()->GetActiveWebContents(), | 82 browser->tab_strip_model()->GetActiveWebContents(), |
| 83 "document.getElementById('more-less-button').click();")); | 83 "document.getElementById('more-less-button').click();")); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Returns true if |browser| is displaying the text representation of | 86 // Returns true if |browser| is displaying the text representation of |
| 87 // |error_code| on the current page. | 87 // |error_code| on the current page. |
| 88 bool WARN_UNUSED_RESULT IsDisplayingNetError(Browser* browser, | 88 bool WARN_UNUSED_RESULT IsDisplayingNetError(Browser* browser, |
| 89 net::Error error_code) { | 89 net::Error error_code) { |
| 90 // Get the error as a string, and remove the leading "net::", which is not | 90 // Get the error as a string, and remove the leading "net::", which is not |
| 91 // included on error pages. | 91 // included on error pages. |
| 92 std::string error_string = net::ErrorToString(error_code); | 92 std::string error_string(net::ErrorToString(error_code)); |
| 93 base::RemoveChars(error_string, "net:", &error_string); | 93 DCHECK(StartsWithASCII(error_string, "net::", true)); |
| 94 error_string.erase(0, 5); |
| 94 | 95 |
| 95 return IsDisplayingText(browser, error_string); | 96 return IsDisplayingText(browser, error_string); |
| 96 } | 97 } |
| 97 | 98 |
| 98 // Checks that the local error page is being displayed, without remotely | 99 // Checks that the local error page is being displayed, without remotely |
| 99 // retrieved navigation corrections, and with the specified error code. | 100 // retrieved navigation corrections, and with the specified error code. |
| 100 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { | 101 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { |
| 101 // Expand the help box so innerText will include text below the fold. | 102 // Expand the help box so innerText will include text below the fold. |
| 102 ToggleHelpBox(browser); | 103 ToggleHelpBox(browser); |
| 103 | 104 |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 browser(), | 1103 browser(), |
| 1103 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1104 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1104 kHostname), | 1105 kHostname), |
| 1105 1); | 1106 1); |
| 1106 | 1107 |
| 1107 ToggleHelpBox(browser()); | 1108 ToggleHelpBox(browser()); |
| 1108 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1109 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1109 } | 1110 } |
| 1110 | 1111 |
| 1111 } // namespace | 1112 } // namespace |
| OLD | NEW |