Commit 9f6025aa authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[Nav Experiment] Introduce kLoadingPlaceholder state to error retry.

And also skips WebStateObserver::OnNavigationItemCommitted() callback
if the navigation has a placeholder URL.

These changes are helpful to differentiate a new request that hasn't
started error handling state transitions, which means it may still
succeed, and a request that has already failed and is in the middle of
loading the error view. The differentiation is useful for integrating
offline reading list with slim nav (crbug.com/840782).

More directly, this change fixes VoiceSearchNavigationTest, which needs
a placeholder entry to be loaded into the WebView before calling
LoadHtml(), but the placeholder entry must not consume the
WillLoadVoiceSearchResult() flag, which is cleared in
OnNavigationItemCommitted callback. Parameterized
VoiceSearchNavigationTest on both navigation manager implementations.

This situation does not arise in production because LoadHtml() is a
test only API. In production, placeholder URLs are only triggered for
app-specific URL or error view, neither of which triggers
OnNavigationItemCommitted on the placeholder load.

Bug: 863026
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ic4eda9f46b59886a2d24169b630aa8179373f7fb
Reviewed-on: https://chromium-review.googlesource.com/1176240
Commit-Queue: Danyao Wang <danyao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583898}
parent 3880edde
...@@ -79,6 +79,7 @@ source_set("unit_tests") { ...@@ -79,6 +79,7 @@ source_set("unit_tests") {
":tts", ":tts",
":voice", ":voice",
"//base", "//base",
"//base/test:test_support",
"//ios/web", "//ios/web",
"//ios/web/public/test", "//ios/web/public/test",
"//testing/gtest", "//testing/gtest",
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/voice/voice_search_navigations_tab_helper.h" #import "ios/chrome/browser/voice/voice_search_navigations_tab_helper.h"
#include "base/test/scoped_feature_list.h"
#include "ios/web/public/features.h"
#import "ios/web/public/navigation_item.h" #import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h" #import "ios/web/public/navigation_manager.h"
#import "ios/web/public/test/web_test_with_web_state.h" #import "ios/web/public/test/web_test_with_web_state.h"
...@@ -15,10 +17,26 @@ ...@@ -15,10 +17,26 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
// VoiceSearchNavigationsTest is parameterized on this enum to test both
// LegacyNavigationManager and WKBasedNavigationManager.
enum class NavigationManagerChoice {
LEGACY,
WK_BASED,
};
// Test fixture for VoiceSearchNavigations. // Test fixture for VoiceSearchNavigations.
class VoiceSearchNavigationsTest : public web::WebTestWithWebState { class VoiceSearchNavigationsTest
: public web::WebTestWithWebState,
public ::testing::WithParamInterface<NavigationManagerChoice> {
public: public:
void SetUp() override { void SetUp() override {
if (GetParam() == NavigationManagerChoice::LEGACY) {
scoped_feature_list_.InitAndDisableFeature(
web::features::kSlimNavigationManager);
} else {
scoped_feature_list_.InitAndEnableFeature(
web::features::kSlimNavigationManager);
}
web::WebTestWithWebState::SetUp(); web::WebTestWithWebState::SetUp();
VoiceSearchNavigationTabHelper::CreateForWebState(web_state()); VoiceSearchNavigationTabHelper::CreateForWebState(web_state());
} }
...@@ -26,11 +44,14 @@ class VoiceSearchNavigationsTest : public web::WebTestWithWebState { ...@@ -26,11 +44,14 @@ class VoiceSearchNavigationsTest : public web::WebTestWithWebState {
VoiceSearchNavigationTabHelper* navigations() { VoiceSearchNavigationTabHelper* navigations() {
return VoiceSearchNavigationTabHelper::FromWebState(web_state()); return VoiceSearchNavigationTabHelper::FromWebState(web_state());
} }
private:
base::test::ScopedFeatureList scoped_feature_list_;
}; };
// Tests that a NavigationItem is not marked as a voice search if // Tests that a NavigationItem is not marked as a voice search if
// WillLoadVoiceSearchResult() was not called. // WillLoadVoiceSearchResult() was not called.
TEST_F(VoiceSearchNavigationsTest, NotVoiceSearchNavigation) { TEST_P(VoiceSearchNavigationsTest, NotVoiceSearchNavigation) {
LoadHtml(@"<html></html>"); LoadHtml(@"<html></html>");
web::NavigationItem* item = web::NavigationItem* item =
web_state()->GetNavigationManager()->GetLastCommittedItem(); web_state()->GetNavigationManager()->GetLastCommittedItem();
...@@ -39,7 +60,7 @@ TEST_F(VoiceSearchNavigationsTest, NotVoiceSearchNavigation) { ...@@ -39,7 +60,7 @@ TEST_F(VoiceSearchNavigationsTest, NotVoiceSearchNavigation) {
// Tests that a pending NavigationItem is recorded as a voice search navigation // Tests that a pending NavigationItem is recorded as a voice search navigation
// if it is added after calling WillLoadVoiceSearchResult(). // if it is added after calling WillLoadVoiceSearchResult().
TEST_F(VoiceSearchNavigationsTest, PendingVoiceSearchNavigation) { TEST_P(VoiceSearchNavigationsTest, PendingVoiceSearchNavigation) {
navigations()->WillLoadVoiceSearchResult(); navigations()->WillLoadVoiceSearchResult();
const GURL kPendingUrl("http://pending.test"); const GURL kPendingUrl("http://pending.test");
AddPendingItem(kPendingUrl, ui::PAGE_TRANSITION_LINK); AddPendingItem(kPendingUrl, ui::PAGE_TRANSITION_LINK);
...@@ -50,7 +71,7 @@ TEST_F(VoiceSearchNavigationsTest, PendingVoiceSearchNavigation) { ...@@ -50,7 +71,7 @@ TEST_F(VoiceSearchNavigationsTest, PendingVoiceSearchNavigation) {
// Tests that a committed NavigationItem is recordored as a voice search // Tests that a committed NavigationItem is recordored as a voice search
// navigation if it occurs after calling WillLoadVoiceSearchResult(). // navigation if it occurs after calling WillLoadVoiceSearchResult().
TEST_F(VoiceSearchNavigationsTest, CommittedVoiceSearchNavigation) { TEST_P(VoiceSearchNavigationsTest, CommittedVoiceSearchNavigation) {
navigations()->WillLoadVoiceSearchResult(); navigations()->WillLoadVoiceSearchResult();
LoadHtml(@"<html></html>"); LoadHtml(@"<html></html>");
web::NavigationItem* item = web::NavigationItem* item =
...@@ -60,7 +81,7 @@ TEST_F(VoiceSearchNavigationsTest, CommittedVoiceSearchNavigation) { ...@@ -60,7 +81,7 @@ TEST_F(VoiceSearchNavigationsTest, CommittedVoiceSearchNavigation) {
// Tests that navigations that occur after a voice search navigation are not // Tests that navigations that occur after a voice search navigation are not
// marked as voice search navigations. // marked as voice search navigations.
TEST_F(VoiceSearchNavigationsTest, NavigationAfterVoiceSearch) { TEST_P(VoiceSearchNavigationsTest, NavigationAfterVoiceSearch) {
navigations()->WillLoadVoiceSearchResult(); navigations()->WillLoadVoiceSearchResult();
const GURL kVoiceSearchUrl("http://voice.test"); const GURL kVoiceSearchUrl("http://voice.test");
LoadHtml(@"<html></html>", kVoiceSearchUrl); LoadHtml(@"<html></html>", kVoiceSearchUrl);
...@@ -75,7 +96,7 @@ TEST_F(VoiceSearchNavigationsTest, NavigationAfterVoiceSearch) { ...@@ -75,7 +96,7 @@ TEST_F(VoiceSearchNavigationsTest, NavigationAfterVoiceSearch) {
} }
// Tests that transient NavigationItems are handled the same as pending items // Tests that transient NavigationItems are handled the same as pending items
TEST_F(VoiceSearchNavigationsTest, TransientNavigations) { TEST_P(VoiceSearchNavigationsTest, TransientNavigations) {
LoadHtml(@"<html></html>", GURL("http://committed_url.test")); LoadHtml(@"<html></html>", GURL("http://committed_url.test"));
const GURL kTransientURL("http://transient.test"); const GURL kTransientURL("http://transient.test");
AddTransientItem(kTransientURL); AddTransientItem(kTransientURL);
...@@ -85,3 +106,8 @@ TEST_F(VoiceSearchNavigationsTest, TransientNavigations) { ...@@ -85,3 +106,8 @@ TEST_F(VoiceSearchNavigationsTest, TransientNavigations) {
navigations()->WillLoadVoiceSearchResult(); navigations()->WillLoadVoiceSearchResult();
EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item)); EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item));
} }
INSTANTIATE_TEST_CASE_P(ProgrammaticVoiceSearchNavigationsTest,
VoiceSearchNavigationsTest,
::testing::Values(NavigationManagerChoice::LEGACY,
NavigationManagerChoice::WK_BASED));
...@@ -33,6 +33,9 @@ enum class ErrorRetryState { ...@@ -33,6 +33,9 @@ enum class ErrorRetryState {
kNewRequest, kNewRequest,
// This navigation item loaded without error. // This navigation item loaded without error.
kNoNavigationError, kNoNavigationError,
// This navigation item failed to load and is in the process of loading a
// placeholder.
kLoadingPlaceholder,
// This navigation item has an entry in WKBackForwardList. Ready to present // This navigation item has an entry in WKBackForwardList. Ready to present
// error in native view. // error in native view.
kReadyToDisplayErrorForFailedNavigation, kReadyToDisplayErrorForFailedNavigation,
......
...@@ -58,6 +58,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation( ...@@ -58,6 +58,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation(
return ErrorRetryCommand::kLoadErrorView; return ErrorRetryCommand::kLoadErrorView;
} }
// Provisional navigation failed on a new item. // Provisional navigation failed on a new item.
state_ = ErrorRetryState::kLoadingPlaceholder;
return ErrorRetryCommand::kLoadPlaceholder; return ErrorRetryCommand::kLoadPlaceholder;
// Reload of a previously successful load fails. // Reload of a previously successful load fails.
...@@ -71,6 +72,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation( ...@@ -71,6 +72,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation(
case ErrorRetryState::kDisplayingWebErrorForFailedNavigation: case ErrorRetryState::kDisplayingWebErrorForFailedNavigation:
return BackForwardOrReloadFailed(web_view_url, error_url); return BackForwardOrReloadFailed(web_view_url, error_url);
case ErrorRetryState::kLoadingPlaceholder:
case ErrorRetryState::kReadyToDisplayErrorForFailedNavigation: case ErrorRetryState::kReadyToDisplayErrorForFailedNavigation:
case ErrorRetryState::kNavigatingToFailedNavigationItem: case ErrorRetryState::kNavigatingToFailedNavigationItem:
NOTREACHED() << "Unexpected error retry state: " NOTREACHED() << "Unexpected error retry state: "
...@@ -96,6 +98,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailNavigation( ...@@ -96,6 +98,7 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailNavigation(
case ErrorRetryState::kDisplayingWebErrorForFailedNavigation: case ErrorRetryState::kDisplayingWebErrorForFailedNavigation:
return BackForwardOrReloadFailed(web_view_url, error_url); return BackForwardOrReloadFailed(web_view_url, error_url);
case ErrorRetryState::kLoadingPlaceholder:
case ErrorRetryState::kReadyToDisplayErrorForFailedNavigation: case ErrorRetryState::kReadyToDisplayErrorForFailedNavigation:
case ErrorRetryState::kNavigatingToFailedNavigationItem: case ErrorRetryState::kNavigatingToFailedNavigationItem:
NOTREACHED() << "Unexpected error retry state: " NOTREACHED() << "Unexpected error retry state: "
...@@ -107,21 +110,20 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailNavigation( ...@@ -107,21 +110,20 @@ ErrorRetryCommand ErrorRetryStateMachine::DidFailNavigation(
ErrorRetryCommand ErrorRetryStateMachine::DidFinishNavigation( ErrorRetryCommand ErrorRetryStateMachine::DidFinishNavigation(
const GURL& web_view_url) { const GURL& web_view_url) {
switch (state_) { switch (state_) {
case ErrorRetryState::kNewRequest: case ErrorRetryState::kLoadingPlaceholder:
// (1) Placeholder load for initial failure succeeded. // (1) Placeholder load for initial failure succeeded.
if (!web::GetWebClient()->IsAppSpecificURL(url_) && DCHECK(!web::GetWebClient()->IsAppSpecificURL(url_));
web_view_url == DCHECK_EQ(web_view_url,
wk_navigation_util::CreatePlaceholderUrlForUrl(url_)) { wk_navigation_util::CreatePlaceholderUrlForUrl(url_));
state_ = ErrorRetryState::kReadyToDisplayErrorForFailedNavigation; state_ = ErrorRetryState::kReadyToDisplayErrorForFailedNavigation;
return ErrorRetryCommand::kLoadErrorView; return ErrorRetryCommand::kLoadErrorView;
}
case ErrorRetryState::kNewRequest:
if (wk_navigation_util::IsRestoreSessionUrl(web_view_url)) { if (wk_navigation_util::IsRestoreSessionUrl(web_view_url)) {
// (8) Initial load of restore_session.html. Don't change state or // (8) Initial load of restore_session.html. Don't change state or
// issue command. Wait for the client-side redirect. // issue command. Wait for the client-side redirect.
} else { } else {
// (2) Initial load succeeded. // (2) Initial load succeeded.
DCHECK(web::GetWebClient()->IsAppSpecificURL(url_) ||
web_view_url == url_);
state_ = ErrorRetryState::kNoNavigationError; state_ = ErrorRetryState::kNoNavigationError;
} }
break; break;
......
...@@ -33,7 +33,7 @@ TEST_F(ErrorRetryStateMachineTest, OfflineThenReload) { ...@@ -33,7 +33,7 @@ TEST_F(ErrorRetryStateMachineTest, OfflineThenReload) {
// Initial load fails. // Initial load fails.
ASSERT_EQ(ErrorRetryCommand::kLoadPlaceholder, ASSERT_EQ(ErrorRetryCommand::kLoadPlaceholder,
machine.DidFailProvisionalNavigation(GURL::EmptyGURL(), test_url)); machine.DidFailProvisionalNavigation(GURL::EmptyGURL(), test_url));
ASSERT_EQ(ErrorRetryState::kNewRequest, machine.state()); ASSERT_EQ(ErrorRetryState::kLoadingPlaceholder, machine.state());
// Placeholder load finishes. // Placeholder load finishes.
ASSERT_EQ(ErrorRetryCommand::kLoadErrorView, ASSERT_EQ(ErrorRetryCommand::kLoadErrorView,
...@@ -96,7 +96,7 @@ TEST_F(ErrorRetryStateMachineTest, WebErrorPageThenReload) { ...@@ -96,7 +96,7 @@ TEST_F(ErrorRetryStateMachineTest, WebErrorPageThenReload) {
// Initial load fails. // Initial load fails.
ASSERT_EQ(ErrorRetryCommand::kLoadPlaceholder, ASSERT_EQ(ErrorRetryCommand::kLoadPlaceholder,
machine.DidFailProvisionalNavigation(GURL::EmptyGURL(), test_url)); machine.DidFailProvisionalNavigation(GURL::EmptyGURL(), test_url));
ASSERT_EQ(ErrorRetryState::kNewRequest, machine.state()); ASSERT_EQ(ErrorRetryState::kLoadingPlaceholder, machine.state());
// Placeholder load finishes. // Placeholder load finishes.
ASSERT_EQ(ErrorRetryCommand::kLoadErrorView, ASSERT_EQ(ErrorRetryCommand::kLoadErrorView,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#import "ios/web/navigation/navigation_manager_impl.h" #import "ios/web/navigation/navigation_manager_impl.h"
#import "ios/web/navigation/wk_navigation_util.h"
#import "ios/web/public/web_client.h" #import "ios/web/public/web_client.h"
#include "ios/web/public/web_state/url_verification_constants.h" #include "ios/web/public/web_state/url_verification_constants.h"
#include "ios/web/public/web_state/web_state_observer.h" #include "ios/web/public/web_state/web_state_observer.h"
...@@ -103,15 +104,15 @@ void WebTestWithWebState::LoadHtml(NSString* html, const GURL& url) { ...@@ -103,15 +104,15 @@ void WebTestWithWebState::LoadHtml(NSString* html, const GURL& url) {
CRWWebController* web_controller = GetWebController(web_state()); CRWWebController* web_controller = GetWebController(web_state());
ASSERT_EQ(PAGE_LOADED, web_controller.loadPhase); ASSERT_EQ(PAGE_LOADED, web_controller.loadPhase);
// If the underlying WKWebView is empty, first load a placeholder about:blank // If the underlying WKWebView is empty, first load a placeholder to create a
// to create a WKBackForwardListItem to store the NavigationItem associated // WKBackForwardListItem to store the NavigationItem associated with the
// with the |-loadHTML|. // |-loadHTML|.
// TODO(crbug.com/777884): consider changing |-loadHTML| to match WKWebView's // TODO(crbug.com/777884): consider changing |-loadHTML| to match WKWebView's
// |-loadHTMLString:baseURL| that doesn't create a navigation entry. // |-loadHTMLString:baseURL| that doesn't create a navigation entry.
if (web::GetWebClient()->IsSlimNavigationManagerEnabled() && if (web::GetWebClient()->IsSlimNavigationManagerEnabled() &&
!web_state()->GetNavigationManager()->GetItemCount()) { !web_state()->GetNavigationManager()->GetItemCount()) {
GURL url(url::kAboutBlankURL); GURL placeholder_url = wk_navigation_util::CreatePlaceholderUrlForUrl(url);
NavigationManager::WebLoadParams params(url); NavigationManager::WebLoadParams params(placeholder_url);
web_state()->GetNavigationManager()->LoadURLWithParams(params); web_state()->GetNavigationManager()->LoadURLWithParams(params);
base::test::ios::WaitUntilCondition(^{ base::test::ios::WaitUntilCondition(^{
return web_controller.loadPhase == PAGE_LOADED; return web_controller.loadPhase == PAGE_LOADED;
......
...@@ -1085,18 +1085,11 @@ TEST_P(CRWWebControllerTitleTest, TitleChange) { ...@@ -1085,18 +1085,11 @@ TEST_P(CRWWebControllerTitleTest, TitleChange) {
scoped_observer.Add(web_state()); scoped_observer.Add(web_state());
ASSERT_EQ(0, observer.title_change_count()); ASSERT_EQ(0, observer.title_change_count());
int initial_title_change_count = 0;
if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
// WKBasedNavigationManager produces an extra call to TitleWasSet because it
// loads New Tab Page in web view.
initial_title_change_count += 1;
}
// Expect TitleWasSet callback after the page is loaded and due to WKWebView // Expect TitleWasSet callback after the page is loaded and due to WKWebView
// title change KVO. // title change KVO.
LoadHtml(@"<title>Title1</title>"); LoadHtml(@"<title>Title1</title>");
EXPECT_EQ("Title1", base::UTF16ToUTF8(web_state()->GetTitle())); EXPECT_EQ("Title1", base::UTF16ToUTF8(web_state()->GetTitle()));
EXPECT_EQ(initial_title_change_count + 2, observer.title_change_count()); EXPECT_EQ(2, observer.title_change_count());
// Expect at least one more TitleWasSet callback after changing title via // Expect at least one more TitleWasSet callback after changing title via
// JavaScript. On iOS 10 WKWebView fires 3 callbacks after JS excucution // JavaScript. On iOS 10 WKWebView fires 3 callbacks after JS excucution
...@@ -1105,7 +1098,7 @@ TEST_P(CRWWebControllerTitleTest, TitleChange) { ...@@ -1105,7 +1098,7 @@ TEST_P(CRWWebControllerTitleTest, TitleChange) {
// Fix expecteation when WKWebView stops sending extra KVO calls. // Fix expecteation when WKWebView stops sending extra KVO calls.
ExecuteJavaScript(@"window.document.title = 'Title2';"); ExecuteJavaScript(@"window.document.title = 'Title2';");
EXPECT_EQ("Title2", base::UTF16ToUTF8(web_state()->GetTitle())); EXPECT_EQ("Title2", base::UTF16ToUTF8(web_state()->GetTitle()));
EXPECT_GE(observer.title_change_count(), initial_title_change_count + 3); EXPECT_GE(observer.title_change_count(), 3);
}; };
// Tests that fragment change navigations use title from the previous page. // Tests that fragment change navigations use title from the previous page.
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#import "ios/web/public/crw_session_storage.h" #import "ios/web/public/crw_session_storage.h"
#include "ios/web/public/favicon_url.h" #include "ios/web/public/favicon_url.h"
#import "ios/web/public/java_script_dialog_presenter.h" #import "ios/web/public/java_script_dialog_presenter.h"
#include "ios/web/public/load_committed_details.h"
#import "ios/web/public/navigation_item.h" #import "ios/web/public/navigation_item.h"
#include "ios/web/public/url_util.h" #include "ios/web/public/url_util.h"
#import "ios/web/public/web_client.h" #import "ios/web/public/web_client.h"
...@@ -852,6 +853,9 @@ void WebStateImpl::OnNavigationItemChanged() { ...@@ -852,6 +853,9 @@ void WebStateImpl::OnNavigationItemChanged() {
void WebStateImpl::OnNavigationItemCommitted( void WebStateImpl::OnNavigationItemCommitted(
const LoadCommittedDetails& load_details) { const LoadCommittedDetails& load_details) {
if (wk_navigation_util::IsWKInternalUrl(load_details.item->GetURL()))
return;
// A committed navigation item indicates that NavigationManager has a new // A committed navigation item indicates that NavigationManager has a new
// valid session history so should invalidate the cached restored session // valid session history so should invalidate the cached restored session
// history. // history.
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#import "ios/web/interstitials/html_web_interstitial_impl.h" #import "ios/web/interstitials/html_web_interstitial_impl.h"
#import "ios/web/navigation/navigation_item_impl.h"
#import "ios/web/navigation/wk_navigation_util.h" #import "ios/web/navigation/wk_navigation_util.h"
#import "ios/web/public/crw_navigation_item_storage.h" #import "ios/web/public/crw_navigation_item_storage.h"
#import "ios/web/public/crw_session_storage.h" #import "ios/web/public/crw_session_storage.h"
...@@ -464,6 +465,8 @@ TEST_P(WebStateImplTest, ObserverTest) { ...@@ -464,6 +465,8 @@ TEST_P(WebStateImplTest, ObserverTest) {
// Test that NavigationItemCommitted() is called. // Test that NavigationItemCommitted() is called.
ASSERT_FALSE(observer->commit_navigation_info()); ASSERT_FALSE(observer->commit_navigation_info());
LoadCommittedDetails details; LoadCommittedDetails details;
auto item = std::make_unique<NavigationItemImpl>();
details.item = item.get();
web_state_->OnNavigationItemCommitted(details); web_state_->OnNavigationItemCommitted(details);
ASSERT_TRUE(observer->commit_navigation_info()); ASSERT_TRUE(observer->commit_navigation_info());
EXPECT_EQ(web_state_.get(), observer->commit_navigation_info()->web_state); EXPECT_EQ(web_state_.get(), observer->commit_navigation_info()->web_state);
...@@ -656,6 +659,8 @@ TEST_P(WebStateImplTest, GlobalObserverTest) { ...@@ -656,6 +659,8 @@ TEST_P(WebStateImplTest, GlobalObserverTest) {
// Test that NavigationItemCommitted() is called. // Test that NavigationItemCommitted() is called.
EXPECT_FALSE(observer->navigation_item_committed_called()); EXPECT_FALSE(observer->navigation_item_committed_called());
LoadCommittedDetails details; LoadCommittedDetails details;
auto item = std::make_unique<NavigationItemImpl>();
details.item = item.get();
web_state_->OnNavigationItemCommitted(details); web_state_->OnNavigationItemCommitted(details);
EXPECT_TRUE(observer->navigation_item_committed_called()); EXPECT_TRUE(observer->navigation_item_committed_called());
......
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