Commit 9b9c4896 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Load restored tab when thumbnail is requested

Fixed: 1123994
Change-Id: I0f099ad8196ba2a967327bca569b535b0585e9f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388761
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804216}
parent 70b51586
...@@ -175,6 +175,8 @@ class ThumbnailTabHelper::TabStateTracker ...@@ -175,6 +175,8 @@ class ThumbnailTabHelper::TabStateTracker
// ThumbnailImage::Delegate: // ThumbnailImage::Delegate:
void ThumbnailImageBeingObservedChanged(bool is_being_observed) override { void ThumbnailImageBeingObservedChanged(bool is_being_observed) override {
capture_driver_.UpdateThumbnailVisibility(is_being_observed); capture_driver_.UpdateThumbnailVisibility(is_being_observed);
if (is_being_observed)
web_contents()->GetController().LoadIfNecessary();
} }
void PageReadinessChanged(PageReadiness readiness) { void PageReadinessChanged(PageReadiness readiness) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/resource_coordinator/session_restore_policy.h"
#include "chrome/browser/sessions/tab_loader_tester.h" #include "chrome/browser/sessions/tab_loader_tester.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
...@@ -77,9 +78,10 @@ class ThumbnailTabHelperBrowserTest : public InProcessBrowserTest { ...@@ -77,9 +78,10 @@ class ThumbnailTabHelperBrowserTest : public InProcessBrowserTest {
} }
#if BUILDFLAG(ENABLE_SESSION_SERVICE) #if BUILDFLAG(ENABLE_SESSION_SERVICE)
void SetMaxSimultaneousLoadsForTesting(TabLoader* tab_loader) { void ConfigureTabLoader(TabLoader* tab_loader) {
TabLoaderTester tester(tab_loader); TabLoaderTester tester(tab_loader);
tester.SetMaxSimultaneousLoadsForTesting(1); tester.SetMaxSimultaneousLoadsForTesting(1);
tester.SetMaxLoadedTabCountForTesting(1);
} }
#endif #endif
...@@ -172,14 +174,10 @@ IN_PROC_BROWSER_TEST_F(ThumbnailTabHelperBrowserTest, ...@@ -172,14 +174,10 @@ IN_PROC_BROWSER_TEST_F(ThumbnailTabHelperBrowserTest,
// with ENABLE_SESSION_SERVICE. // with ENABLE_SESSION_SERVICE.
#if BUILDFLAG(ENABLE_SESSION_SERVICE) #if BUILDFLAG(ENABLE_SESSION_SERVICE)
// Note that this code is mostly cribbed from the test: // On browser restore, some tabs may not be loaded. Requesting a
// TabRestoreTest.TabsFromRestoredWindowsAreLoadedGradually // thumbnail for one of these tabs should trigger load and capture.
// because we need to simulate a browser restore that doesn't reload all of the IN_PROC_BROWSER_TEST_F(ThumbnailTabHelperBrowserTest,
// tabs - and then ensure that we do get thumbnails when we watch the tabs that CapturesRestoredTabWhenRequested) {
// didn't load.
IN_PROC_BROWSER_TEST_F(
ThumbnailTabHelperBrowserTest,
WatchingThumbnailAfterBrowserRestoreCausesPageLoadAndProducesThumbnail) {
ui_test_utils::NavigateToURLWithDisposition( ui_test_utils::NavigateToURLWithDisposition(
browser(), url2_, WindowOpenDisposition::NEW_WINDOW, browser(), url2_, WindowOpenDisposition::NEW_WINDOW,
ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER);
...@@ -191,11 +189,10 @@ IN_PROC_BROWSER_TEST_F( ...@@ -191,11 +189,10 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ(kTabCount, browser2->tab_strip_model()->count()); EXPECT_EQ(kTabCount, browser2->tab_strip_model()->count());
CloseBrowserSynchronously(browser2); CloseBrowserSynchronously(browser2);
// When the tab loader is created configure it for this test. This ensures // Set up the tab loader to ensure tabs are left unloaded.
// that no more than 1 loading slot is used for the test. base::RepeatingCallback<void(TabLoader*)> callback =
base::RepeatingCallback<void(TabLoader*)> callback = base::BindRepeating( base::BindRepeating(&ThumbnailTabHelperBrowserTest::ConfigureTabLoader,
&ThumbnailTabHelperBrowserTest::SetMaxSimultaneousLoadsForTesting, base::Unretained(this));
base::Unretained(this));
TabLoaderTester::SetConstructionCallbackForTesting(&callback); TabLoaderTester::SetConstructionCallbackForTesting(&callback);
// Restore recently closed window. // Restore recently closed window.
...@@ -205,18 +202,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -205,18 +202,6 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ(kTabCount, browser2->tab_strip_model()->count()); EXPECT_EQ(kTabCount, browser2->tab_strip_model()->count());
EXPECT_EQ(kTabCount - 1, browser2->tab_strip_model()->active_index()); EXPECT_EQ(kTabCount - 1, browser2->tab_strip_model()->active_index());
// These two tabs should be loaded by TabLoader.
EnsureTabLoaded(browser2->tab_strip_model()->GetWebContentsAt(kTabCount - 1));
EnsureTabLoaded(browser2->tab_strip_model()->GetWebContentsAt(0));
// The following isn't necessary but just to be sure there is no any async
// task that could have an impact on the expectations below. Note that because
// we're on the browser main thread, tasks are executed in order, so this
// effectively flushes the queue.
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run();
// These tabs shouldn't want to be loaded. // These tabs shouldn't want to be loaded.
for (int tab_idx = 1; tab_idx < kTabCount - 1; ++tab_idx) { for (int tab_idx = 1; tab_idx < kTabCount - 1; ++tab_idx) {
......
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