0

[iOS] Don't reset fullscreen state for same-document navigations.

Bug: 834131
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I7a3bb44da51bdd3aac19ff8da559d4178e0fe168
Reviewed-on: https://chromium-review.googlesource.com/1017231
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552164}
This commit is contained in:
Kurt Horimoto
2018-04-19 21:29:25 +00:00
committed by Commit Bot
parent 17c77ccb59
commit 0e1921e809
2 changed files with 18 additions and 2 deletions

@ -13,6 +13,7 @@
#import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h"
#include "ios/web/public/ssl_status.h"
#import "ios/web/public/web_state/navigation_context.h"
#import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
#import "ios/web/public/web_state/web_state.h"
@ -88,8 +89,10 @@ void FullscreenWebStateObserver::DidFinishNavigation(
web_state->GetWebViewProxy().shouldUseViewContentInset =
force_content_inset ||
web_state->GetContentsMimeType() == "application/pdf";
// Reset the model so that the toolbar is visible for the new page.
model_->ResetForNavigation();
// Reset the model so that the toolbar is visible when navigating to a new
// document.
if (!navigation_context->IsSameDocument())
model_->ResetForNavigation();
// Disable fullscreen if there is a problem with the SSL status.
SetDisableFullscreenForSSL(ShouldDisableFullscreenForWebStateSSL(web_state));
}

@ -69,6 +69,19 @@ TEST_F(FullscreenWebStateObserverTest, ResetForNavigation) {
EXPECT_EQ(model().progress(), 1.0);
}
// Tests that the FullscreenModel is not reset for a same-document navigation.
TEST_F(FullscreenWebStateObserverTest, NoResetForSameDocument) {
// Simulate a scroll to 0.5 progress.
SimulateFullscreenUserScrollForProgress(&model(), 0.5);
EXPECT_EQ(model().progress(), 0.5);
// Simulate a same-document navigation and verify that the 0.5 progress hasn't
// been reset to 1.0.
web::FakeNavigationContext context;
context.SetIsSameDocument(true);
web_state().OnNavigationFinished(&context);
EXPECT_EQ(model().progress(), 0.5);
}
// Tests that the model is disabled when a load is occurring.
TEST_F(FullscreenWebStateObserverTest, DisableDuringLoad) {
EXPECT_TRUE(model().enabled());