Commit bf3139b1 authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Add tests to check SSLInfo is properly passed to PrepareErrorPage

Follow-up to crrev.com/c/1793260.

Bug: 1017406
Change-Id: Ic7823f6a630d0cd4cbd7e64d0999b81d964b9129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894043Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712624}
parent 1bab05bb
...@@ -27,7 +27,8 @@ std::string GetErrorText(WebState* web_state, ...@@ -27,7 +27,8 @@ std::string GetErrorText(WebState* web_state,
const std::string& error_domain, const std::string& error_domain,
long error_code, long error_code,
bool is_post, bool is_post,
bool is_off_the_record); bool is_off_the_record,
bool has_ssl_info);
} // namespace testing } // namespace testing
} // namespace web } // namespace web
......
...@@ -27,11 +27,13 @@ std::string GetErrorText(WebState* web_state, ...@@ -27,11 +27,13 @@ std::string GetErrorText(WebState* web_state,
const std::string& error_domain, const std::string& error_domain,
long error_code, long error_code,
bool is_post, bool is_post,
bool is_off_the_record) { bool is_off_the_record,
return base::StringPrintf( bool has_ssl_info) {
"web_state: %p url: %s domain: %s code: %ld post: %d otr: %d", web_state, return base::StringPrintf("web_state: %p url: %s domain: %s code: %ld post: "
url.spec().c_str(), error_domain.c_str(), error_code, is_post, "%d otr: %d ssl_info: %d",
is_off_the_record); web_state, url.spec().c_str(), error_domain.c_str(),
error_code, is_post, is_off_the_record,
has_ssl_info);
} }
} // namespace testing } // namespace testing
......
...@@ -109,7 +109,7 @@ void TestWebClient::PrepareErrorPage( ...@@ -109,7 +109,7 @@ void TestWebClient::PrepareErrorPage(
base::OnceCallback<void(NSString*)> callback) { base::OnceCallback<void(NSString*)> callback) {
std::move(callback).Run(base::SysUTF8ToNSString(testing::GetErrorText( std::move(callback).Run(base::SysUTF8ToNSString(testing::GetErrorText(
web_state, url, base::SysNSStringToUTF8(error.domain), error.code, web_state, url, base::SysNSStringToUTF8(error.domain), error.code,
is_post, is_off_the_record))); is_post, is_off_the_record, info.has_value())));
} }
UIView* TestWebClient::GetWindowedContainer() { UIView* TestWebClient::GetWindowedContainer() {
......
...@@ -248,7 +248,8 @@ TEST_P(BadSslResponseTest, ShowSSLErrorPageCommittedInterstitial) { ...@@ -248,7 +248,8 @@ TEST_P(BadSslResponseTest, ShowSSLErrorPageCommittedInterstitial) {
web_state(), web_state(),
testing::GetErrorText(web_state(), url, "NSURLErrorDomain", testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorServerCertificateUntrusted, /*error_code=*/NSURLErrorServerCertificateUntrusted,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/true)));
ASSERT_TRUE(security_state_info()); ASSERT_TRUE(security_state_info());
ASSERT_TRUE(security_state_info()->visible_ssl_status); ASSERT_TRUE(security_state_info()->visible_ssl_status);
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN,
......
...@@ -48,7 +48,8 @@ bool WaitForErrorText(WebState* web_state, const GURL& url) { ...@@ -48,7 +48,8 @@ bool WaitForErrorText(WebState* web_state, const GURL& url) {
web_state, web_state,
testing::GetErrorText(web_state, url, "NSURLErrorDomain", testing::GetErrorText(web_state, url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost, /*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/false, /*is_otr=*/false)); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false));
} }
} // namespace } // namespace
...@@ -327,7 +328,8 @@ TEST_P(ErrorPageTest, OtrError) { ...@@ -327,7 +328,8 @@ TEST_P(ErrorPageTest, OtrError) {
testing::GetErrorText(web_state.get(), server_.GetURL("/echo-query?foo"), testing::GetErrorText(web_state.get(), server_.GetURL("/echo-query?foo"),
"NSURLErrorDomain", "NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost, /*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/false, /*is_otr=*/true))); /*is_post=*/false, /*is_otr=*/true,
/*has_ssl_info=*/false)));
} }
// Loads the URL with form which fails to submit. // Loads the URL with form which fails to submit.
...@@ -342,10 +344,10 @@ TEST_P(ErrorPageTest, FormSubmissionError) { ...@@ -342,10 +344,10 @@ TEST_P(ErrorPageTest, FormSubmissionError) {
// Error is displayed after the form submission navigation. // Error is displayed after the form submission navigation.
ASSERT_TRUE(test::WaitForWebViewContainingText( ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), web_state(),
testing::GetErrorText(web_state(), server_.GetURL("/close-socket"), testing::GetErrorText(
"NSURLErrorDomain", web_state(), server_.GetURL("/close-socket"), "NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost, /*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/true, /*is_otr=*/false))); /*is_post=*/true, /*is_otr=*/false, /*has_ssl_info=*/false)));
} }
// Loads an item and checks that virtualURL and URL after displaying the error // Loads an item and checks that virtualURL and URL after displaying the error
......
...@@ -1139,7 +1139,8 @@ TEST_P(WebStateObserverTest, FailedNavigation) { ...@@ -1139,7 +1139,8 @@ TEST_P(WebStateObserverTest, FailedNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText( ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain", web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*error_code=*/-1005, /*error_code=*/-1005,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
DCHECK_EQ(item->GetTitle(), base::UTF8ToUTF16(kFailedTitle)); DCHECK_EQ(item->GetTitle(), base::UTF8ToUTF16(kFailedTitle));
} }
...@@ -1280,7 +1281,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedSchemeNavigation) { ...@@ -1280,7 +1281,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedSchemeNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText( ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain", web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*error_code=*/-1002, /*error_code=*/-1002,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
} }
// Tests failed navigation because URL with a space is not supported by // Tests failed navigation because URL with a space is not supported by
...@@ -1332,7 +1334,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedUrlNavigation) { ...@@ -1332,7 +1334,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedUrlNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText( ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "WebKitErrorDomain", web_state(), testing::GetErrorText(web_state(), url, "WebKitErrorDomain",
/*error_code=*/101, /*error_code=*/101,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
} }
// Tests failed navigation because URL scheme is not supported by WebState. // Tests failed navigation because URL scheme is not supported by WebState.
......
...@@ -608,7 +608,8 @@ TEST_P(WebStateTest, LoadChromeThenHTML) { ...@@ -608,7 +608,8 @@ TEST_P(WebStateTest, LoadChromeThenHTML) {
web_state(), web_state(),
testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain", testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorUnsupportedURL, /*error_code=*/NSURLErrorUnsupportedURL,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
NSString* data_html = @(kTestPageHTML); NSString* data_html = @(kTestPageHTML);
web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding], web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding],
@"text/html", GURL("https://www.chromium.org")); @"text/html", GURL("https://www.chromium.org"));
...@@ -643,7 +644,8 @@ TEST_P(WebStateTest, LoadChromeThenWaitThenHTMLThenReload) { ...@@ -643,7 +644,8 @@ TEST_P(WebStateTest, LoadChromeThenWaitThenHTMLThenReload) {
web_state(), web_state(),
testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain", testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorUnsupportedURL, /*error_code=*/NSURLErrorUnsupportedURL,
/*is_post=*/false, /*is_otr=*/false))); /*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
NSString* data_html = @(kTestPageHTML); NSString* data_html = @(kTestPageHTML);
web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding], web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding],
@"text/html", echo_url); @"text/html", echo_url);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment