Commit 1870509a authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

Reland "[Nav Experiment] Call LoadIfNecessary() in CWVWebView session restore."

This is a reland of b21bf2bb

Original change's description:
> [Nav Experiment] Call LoadIfNecessary() in CWVWebView session restore.
> 
> The web view load scheduled by WKBasedNavigationManager::Restore() is
> deferred when used in CWVWebView's |resetWebStateWithSessionStorage|
> because the |_containerView| is not created until later. This CL calls
> LoadIfNecessary() explicitly after the view is created to trigger the
> session restoration.
> 
> This fixes WebViewRestorableStateTest when WKBasedNavigationManger is
> enabled. A better approach would be to turn this test into a
> programmatic test so both navigation managers implementations are
> tested, but web::features symbols are not exposed in ios/web_view.
> 
> Bug: 862714
> Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;luci.chromium.try:ios-simulator-cronet
> Change-Id: I21e694e3fef6a833f1cce04ff9cebd3784349111
> Reviewed-on: https://chromium-review.googlesource.com/c/1135435
> Commit-Queue: Danyao Wang <danyao@chromium.org>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Reviewed-by: Hiroshi Ichikawa <ichikawa@chromium.org>
> Reviewed-by: Justin Cohen <justincohen@chromium.org>
> Auto-Submit: Danyao Wang <danyao@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#626170}

Bug: 862714
Change-Id: I853a8e030bef9f812605eac24c65d8237027f107
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;luci.chromium.try:ios-simulator-cronet
Reviewed-on: https://chromium-review.googlesource.com/c/1437574Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626206}
parent 2e1939cb
......@@ -20,6 +20,7 @@
#import "ios/web/public/navigation_manager.h"
#include "ios/web/public/referrer.h"
#include "ios/web/public/reload_type.h"
#import "ios/web/public/web_client.h"
#import "ios/web/public/web_state/context_menu_params.h"
#import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
#import "ios/web/public/web_state/navigation_context.h"
......@@ -660,6 +661,12 @@ static NSString* gUserAgentProduct = nil;
[self updateVisibleSSLStatus];
self.loading = NO;
self.estimatedProgress = 0.0;
// TODO(crbug.com/873729): The session will not be restored until
// LoadIfNecessary call. Fix the bug and remove extra call.
if (web::GetWebClient()->IsSlimNavigationManagerEnabled() && sessionStorage) {
_webState->GetNavigationManager()->LoadIfNecessary();
}
}
// Adds the web view provided by |_webState| as a subview unless it has already.
......
......@@ -4,6 +4,7 @@
#import <ChromeWebView/ChromeWebView.h>
#import "base/test/ios/wait_util.h"
#import "ios/web_view/test/web_view_inttest_base.h"
#import "ios/web_view/test/web_view_test_util.h"
#include "testing/gtest_mac.h"
......@@ -12,6 +13,9 @@
#error "This file requires ARC support."
#endif
using base::test::ios::WaitUntilConditionOrTimeout;
using base::test::ios::kWaitForPageLoadTimeout;
namespace ios_web_view {
// Tests encodeRestorableStateWithCoder: and decodeRestorableStateWithCoder:
......@@ -36,6 +40,11 @@ TEST_F(WebViewRestorableStateTest, EncodeDecode) {
CWVWebView* restored_web_view = test::CreateWebView();
test::CopyWebViewState(web_view_, restored_web_view);
// Wait for restore to finish.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^bool {
return [restored_web_view canGoBack];
}));
// Verify that the state has been restored correctly.
EXPECT_NSEQ(@"about:blank",
[restored_web_view lastCommittedURL].absoluteString);
......
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