Commit 578c90a6 authored by Jun Choi's avatar Jun Choi Committed by Commit Bot

Revert "Add web::NavigationContext::IsPlaceholderNavigation"

This reverts commit 7b0f2bb8.

Reason for revert: Fails multiple IOS builds including Builder ios-slimnav <https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/ios-slimnav/191>

Link to sample failure logs : https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8929398908718170816/+/steps/ios_chrome_unittests__iPhone_6s_iOS_12.1_/0/logs/TextToSpeechListenerTest.ValidAudioDataTest/0


Original change's description:
> Add web::NavigationContext::IsPlaceholderNavigation
> 
> This is a step in multistep refactoring. The next steps will be:
> 
> 1.) web::NavigationContext::URL is never set to placeholder
>     URL and always represents navigation URL
> 2.) Same web::NavigationContext will be reused for placeholder
>     navigation to extend it's lifetime.
> 3.) WebStateObserver::DidFinishNavigation will be caller after
>     placeholder navigation is finished and will use original
>     web::NavigationContext passed to WebStateObserver::DidStartNavigation
> 
> This will partially fix crbug.com/903497 and will call
> WebStateObserver::DidFinishNavigation after committed URL actually
> changed.
> 
> Bug: 903497
> Change-Id: Ib6ba96d664ac352d038787aa74ac844d07282789
> Reviewed-on: https://chromium-review.googlesource.com/c/1331044
> Reviewed-by: Danyao Wang <danyao@chromium.org>
> Commit-Queue: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#609398}

TBR=eugenebut@chromium.org,danyao@chromium.org

