Commit 5b94bd87 authored by Sreeja Kamishetty's avatar Sreeja Kamishetty Committed by Commit Bot

[bfcache] Fix failing navigation_controller_impl_browsertests

This CL disables back-forward cache for the tests which want
to cover scenarios without documents being preserved in the
cache and adds new tests which require to test the functionality
when BackForwardCache is enabled.

BUG=1102629

Change-Id: Ib26902c1a590d252030ec5d5105299cb0ef895c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354242Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Sreeja Kamishetty <sreejakshetty@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800043}
parent 3f767cdd
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/common/use_zoom_for_dsf_policy.h" #include "content/public/common/use_zoom_for_dsf_policy.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test.h"
...@@ -3332,6 +3333,12 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ...@@ -3332,6 +3333,12 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
// when we go back. // when we go back.
entry2->root_node()->children[0]->frame_entry->set_frame_unique_name("wrong"); entry2->root_node()->children[0]->frame_entry->set_frame_unique_name("wrong");
// With BackForwardCache page is restored from cache instead of getting
// recreated on history navigation, disable back-forward cache to force a
// reload and a URL fetch.
DisableBackForwardCacheForTesting(
contents(), content::BackForwardCache::TEST_ASSUMES_NO_CACHING);
// 4. Go back, recreating the iframe. The subframe entry won't be found, and // 4. Go back, recreating the iframe. The subframe entry won't be found, and
// we should fall back to the default URL. // we should fall back to the default URL.
{ {
...@@ -3423,6 +3430,12 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ...@@ -3423,6 +3430,12 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(0U, entry2->root_node()->children.size()); EXPECT_EQ(0U, entry2->root_node()->children.size());
// With BackForwardCache page is restored from cache instead of getting
// recreated on history navigation, disable back-forward cache to force a
// reload and a URL fetch.
DisableBackForwardCacheForTesting(
contents(), content::BackForwardCache::TEST_ASSUMES_NO_CACHING);
// 3. Go back, recreating the iframe. The subframe will have a new name this // 3. Go back, recreating the iframe. The subframe will have a new name this
// time, so we won't find a history item for it. We should let the new data // time, so we won't find a history item for it. We should let the new data
// URL be loaded into it, rather than clobbering it with an about:blank page. // URL be loaded into it, rather than clobbering it with an about:blank page.
...@@ -8498,6 +8511,13 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ...@@ -8498,6 +8511,13 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
// Perform a cross-site omnibox navigation. // Perform a cross-site omnibox navigation.
prev_host = curr_host; prev_host = curr_host;
prev_spare = curr_spare; prev_spare = curr_spare;
// With BackForwardCache the old process won't get deleted on navigation as it
// is still in use by the bfcached document, disable back-forward cache to
// ensure that the process gets deleted.
DisableBackForwardCacheForTesting(
contents(), content::BackForwardCache::TEST_ASSUMES_NO_CACHING);
RenderProcessHostWatcher prev_host_watcher( RenderProcessHostWatcher prev_host_watcher(
prev_host, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); prev_host, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION);
EXPECT_TRUE(NavigateToURL(shell(), second_url)); EXPECT_TRUE(NavigateToURL(shell(), second_url));
...@@ -8605,6 +8625,13 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ...@@ -8605,6 +8625,13 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
EXPECT_NE(initial_site_instance, EXPECT_NE(initial_site_instance,
root->current_frame_host()->GetSiteInstance()); root->current_frame_host()->GetSiteInstance());
// This test expects using different SiteInstance/URL when navigating back.
// This won't happen with BackForwardCache as document is restored directly
// instead of redirecting, disable back-forward cache to ensure that redirect
// happens on history navigation.
DisableBackForwardCacheForTesting(
contents(), content::BackForwardCache::TEST_ASSUMES_NO_CACHING);
// Back, which should redirect to |url3|. // Back, which should redirect to |url3|.
FrameNavigateParamsCapturer capturer(root); FrameNavigateParamsCapturer capturer(root);
shell()->web_contents()->GetController().GoBack(); shell()->web_contents()->GetController().GoBack();
...@@ -8767,6 +8794,12 @@ IN_PROC_BROWSER_TEST_P( ...@@ -8767,6 +8794,12 @@ IN_PROC_BROWSER_TEST_P(
window.domAutomationController.send('done'); window.domAutomationController.send('done');
};)")); };)"));
// With BackForwardCache, old RenderFrameHost won't enter pending deletion
// on navigation as it is stored in bfcache, disable back-forward cache to
// ensure that the RFH will enter pending deletion state.
DisableBackForwardCacheForTesting(
contents(), content::BackForwardCache::TEST_ASSUMES_NO_CACHING);
// Navigate the main frame cross-process and wait for the unload event to // Navigate the main frame cross-process and wait for the unload event to
// fire. // fire.
DOMMessageQueue dom_message_queue(frame); DOMMessageQueue dom_message_queue(frame);
......
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