Commit ac76b484 authored by rohitrao's avatar rohitrao Committed by Commit bot

Revert of Cleaned up old navigation code that did not use pending navigation...

Revert of Cleaned up old navigation code that did not use pending navigation item. (patchset #4 id:60001 of https://codereview.chromium.org/2751793002/ )

Reason for revert:
testReloadInterstitial is failing on an internal bot.  For an example, see build 4404 on the internal iphone10-simulator bot.

Original issue's description:
> Cleaned up old navigation code that did not use pending navigation item.
>
> Also removed PendingIndexNavigationDisabled experimental setting.
>
> BUG=692331,701717
> TEST=Back forward navigation works correctly.
>
> Review-Url: https://codereview.chromium.org/2751793002
> Cr-Commit-Position: refs/heads/master@{#457459}
> Committed: https://chromium.googlesource.com/chromium/src/+/2feaa058530953a2232e6128e16deb31192ad9d2

TBR=kkhorimoto@chromium.org,eugenebut@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=692331,701717

Review-Url: https://codereview.chromium.org/2759483002
Cr-Commit-Position: refs/heads/master@{#457519}
parent fd9de243
......@@ -76,6 +76,9 @@ bool IsPasswordGenerationEnabled();
// Whether the Payment Request API is enabled or not.
bool IsPaymentRequestEnabled();
// Whether the back-forward navigation uses pending index.
bool IsPendingIndexNavigationEnabled();
// Whether the Physical Web feature is enabled.
bool IsPhysicalWebEnabled();
......
......@@ -41,6 +41,8 @@ NSString* const kHeuristicsForPasswordGeneration =
@"HeuristicsForPasswordGeneration";
NSString* const kMDMIntegrationDisabled = @"MDMIntegrationDisabled";
NSString* const kOriginServerHost = @"AlternateOriginServerHost";
NSString* const kPendingIndexNavigationDisabled =
@"PendingIndexNavigationDisabled";
NSString* const kSafariVCSignInDisabled = @"SafariVCSignInDisabled";
NSString* const kWhatsNewPromoStatus = @"WhatsNewPromoStatus";
......@@ -199,6 +201,11 @@ bool IsPaymentRequestEnabled() {
base::CompareCase::INSENSITIVE_ASCII);
}
bool IsPendingIndexNavigationEnabled() {
return ![[NSUserDefaults standardUserDefaults]
boolForKey:kPendingIndexNavigationDisabled];
}
bool IsPhysicalWebEnabled() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableIOSPhysicalWeb)) {
......
......@@ -4,6 +4,16 @@
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Disable pending index navigation</string>
<key>Key</key>
<string>PendingIndexNavigationDisabled</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
......
......@@ -1319,6 +1319,10 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
return NO;
}
- (void)webWillFinishHistoryNavigation {
[parentTabModel_ notifyTabChanged:self];
}
- (void)webState:(web::WebState*)webState
didFinishNavigation:(web::NavigationContext*)navigation {
if (navigation->IsSameDocument()) {
......
......@@ -7,12 +7,14 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/public/test/response_providers/html_response_provider.h"
......@@ -173,6 +175,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL during
// pending back and forward navigations.
- (void)testBackForwardNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -219,6 +225,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL during
// pending navigations initialted from back history popover.
- (void)testHistoryNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -248,6 +258,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that stopping a pending Back navigation and reloading reloads committed
// URL, not pending URL.
- (void)testStoppingPendingBackNavigationAndReload {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -281,6 +295,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL during
// back forward navigations initiated with JS.
- (void)testJSBackForwardNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -326,6 +344,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL during go
// navigations initiated with JS.
- (void)testJSGoNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -372,6 +394,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL during go
// back navigation started with pending reload in progress.
- (void)testBackNavigationWithPendingReload {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -410,6 +436,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// back navigation initiated with pending renderer-initiated navigation in
// progress.
- (void)testBackNavigationWithPendingRendererInitiatedNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -440,6 +470,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// renderer-initiated navigation started with pending back navigation in
// progress.
- (void)testRendererInitiatedNavigationWithPendingBackNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Purge web view caches and pause the server to make sure that tests can
// verify omnibox state before server starts responding.
PurgeCachedWebViewPages();
......@@ -470,6 +504,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL if user
// issues 2 go back commands.
- (void)testDoubleBackNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Create 3rd entry in the history, to be able to go back twice.
[ChromeEarlGrey loadURL:_testURL3];
......@@ -501,6 +539,10 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tests that visible URL is always the same as last committed URL if page calls
// window.history.back() twice.
- (void)testDoubleBackJSNavigation {
if (!experimental_flags::IsPendingIndexNavigationEnabled()) {
EARL_GREY_TEST_SKIPPED(@"Pending Index Navigation experiment is disabled");
}
// Create 3rd entry in the history, to be able to go back twice.
[ChromeEarlGrey loadURL:_testURL3];
......
......@@ -84,12 +84,19 @@ void WebInterstitialImpl::DontProceed() {
// Clear the pending entry, since that's the page that's not being
// proceeded to.
GetWebStateImpl()->GetNavigationManager()->DiscardNonCommittedItems();
NavigationManager* nav_manager = GetWebStateImpl()->GetNavigationManager();
nav_manager->DiscardNonCommittedItems();
Hide();
GetDelegate()->OnDontProceed();
NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults];
if (![user_defaults boolForKey:@"PendingIndexNavigationDisabled"]) {
// Reload last committed entry.
nav_manager->Reload(ReloadType::NORMAL, true /* check_for_repost */);
}
delete this;
}
......
......@@ -58,6 +58,9 @@ class GURL;
- (void)webDidUpdateSessionForLoadWithParams:
(const web::NavigationManager::WebLoadParams&)params
wasInitialNavigation:(BOOL)initialNavigation;
// Called from finishHistoryNavigationFromEntry.
// TODO(crbug.com/692331): Remove this method and use |DidFinishNavigation|.
- (void)webWillFinishHistoryNavigation;
@optional
......
This diff is collapsed.
......@@ -50,6 +50,8 @@ using web::NavigationManagerImpl;
@interface CRWWebController (PrivateAPI)
@property(nonatomic, readwrite) web::PageDisplayState pageDisplayState;
- (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem
previousURL:(const GURL&)previousURL;
@end
@interface CountingObserver : NSObject<CRWWebControllerObserver>
......@@ -168,6 +170,72 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
base::scoped_nsobject<id> mock_web_view_;
};
#define MAKE_URL(url_string) GURL([url_string UTF8String])
TEST_F(CRWWebControllerTest, UrlForHistoryNavigation) {
NSArray* urls_without_fragments = @[
@"http://one.com", @"http://two.com/", @"http://three.com/bar",
@"http://four.com/bar/", @"five", @"/six", @"/seven/", @""
];
NSArray* fragments = @[ @"#", @"#bar" ];
NSMutableArray* urls_with_fragments = [NSMutableArray array];
for (NSString* url in urls_without_fragments) {
for (NSString* fragment in fragments) {
[urls_with_fragments addObject:[url stringByAppendingString:fragment]];
}
}
GURL previous_url;
web::NavigationItemImpl to_item;
// No start fragment: the end url is never changed.
for (NSString* start in urls_without_fragments) {
for (NSString* end in urls_with_fragments) {
previous_url = MAKE_URL(start);
to_item.SetURL(MAKE_URL(end));
EXPECT_EQ(MAKE_URL(end),
[web_controller() URLForHistoryNavigationToItem:&to_item
previousURL:previous_url]);
}
}
// Both contain fragments: the end url is never changed.
for (NSString* start in urls_with_fragments) {
for (NSString* end in urls_with_fragments) {
previous_url = MAKE_URL(start);
to_item.SetURL(MAKE_URL(end));
EXPECT_EQ(MAKE_URL(end),
[web_controller() URLForHistoryNavigationToItem:&to_item
previousURL:previous_url]);
}
}
for (unsigned start_index = 0; start_index < urls_with_fragments.count;
++start_index) {
NSString* start = urls_with_fragments[start_index];
for (unsigned end_index = 0; end_index < urls_without_fragments.count;
++end_index) {
NSString* end = urls_without_fragments[end_index];
previous_url = MAKE_URL(start);
if (start_index / 2 != end_index) {
// The URLs have nothing in common, they are left untouched.
to_item.SetURL(MAKE_URL(end));
EXPECT_EQ(
MAKE_URL(end),
[web_controller() URLForHistoryNavigationToItem:&to_item
previousURL:previous_url]);
} else {
// Start contains a fragment and matches end: An empty fragment is
// added.
to_item.SetURL(MAKE_URL(end));
EXPECT_EQ(
MAKE_URL([end stringByAppendingString:@"#"]),
[web_controller() URLForHistoryNavigationToItem:&to_item
previousURL:previous_url]);
}
}
}
}
// Tests that AllowCertificateError is called with correct arguments if
// WKWebView fails to load a page with bad SSL cert.
TEST_F(CRWWebControllerTest, SslCertError) {
......
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