Commit 50c82ce4 authored by Ali Juma's avatar Ali Juma Committed by Commit Bot

[iOS] Fix unit tests that fail when committed interstitials are enabled

This CL fixes WebStateObserverTest.FailedSslConnection with
committed interstitials. This also makes
CRWWebControllerTest.SslCertError early-return when committed
interstitials are enabled, since it tests behavior that
is specific to the old interstitials workflow.

Bug: 921916
Change-Id: I6bf4b0ff40ae0f7ee7f0ce91967aa3abc79ffb13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438890Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Ali Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812084}
parent 5fbcc48f
......@@ -231,6 +231,12 @@ class CRWWebControllerTest : public WebTestWithWebController {
// Tests that AllowCertificateError is called with correct arguments if
// WKWebView fails to load a page with bad SSL cert.
TEST_F(CRWWebControllerTest, SslCertError) {
if (base::FeatureList::IsEnabled(web::features::kSSLCommittedInterstitials)) {
// |AllowCertificateError| isn't called in the committed interstitials flow
// for SSL errors.
return;
}
// Last arguments passed to AllowCertificateError must be in default state.
ASSERT_FALSE(GetWebClient()->last_cert_error_code());
ASSERT_FALSE(GetWebClient()->last_cert_error_ssl_info().is_valid());
......
......@@ -2028,8 +2028,19 @@ TEST_F(WebStateObserverTest, FailedSslConnection) {
.WillOnce(VerifyPageStartedContext(
web_state(), url, ui::PageTransition::PAGE_TRANSITION_TYPED, &context,
&nav_id));
// TODO(crbug.com/921916): DidFinishNavigation is not called for SSL errors.
EXPECT_CALL(observer_, DidStopLoading(web_state()));
if (base::FeatureList::IsEnabled(web::features::kSSLCommittedInterstitials)) {
// First, a placeholder navigation starts and finishes.
EXPECT_CALL(observer_, DidStartLoading(web_state()));
EXPECT_CALL(observer_, DidStopLoading(web_state()));
EXPECT_CALL(observer_, DidFinishNavigation(web_state(), _));
EXPECT_CALL(observer_,
PageLoaded(web_state(), PageLoadCompletionStatus::FAILURE));
// Finally, the error page itself is loaded.
EXPECT_CALL(observer_, DidStartLoading(web_state()));
EXPECT_CALL(observer_, DidStopLoading(web_state()));
}
test::LoadUrl(web_state(), url);
EXPECT_TRUE(WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^{
......
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