Change-Id: I8d7c9b66d752a792761d95ccf348f045eaa9de03
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 903497
Reviewed-on: https://chromium-review.googlesource.com/c/1343351Reviewed-by: default avatarJun Choi <hongjunchoi@chromium.org>
Commit-Queue: Jun Choi <hongjunchoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609494}
parent c8fc00a7
......@@ -197,7 +197,6 @@ source_set("unit_tests") {
"//ios/web/public/test",
"//ios/web/public/test/fakes",
"//ios/web/test/fakes:fakes",
"//ios/web/web_state:navigation_context",
"//net",
"//testing/gmock",
"//testing/gtest",
......
......@@ -7,7 +7,6 @@ specific_include_rules = {
],
"^tab_unittest\.mm$": [
"+ios/web/web_state/ui/crw_web_controller.h",
"+ios/web/web_state/navigation_context_impl.h",
"+ios/web/navigation/navigation_manager_impl.h",
"+ios/web/web_state/web_state_impl.h",
"+ios/web/test/fakes/crw_fake_back_forward_list.h",
......
......@@ -48,7 +48,6 @@
#import "ios/web/public/test/fakes/fake_navigation_context.h"
#include "ios/web/public/test/test_web_thread_bundle.h"
#import "ios/web/test/fakes/crw_fake_back_forward_list.h"
#import "ios/web/web_state/navigation_context_impl.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
#import "ios/web/web_state/web_state_impl.h"
#import "net/base/mac/url_conversions.h"
......@@ -238,13 +237,9 @@ class TabTest : public BlockCleanupTest,
NSString* title) {
DCHECK_EQ(tab_.webState, web_state_impl_.get());
std::unique_ptr<web::NavigationContextImpl> context1 =
web::NavigationContextImpl::CreateNavigationContext(
web_state_impl_.get(), user_url,
/*has_user_gesture=*/true,
ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK,
/*is_renderer_initiated=*/true);
web_state_impl_->OnNavigationStarted(context1.get());
web::FakeNavigationContext context1;
context1.SetUrl(user_url);
web_state_impl_->OnNavigationStarted(&context1);
web::Referrer empty_referrer;
web_state_impl_->GetNavigationManagerImpl().AddPendingItem(
......@@ -252,13 +247,9 @@ class TabTest : public BlockCleanupTest,
web::NavigationInitiationType::RENDERER_INITIATED,
web::NavigationManager::UserAgentOverrideOption::INHERIT);
std::unique_ptr<web::NavigationContextImpl> context2 =
web::NavigationContextImpl::CreateNavigationContext(
web_state_impl_.get(), redirect_url,
/*has_user_gesture=*/true,
ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK,
/*is_renderer_initiated=*/true);
web_state_impl_->OnNavigationStarted(context2.get());
web::FakeNavigationContext context2;
context2.SetUrl(redirect_url);
web_state_impl_->OnNavigationStarted(&context2);
if (GetParam() == NavigationManagerChoice::WK_BASED) {
[fake_wk_list_
......@@ -266,9 +257,9 @@ class TabTest : public BlockCleanupTest,
}
web_state_impl_->GetNavigationManagerImpl().CommitPendingItem();
context2->SetHasCommitted(true);
context2.SetHasCommitted(true);
web_state_impl_->UpdateHttpResponseHeaders(redirect_url);
web_state_impl_->OnNavigationFinished(context2.get());
web_state_impl_->OnNavigationFinished(&context2);
web_state_impl_->SetIsLoading(true);
base::string16 new_title = base::SysNSStringToUTF16(title);
......
......@@ -58,7 +58,6 @@ source_set("wk_web_view_security_util") {
source_set("navigation_context") {
deps = [
"//base",
"//ios/web/navigation:core",
"//ios/web/public",
]
......
......@@ -85,10 +85,6 @@ class NavigationContextImpl : public NavigationContext {
bool IsNativeContentPresented() const;
void SetIsNativeContentPresented(bool is_native_content_presented);
// true if this navigation context is a placeholder navigation.
bool IsPlaceholderNavigation() const;
void SetPlaceholderNavigation(bool flag);
private:
NavigationContextImpl(WebState* web_state,
const GURL& url,
......@@ -113,7 +109,6 @@ class NavigationContextImpl : public NavigationContext {
bool is_loading_error_page_ = false;
bool is_loading_html_string_ = false;
bool is_native_content_presented_ = false;
bool is_placeholder_navigation_ = false;
DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl);
};
......
......@@ -175,14 +175,6 @@ void NavigationContextImpl::SetIsNativeContentPresented(
is_native_content_presented_ = is_native_content_presented;
}
bool NavigationContextImpl::IsPlaceholderNavigation() const {
return is_placeholder_navigation_;
}
void NavigationContextImpl::SetPlaceholderNavigation(bool flag) {
is_placeholder_navigation_ = flag;
}
NavigationContextImpl::NavigationContextImpl(WebState* web_state,
const GURL& url,
bool has_user_gesture,
......
......@@ -472,7 +472,7 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
// information about the navigation that triggered the document/URL change.
// TODO(stuartmorgan): The code conflates URL changes and document object
// changes; the two need to be separated and handled differently.
- (void)webPageChangedWithContext:(const web::NavigationContextImpl*)context;
- (void)webPageChangedWithContext:(const web::NavigationContext*)context;
// Resets any state that is associated with a specific document object (e.g.,
// page interaction tracking).
- (void)resetDocumentSpecificState;
......@@ -637,8 +637,7 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
- (std::unique_ptr<web::NavigationContextImpl>)
registerLoadRequestForURL:(const GURL&)URL
sameDocumentNavigation:(BOOL)sameDocumentNavigation
hasUserGesture:(BOOL)hasUserGesture
placeholderNavigation:(BOOL)placeholderNavigation;
hasUserGesture:(BOOL)hasUserGesture;
// Prepares web controller and delegates for anticipated page change.
// Allows several methods to invoke webWill/DidAddPendingURL on anticipated page
// change, using the same cached request and calculated transition types.
......@@ -648,8 +647,7 @@ registerLoadRequestForURL:(const GURL&)URL
referrer:(const web::Referrer&)referrer
transition:(ui::PageTransition)transition
sameDocumentNavigation:(BOOL)sameDocumentNavigation
hasUserGesture:(BOOL)hasUserGesture
placeholderNavigation:(BOOL)placeholderNavigation;
hasUserGesture:(BOOL)hasUserGesture;
// Maps WKNavigationType to ui::PageTransition.
- (ui::PageTransition)pageTransitionFromNavigationType:
(WKNavigationType)navigationType;
......@@ -1371,8 +1369,7 @@ GURL URLEscapedForHistory(const GURL& url) {
- (std::unique_ptr<web::NavigationContextImpl>)
registerLoadRequestForURL:(const GURL&)URL
sameDocumentNavigation:(BOOL)sameDocumentNavigation
hasUserGesture:(BOOL)hasUserGesture
placeholderNavigation:(BOOL)placeholderNavigation {
hasUserGesture:(BOOL)hasUserGesture {
// Get the navigation type from the last main frame load request, and try to
// map that to a PageTransition.
WKNavigationType navigationType =
......@@ -1387,8 +1384,7 @@ registerLoadRequestForURL:(const GURL&)URL
referrer:emptyReferrer
transition:transition
sameDocumentNavigation:sameDocumentNavigation
hasUserGesture:hasUserGesture
placeholderNavigation:placeholderNavigation];
hasUserGesture:(BOOL)hasUserGesture];
context->SetWKNavigationType(navigationType);
return context;
}
......@@ -1398,8 +1394,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:(const web::Referrer&)referrer
transition:(ui::PageTransition)transition
sameDocumentNavigation:(BOOL)sameDocumentNavigation
hasUserGesture:(BOOL)hasUserGesture
placeholderNavigation:(BOOL)placeholderNavigation {
hasUserGesture:(BOOL)hasUserGesture {
// Transfer time is registered so that further transitions within the time
// envelope are not also registered as links.
_lastTransferTimeInSeconds = CFAbsoluteTimeGetCurrent();
......@@ -1459,7 +1454,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
web::NavigationContextImpl::CreateNavigationContext(
_webStateImpl, requestURL, hasUserGesture, transition,
isRendererInitiated);
context->SetPlaceholderNavigation(placeholderNavigation);
// TODO(crbug.com/676129): LegacyNavigationManagerImpl::AddPendingItem does
// not create a pending item in case of reload. Remove this workaround once
......@@ -1800,9 +1794,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
// load for a provisional load failure. Rewrite the context URL to actual URL
// so the navigation event is broadcasted.
// TODO(crbug.com/803503) Clean up callbcks for native error.
if (context->IsPlaceholderNavigation()) {
if (IsPlaceholderUrl(context->GetUrl())) {
context->SetUrl(item->GetURL());
context->SetPlaceholderNavigation(false);
}
[self loadNativeViewWithSuccess:NO navigationContext:context];
_webStateImpl->SetIsLoading(false);
......@@ -1855,8 +1848,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:referrer
transition:self.currentTransition
sameDocumentNavigation:NO
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
[self loadNativeViewWithSuccess:YES
navigationContext:navigationContext.get()];
_loadPhase = web::PAGE_LOADED;
......@@ -1878,8 +1870,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
std::unique_ptr<web::NavigationContextImpl> navigationContext =
[self registerLoadRequestForURL:placeholderURL
sameDocumentNavigation:NO
hasUserGesture:NO
placeholderNavigation:YES];
hasUserGesture:NO];
[_navigationStates setContext:std::move(navigationContext)
forNavigation:navigation];
return [_navigationStates contextForNavigation:navigation];
......@@ -1912,8 +1903,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
std::unique_ptr<web::NavigationContextImpl> navigationContext =
[self registerLoadRequestForURL:item->GetURL()
sameDocumentNavigation:NO
hasUserGesture:NO
placeholderNavigation:NO];
hasUserGesture:NO];
WKNavigation* navigation =
[_webView loadHTMLString:@""
baseURL:net::NSURLWithGURL(item->GetURL())];
......@@ -2040,8 +2030,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:self.currentNavItemReferrer
transition:ui::PageTransition::PAGE_TRANSITION_RELOAD
sameDocumentNavigation:NO
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
navigationContext->SetIsRendererInitiated(isRendererInitiated);
_webStateImpl->OnNavigationStarted(navigationContext.get());
[self didStartLoading];
......@@ -2078,8 +2067,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:self.currentNavItemReferrer
transition:ui::PageTransition::PAGE_TRANSITION_RELOAD
sameDocumentNavigation:NO
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
[_navigationStates setContext:std::move(navigationContext)
forNavigation:navigation];
} else {
......@@ -2207,10 +2195,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
// placeholder URLs because this may be the only opportunity to update
// |isLoading| for native view reload.
if (context && context->IsPlaceholderNavigation())
return;
if (context && IsRestoreSessionUrl(context->GetUrl()))
if (context && IsWKInternalUrl(context->GetUrl()))
return;
if (IsRestoreSessionUrl(net::GURLWithNSURL(_webView.URL)))
......@@ -2927,7 +2912,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
// TODO(stuartmorgan): This method conflates document changes and URL changes;
// we should be distinguishing better, and be clear about the expected
// WebDelegate and WCO callbacks in each case.
- (void)webPageChangedWithContext:(const web::NavigationContextImpl*)context {
- (void)webPageChangedWithContext:(const web::NavigationContext*)context {
DCHECK_EQ(_loadPhase, web::LOAD_REQUESTED);
web::Referrer referrer = [self currentReferrer];
......@@ -2946,7 +2931,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
[self didStartLoading];
// Do not commit pending item in the middle of loading a placeholder URL. The
// item will be committed when the native content or webUI is displayed.
if (!context->IsPlaceholderNavigation()) {
if (!IsPlaceholderUrl(context->GetUrl())) {
self.navigationManagerImpl->CommitPendingItem();
}
}
......@@ -4189,8 +4174,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:web::Referrer()
transition:loadHTMLTransition
sameDocumentNavigation:NO
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:true];
}
context->SetIsRendererInitiated(false);
context->SetLoadingHtmlString(true);
......@@ -4386,11 +4370,10 @@ registerLoadRequestForURL:(const GURL&)requestURL
action.navigationType == WKNavigationTypeBackForward) {
// WKBackForwardList would have already been updated for back/forward
// navigation. Create the pending item here to match.
std::unique_ptr<web::NavigationContextImpl> context =
[self registerLoadRequestForURL:requestURL
sameDocumentNavigation:NO
hasUserGesture:[_pendingNavigationInfo hasUserGesture]
placeholderNavigation:IsPlaceholderUrl(requestURL)];
std::unique_ptr<web::NavigationContextImpl> context = [self
registerLoadRequestForURL:net::GURLWithNSURL(action.request.URL)
sameDocumentNavigation:NO
hasUserGesture:[_pendingNavigationInfo hasUserGesture]];
[_pendingNavigationInfo setPendingBackForwardContext:std::move(context)];
}
......@@ -4633,8 +4616,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
return;
}
if (context->GetUrl() != webViewURL &&
!context->IsPlaceholderNavigation()) {
if (context->GetUrl() != webViewURL) {
// Update last seen URL because it may be changed by WKWebView (f.e. by
// performing characters escaping).
web::NavigationItem* item = web::GetItemWithUniqueID(
......@@ -4693,8 +4675,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
std::unique_ptr<web::NavigationContextImpl> navigationContext =
[self registerLoadRequestForURL:webViewURL
sameDocumentNavigation:NO
hasUserGesture:[_pendingNavigationInfo hasUserGesture]
placeholderNavigation:IsPlaceholderUrl(webViewURL)];
hasUserGesture:[_pendingNavigationInfo hasUserGesture]];
_webStateImpl->OnNavigationStarted(navigationContext.get());
[_navigationStates setContext:std::move(navigationContext)
forNavigation:navigation];
......@@ -4843,8 +4824,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
// because redirect callback was not called.
if (@available(iOS 12, *)) {
// rdar://37547029 was fixed on iOS 12.
} else if (context && !context->IsPlaceholderNavigation() &&
context->GetUrl() != webViewURL) {
} else if (context && context->GetUrl() != webViewURL) {
[self didReceiveRedirectForNavigation:context withURL:webViewURL];
}
}
......@@ -4943,7 +4923,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
// Do not update the HTML5 history state or states of the last committed item
// for placeholder page because the actual navigation item will not be
// committed until the native content or WebUI is shown.
if (context && !context->IsPlaceholderNavigation() &&
if (context && !IsPlaceholderUrl(context->GetUrl()) &&
!context->GetUrl().SchemeIs(url::kAboutScheme)) {
[self updateSSLStatusForCurrentNavigationItem];
[self updateHTML5HistoryState];
......@@ -5306,8 +5286,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
std::unique_ptr<web::NavigationContextImpl> newContext =
[self registerLoadRequestForURL:webViewURL
sameDocumentNavigation:isSameDocumentNavigation
hasUserGesture:NO
placeholderNavigation:IsPlaceholderUrl(webViewURL)];
hasUserGesture:NO];
[self webPageChangedWithContext:newContext.get()];
newContext->SetHasCommitted(!isSameDocumentNavigation);
_webStateImpl->OnNavigationFinished(newContext.get());
......@@ -5554,8 +5533,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
// 4.) Back-forward same document navigation
newNavigationContext = [self registerLoadRequestForURL:newURL
sameDocumentNavigation:YES
hasUserGesture:NO
placeholderNavigation:NO];
hasUserGesture:NO];
// Use the current title for items created by same document navigations.
auto* pendingItem = self.navigationManagerImpl->GetPendingItem();
......@@ -5675,8 +5653,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:self.currentNavItemReferrer
transition:self.currentTransition
sameDocumentNavigation:sameDocumentNavigation
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
WKNavigation* navigation = [self loadPOSTRequest:request];
[_navigationStates setContext:std::move(navigationContext)
forNavigation:navigation];
......@@ -5694,8 +5671,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:self.currentNavItemReferrer
transition:self.currentTransition
sameDocumentNavigation:sameDocumentNavigation
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
navigationContext->SetIsRendererInitiated(false);
WKNavigation* navigation = [self loadRequest:request];
[_navigationStates setContext:std::move(navigationContext)
......@@ -5738,8 +5714,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
referrer:self.currentNavItemReferrer
transition:self.currentTransition
sameDocumentNavigation:sameDocumentNavigation
hasUserGesture:YES
placeholderNavigation:NO];
hasUserGesture:YES];
navigationContext->SetIsRendererInitiated(false);
WKNavigation* navigation = nil;
if (navigationURL == net::GURLWithNSURL([_webView URL])) {
......
......@@ -46,7 +46,7 @@ class BrowserState;
struct ContextMenuParams;
struct FaviconURL;
struct LoadCommittedDetails;
class NavigationContextImpl;
class NavigationContext;
class NavigationManager;
class SessionCertificatePolicyCacheImpl;
class WebInterstitialImpl;
......@@ -78,12 +78,12 @@ class WebStateImpl : public WebState, public NavigationManagerDelegate {
void SetWebController(CRWWebController* web_controller);
// Notifies the observers that a navigation has started.
void OnNavigationStarted(web::NavigationContextImpl* context);
void OnNavigationStarted(web::NavigationContext* context);
// Notifies the observers that a navigation has finished. For same-document
// navigations notifies the observers about favicon URLs update using
// candidates received in OnFaviconUrlUpdated.
void OnNavigationFinished(web::NavigationContextImpl* context);
void OnNavigationFinished(web::NavigationContext* context);
// Called when current window's canGoBack / canGoForward state was changed.
void OnBackForwardStateChanged();
......
......@@ -735,27 +735,23 @@ void WebStateImpl::TakeSnapshot(CGRect rect, SnapshotCallback callback) {
}];
}
void WebStateImpl::OnNavigationStarted(web::NavigationContextImpl* context) {
void WebStateImpl::OnNavigationStarted(web::NavigationContext* context) {
// Navigation manager loads internal URLs to restore session history and
// create back-forward entries for Native View and WebUI. Do not trigger
// external callbacks.
if (context->IsPlaceholderNavigation() ||
wk_navigation_util::IsRestoreSessionUrl(context->GetUrl())) {
if (wk_navigation_util::IsWKInternalUrl(context->GetUrl()))
return;
}
for (auto& observer : observers_)
observer.DidStartNavigation(this, context);
}
void WebStateImpl::OnNavigationFinished(web::NavigationContextImpl* context) {
void WebStateImpl::OnNavigationFinished(web::NavigationContext* context) {
// Navigation manager loads internal URLs to restore session history and
// create back-forward entries for Native View and WebUI. Do not trigger
// external callbacks.
if (context->IsPlaceholderNavigation() ||
wk_navigation_util::IsRestoreSessionUrl(context->GetUrl())) {
if (wk_navigation_util::IsWKInternalUrl(context->GetUrl()))
return;
}
for (auto& observer : observers_)
observer.DidFinishNavigation(this, context);
......
......@@ -415,7 +415,7 @@ TEST_P(WebStateImplTest, ObserverTest) {
// Test that DidFinishNavigation() is called.
ASSERT_FALSE(observer->did_finish_navigation_info());
const GURL url("http://test");
std::unique_ptr<NavigationContextImpl> context =
std::unique_ptr<web::NavigationContext> context =
NavigationContextImpl::CreateNavigationContext(
web_state_.get(), url, /*has_user_gesture=*/true,
ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK,
......@@ -505,27 +505,22 @@ TEST_P(WebStateImplTest, ObserverTest) {
// Tests that placeholder navigations are not visible to WebStateObservers.
TEST_P(WebStateImplTest, PlaceholderNavigationNotExposedToObservers) {
TestWebStateObserver observer(web_state_.get());
GURL placeholder_url =
wk_navigation_util::CreatePlaceholderUrlForUrl(GURL("chrome://newtab"));
std::unique_ptr<NavigationContextImpl> context =
NavigationContextImpl::CreateNavigationContext(
web_state_.get(), placeholder_url,
/*has_user_gesture=*/true,
ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK,
/*is_renderer_initiated=*/true);
context->SetPlaceholderNavigation(true);
FakeNavigationContext context;
context.SetUrl(
wk_navigation_util::CreatePlaceholderUrlForUrl(GURL("chrome://newtab")));
// Test that OnPageLoaded() is not called.
web_state_->OnPageLoaded(placeholder_url, /*load_success=*/true);
web_state_->OnPageLoaded(context.GetUrl(), true /* load_success */);
EXPECT_FALSE(observer.load_page_info());
web_state_->OnPageLoaded(placeholder_url, /*load_success=*/false);
web_state_->OnPageLoaded(context.GetUrl(), false /* load_success */);
EXPECT_FALSE(observer.load_page_info());
// Test that OnNavigationStarted() is not called.
web_state_->OnNavigationStarted(context.get());
web_state_->OnNavigationStarted(&context);
EXPECT_FALSE(observer.did_start_navigation_info());
// Test that OnNavigationFinished() is not called.
web_state_->OnNavigationFinished(context.get());
web_state_->OnNavigationFinished(&context);
EXPECT_FALSE(observer.did_finish_navigation_info());
}
......@@ -671,12 +666,8 @@ TEST_P(WebStateImplTest, GlobalObserverTest) {
// Test that DidStartNavigation() is called.
EXPECT_FALSE(observer->did_start_navigation_called());
std::unique_ptr<NavigationContextImpl> context =
NavigationContextImpl::CreateNavigationContext(
web_state_.get(), GURL::EmptyGURL(), /*has_user_gesture=*/true,
ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK,
/*is_renderer_initiated=*/true);
web_state_->OnNavigationStarted(context.get());
FakeNavigationContext context;
web_state_->OnNavigationStarted(&context);
EXPECT_TRUE(observer->did_start_navigation_called());
// Test that WebStateDidStartLoading() is called.
......@@ -936,13 +927,9 @@ TEST_P(WebStateImplTest, FaviconUpdateForSameDocumentNavigations) {
auto observer = std::make_unique<TestWebStateObserver>(web_state_.get());
// No callback if icons has not been fetched yet.
std::unique_ptr<NavigationContextImpl> context =
NavigationContextImpl::CreateNavigationContext(
web_state_.get(), GURL::EmptyGURL(),
/*has_user_gesture=*/false, ui::PageTransition::PAGE_TRANSITION_LINK,
/*is_renderer_initiated=*/false);
context->SetIsSameDocument(true);
web_state_->OnNavigationFinished(context.get());
FakeNavigationContext context;
context.SetIsSameDocument(true);
web_state_->OnNavigationFinished(&context);
EXPECT_FALSE(observer->update_favicon_url_candidates_info());
// Callback is called when icons were fetched.
......@@ -955,7 +942,7 @@ TEST_P(WebStateImplTest, FaviconUpdateForSameDocumentNavigations) {
// Callback is now called after same-document navigation.
observer = std::make_unique<TestWebStateObserver>(web_state_.get());
web_state_->OnNavigationFinished(context.get());
web_state_->OnNavigationFinished(&context);
ASSERT_TRUE(observer->update_favicon_url_candidates_info());
ASSERT_EQ(1U,
observer->update_favicon_url_candidates_info()->candidates.size());
......@@ -972,14 +959,14 @@ TEST_P(WebStateImplTest, FaviconUpdateForSameDocumentNavigations) {
// Document change navigation does not call callback.
observer = std::make_unique<TestWebStateObserver>(web_state_.get());
context->SetIsSameDocument(false);
web_state_->OnNavigationFinished(context.get());
context.SetIsSameDocument(false);
web_state_->OnNavigationFinished(&context);
EXPECT_FALSE(observer->update_favicon_url_candidates_info());
// Previous candidates were invalidated by the document change. No callback
// if icons has not been fetched yet.
context->SetIsSameDocument(true);
web_state_->OnNavigationFinished(context.get());
context.SetIsSameDocument(true);
web_state_->OnNavigationFinished(&context);
EXPECT_FALSE(observer->update_favicon_url_candidates_info());
}
......
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