Commit d495ed7d authored by Eugene But's avatar Eugene But Committed by Commit Bot

Add NavigationAndLoadCallbacksTest.DisallowResponse test.

This tests load rejection when ShouldAllowResponse returns false.

Bug: 614168,789585
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I91c1da903fdda7910aadc7ffdf74c23a72f79bde
Reviewed-on: https://chromium-review.googlesource.com/900094Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534852}
parent efefb20b
......@@ -1024,4 +1024,25 @@ TEST_F(NavigationAndLoadCallbacksTest, DisallowRequest) {
}));
}
// Tests rejecting the navigation from ShouldAllowResponse. PageLoaded callback
// is not called.
TEST_F(NavigationAndLoadCallbacksTest, DisallowResponse) {
const GURL url = test_server_->GetURL("/echo");
// Perform new page navigation.
NavigationContext* context = nullptr;
EXPECT_CALL(observer_, DidStartLoading(web_state()));
EXPECT_CALL(*decider_, ShouldAllowRequest(_, _)).WillOnce(Return(true));
EXPECT_CALL(observer_, DidStartNavigation(web_state(), _))
.WillOnce(VerifyNewPageStartedContext(web_state(), url, &context));
EXPECT_CALL(*decider_, ShouldAllowResponse(_, /*for_main_frame=*/true))
.WillOnce(Return(false));
// TODO(crbug.com/809557): DidFinishNavigation should be called.
EXPECT_CALL(observer_, DidStopLoading(web_state()));
web::test::LoadUrl(web_state(), test_server_->GetURL("/echo"));
EXPECT_TRUE(WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{
return !web_state()->IsLoading();
}));
}
} // namespace web
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