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

Mock WKWebView.URL for CRWWebControllerTest.CurrentUrlWithTrustLevel.

-[CRWWebController setDocumentURL:] will have a DCHECK when new document
URL does not match last committed URL in WKBasedNavigationManager. This
DCHECK will help to diagnose possible URL spoofing bugs in Slim
Navigation feature.

Mocking WKWebView.URL will prevent that DCHECK from firing in
CRWWebControllerTest.CurrentUrlWithTrustLevel.

Bug: 1171671
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I19e317079859306948fa6a925bd37d2157987876
Reviewed-on: https://chromium-review.googlesource.com/1182320Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584624}
parent 54796409
......@@ -804,10 +804,12 @@ TEST_P(CRWWebControllerDownloadTest, DataUrlResponse) {
// Tests |currentURLWithTrustLevel:| method.
TEST_P(CRWWebControllerTest, CurrentUrlWithTrustLevel) {
AddPendingItem(GURL("http://chromium.test"), ui::PAGE_TRANSITION_TYPED);
GURL url("http://chromium.test");
AddPendingItem(url, ui::PAGE_TRANSITION_TYPED);
[[[mock_web_view_ stub] andReturnBool:NO] hasOnlySecureContent];
[static_cast<WKWebView*>([[mock_web_view_ stub] andReturn:@""]) title];
SetWebViewURL(@"http://chromium.test");
// Stub out the injection process.
[[mock_web_view_ stub] evaluateJavaScript:OCMOCK_ANY
......@@ -820,9 +822,7 @@ TEST_P(CRWWebControllerTest, CurrentUrlWithTrustLevel) {
[navigation_delegate_ webView:mock_web_view_ didCommitNavigation:nil];
URLVerificationTrustLevel trust_level = kNone;
GURL url = [web_controller() currentURLWithTrustLevel:&trust_level];
EXPECT_EQ(GURL(kTestURLString), url);
EXPECT_EQ(url, [web_controller() currentURLWithTrustLevel:&trust_level]);
EXPECT_EQ(kAbsolute, trust_level);
}
......
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