| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void ToggleHelpBox(Browser* browser) { | 80 void ToggleHelpBox(Browser* browser) { |
| 81 EXPECT_TRUE(content::ExecuteScript( | 81 EXPECT_TRUE(content::ExecuteScript( |
| 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 return IsDisplayingText(browser, net::ErrorToShortString(error_code)); |
| 91 // included on error pages. | |
| 92 std::string error_string(net::ErrorToString(error_code)); | |
| 93 DCHECK(StartsWithASCII(error_string, "net::", true)); | |
| 94 error_string.erase(0, 5); | |
| 95 | |
| 96 return IsDisplayingText(browser, error_string); | |
| 97 } | 91 } |
| 98 | 92 |
| 99 // Checks that the local error page is being displayed, without remotely | 93 // Checks that the local error page is being displayed, without remotely |
| 100 // retrieved navigation corrections, and with the specified error code. | 94 // retrieved navigation corrections, and with the specified error code. |
| 101 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { | 95 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { |
| 102 // Expand the help box so innerText will include text below the fold. | 96 // Expand the help box so innerText will include text below the fold. |
| 103 ToggleHelpBox(browser); | 97 ToggleHelpBox(browser); |
| 104 | 98 |
| 105 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); | 99 EXPECT_TRUE(IsDisplayingNetError(browser, error_code)); |
| 106 | 100 |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 browser(), | 1093 browser(), |
| 1100 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1094 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1101 kHostname), | 1095 kHostname), |
| 1102 1); | 1096 1); |
| 1103 | 1097 |
| 1104 ToggleHelpBox(browser()); | 1098 ToggleHelpBox(browser()); |
| 1105 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1099 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1106 } | 1100 } |
| 1107 | 1101 |
| 1108 } // namespace | 1102 } // namespace |
| OLD | NEW |