diff options
author | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 23:19:58 +0000 |
---|---|---|
committer | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 23:19:58 +0000 |
commit | 6b551a9df86cb32ae1327707696dd7a92defd7b0 (patch) | |
tree | 9fdf3289c34cfec0a6a6d867ff2fe3bb3e5f0a11 | |
parent | 6cc1c341a431e06d95e38c1042bba71b570cd928 (diff) | |
download | chromium_src-6b551a9df86cb32ae1327707696dd7a92defd7b0.zip chromium_src-6b551a9df86cb32ae1327707696dd7a92defd7b0.tar.gz chromium_src-6b551a9df86cb32ae1327707696dd7a92defd7b0.tar.bz2 |
Add a test for the disposition of session restored tabs
Follow on for https://src.chromium.org/viewvc/chrome?revision=218548
which fixed various background tab issues related to visibility (see
for example bugs 118269, 142061, 155365 and 272962). Add a test case
for session restored tabs.
TEST=browser_tests --gtest_filter="SessionRestore*TabsHaveCorrectVisibilityState"
BUG=118269
Review URL: https://codereview.chromium.org/258283004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267371 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sessions/session_restore_browsertest.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index c3b7b76..67f3961 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -45,6 +45,7 @@ #include "content/public/browser/web_contents_view.h" #include "content/public/common/bindings_policy.h" #include "content/public/common/page_transition_types.h" +#include "content/public/test/browser_test_utils.h" #include "content/public/test/test_navigation_observer.h" #include "sync/protocol/session_specifics.pb.h" @@ -221,6 +222,51 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoredTabsShouldHaveRootWindow) { } #endif // USE_AURA +// Verify that restored tabs have correct disposition. Only one tab should +// have disposition->visibility state. +// (http://crbug.com/155365 http://crbug.com/118269) +IN_PROC_BROWSER_TEST_F(SessionRestoreTest, + RestoredTabsHaveCorrectVisibilityState) { + // Create tabs. + GURL test_page(ui_test_utils::GetTestUrl(base::FilePath(), + base::FilePath(FILE_PATH_LITERAL("tab-restore-visibilty.html")))); + ui_test_utils::NavigateToURLWithDisposition( + browser(), test_page, NEW_FOREGROUND_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + ui_test_utils::NavigateToURLWithDisposition( + browser(), test_page, NEW_BACKGROUND_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + + // Restart and session restore the tabs. + content::DOMMessageQueue message_queue; + Browser* restored = QuitBrowserAndRestore(browser(), 3); + for (int i = 0; i < 2; ++i) { + std::string message; + EXPECT_TRUE(message_queue.WaitForMessage(&message)); + EXPECT_EQ("\"READY\"", message); + } + + // There should be 3 restored tabs in the new browser. + TabStripModel* tab_strip_model = restored->tab_strip_model(); + const int tabs = tab_strip_model->count(); + ASSERT_EQ(3, tabs); + + // The middle tab only should have visible disposition. + for (int i = 0; i < tabs; ++i) { + content::WebContents* contents = tab_strip_model->GetWebContentsAt(i); + std::string document_visibility_state; + const char kGetStateJS[] = "window.domAutomationController.send(" + "window.document.visibilityState);"; + EXPECT_TRUE(content::ExecuteScriptAndExtractString( + contents, kGetStateJS, &document_visibility_state)); + if (i == 1) { + EXPECT_EQ("visible", document_visibility_state); + } else { + EXPECT_EQ("hidden", document_visibility_state); + } + } +} + #if defined(OS_CHROMEOS) // Verify that session restore does not occur when a user opens a browser window // when no other browser windows are open on ChromeOS. |