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,
const std::string& error_domain,
long error_code,
bool is_post,
bool is_off_the_record);
bool is_off_the_record,
bool has_ssl_info);
} // namespace testing
} // namespace web
......
......@@ -27,11 +27,13 @@ std::string GetErrorText(WebState* web_state,
const std::string& error_domain,
long error_code,
bool is_post,
bool is_off_the_record) {
return base::StringPrintf(
"web_state: %p url: %s domain: %s code: %ld post: %d otr: %d", web_state,
url.spec().c_str(), error_domain.c_str(), error_code, is_post,
is_off_the_record);
bool is_off_the_record,
bool has_ssl_info) {
return base::StringPrintf("web_state: %p url: %s domain: %s code: %ld post: "
"%d otr: %d ssl_info: %d",
web_state, url.spec().c_str(), error_domain.c_str(),
error_code, is_post, is_off_the_record,
has_ssl_info);
}
} // namespace testing
......
......@@ -109,7 +109,7 @@ void TestWebClient::PrepareErrorPage(
base::OnceCallback<void(NSString*)> callback) {
std::move(callback).Run(base::SysUTF8ToNSString(testing::GetErrorText(
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() {
......
......@@ -248,7 +248,8 @@ TEST_P(BadSslResponseTest, ShowSSLErrorPageCommittedInterstitial) {
web_state(),
testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*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()->visible_ssl_status);
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN,
......
......@@ -48,7 +48,8 @@ bool WaitForErrorText(WebState* web_state, const GURL& url) {
web_state,
testing::GetErrorText(web_state, url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/false, /*is_otr=*/false));
/*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false));
}
} // namespace
......@@ -327,7 +328,8 @@ TEST_P(ErrorPageTest, OtrError) {
testing::GetErrorText(web_state.get(), server_.GetURL("/echo-query?foo"),
"NSURLErrorDomain",
/*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.
......@@ -342,10 +344,10 @@ TEST_P(ErrorPageTest, FormSubmissionError) {
// Error is displayed after the form submission navigation.
ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(),
testing::GetErrorText(web_state(), server_.GetURL("/close-socket"),
"NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/true, /*is_otr=*/false)));
testing::GetErrorText(
web_state(), server_.GetURL("/close-socket"), "NSURLErrorDomain",
/*error_code=*/NSURLErrorNetworkConnectionLost,
/*is_post=*/true, /*is_otr=*/false, /*has_ssl_info=*/false)));
}
// Loads an item and checks that virtualURL and URL after displaying the error
......
......@@ -1139,7 +1139,8 @@ TEST_P(WebStateObserverTest, FailedNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*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));
}
......@@ -1280,7 +1281,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedSchemeNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "NSURLErrorDomain",
/*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
......@@ -1332,7 +1334,8 @@ TEST_P(WebStateObserverTest, WebViewUnsupportedUrlNavigation) {
ASSERT_TRUE(test::WaitForWebViewContainingText(
web_state(), testing::GetErrorText(web_state(), url, "WebKitErrorDomain",
/*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.
......
......@@ -608,7 +608,8 @@ TEST_P(WebStateTest, LoadChromeThenHTML) {
web_state(),
testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorUnsupportedURL,
/*is_post=*/false, /*is_otr=*/false)));
/*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
NSString* data_html = @(kTestPageHTML);
web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding],
@"text/html", GURL("https://www.chromium.org"));
......@@ -643,7 +644,8 @@ TEST_P(WebStateTest, LoadChromeThenWaitThenHTMLThenReload) {
web_state(),
testing::GetErrorText(web_state(), app_specific_url, "NSURLErrorDomain",
/*error_code=*/NSURLErrorUnsupportedURL,
/*is_post=*/false, /*is_otr=*/false)));
/*is_post=*/false, /*is_otr=*/false,
/*has_ssl_info=*/false)));
NSString* data_html = @(kTestPageHTML);
web_state()->LoadData([data_html dataUsingEncoding:NSUTF8StringEncoding],
@"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