summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorshishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 16:37:48 +0000
committershishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 16:37:48 +0000
commit42f027fbb1df8eeefea3cbf27855d94d46f0cf74 (patch)
treea0fd0780acf1f8d66e2c6d5a564685fe739e713f /chrome/browser
parentef0e5c7060337ef5d5787a8f190e4dcc9b002c89 (diff)
downloadchromium_src-42f027fbb1df8eeefea3cbf27855d94d46f0cf74.zip
chromium_src-42f027fbb1df8eeefea3cbf27855d94d46f0cf74.tar.gz
chromium_src-42f027fbb1df8eeefea3cbf27855d94d46f0cf74.tar.bz2
Fixing visibility transitions for Instant
BUG=101593 TEST=instant_browsertest Review URL: http://codereview.chromium.org/8373010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107585 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/instant/instant_browsertest.cc50
-rw-r--r--chrome/browser/instant/instant_loader.cc1
-rw-r--r--chrome/browser/ui/browser.cc7
3 files changed, 58 insertions, 0 deletions
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 8fa7c25..73203c5 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -59,6 +59,7 @@
#define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS
#define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox
#define MAYBE_PreloadsInstant DISABLED_PreloadsInstant
+#define MAYBE_PageVisibilityTest DISABLED_PageVisibilityTest
#define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled
#define MAYBE_IntranetPathLooksLikeSearch DISABLED_IntranetPathLooksLikeSearch
#else
@@ -81,6 +82,7 @@
#define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS
#define MAYBE_DontPersistSearchbox DontPersistSearchbox
#define MAYBE_PreloadsInstant PreloadsInstant
+#define MAYBE_PageVisibilityTest PageVisibilityTest
#define MAYBE_ExperimentEnabled ExperimentEnabled
#define MAYBE_IntranetPathLooksLikeSearch IntranetPathLooksLikeSearch
#endif
@@ -265,6 +267,14 @@ class InstantTest : public InProcessBrowserTest {
return browser()->instant()->GetPreviewContents() != NULL;
}
+ bool IsVisible(TabContents* tab_contents) {
+ std::string visibility;
+ if (!GetStringFromJavascript(tab_contents, "document.webkitVisibilityState",
+ &visibility))
+ return false;
+ return visibility == "visible";
+ }
+
// Returns the state of the search box as a string. This consists of the
// following:
// window.chrome.sv
@@ -898,6 +908,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_PreloadsInstant) {
// Instant should have a preview, but not display it.
EXPECT_TRUE(HasPreview());
EXPECT_FALSE(browser()->instant()->is_displayable());
+ EXPECT_FALSE(IsVisible(tab_contents->tab_contents()));
// Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper.
AddBlankTabAndShow(browser());
@@ -935,6 +946,45 @@ IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_IntranetPathLooksLikeSearch) {
EXPECT_FALSE(HasPreview());
}
+// Tests that the instant search page's visibility is set correctly.
+IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_PageVisibilityTest) {
+ ASSERT_TRUE(test_server()->Start());
+ EnableInstant();
+ ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html"));
+
+ // Initially navigate to the empty page which should be visible.
+ ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(""));
+ TabContents* initial_contents = browser()->GetSelectedTabContents();
+ EXPECT_TRUE(IsVisible(initial_contents));
+
+ // Type something for instant to trigger and wait for preview to navigate.
+ ASSERT_NO_FATAL_FAILURE(FindLocationBar());
+ location_bar_->FocusLocation(false);
+ SetupLocationBar();
+ SetupPreview();
+ SetLocationBarText("def");
+ TabContents* preview_contents =
+ browser()->instant()->GetPreviewContents()->tab_contents();
+ EXPECT_TRUE(IsVisible(preview_contents));
+ EXPECT_FALSE(IsVisible(initial_contents));
+
+ // Delete the user text we should show the previous page.
+ location_bar_->location_entry()->SetUserText(UTF8ToUTF16(""));
+ EXPECT_FALSE(IsVisible(preview_contents));
+ EXPECT_TRUE(IsVisible(initial_contents));
+
+ // Set the user text back and we should see the preview again.
+ location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def"));
+ EXPECT_TRUE(IsVisible(preview_contents));
+ EXPECT_FALSE(IsVisible(initial_contents));
+
+ // Commit the preview.
+ SendKey(ui::VKEY_RETURN);
+ EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents());
+ EXPECT_TRUE(IsVisible(preview_contents));
+}
+
+
// Tests the INSTANT experiment of the field trial.
class InstantFieldTrialInstantTest : public InstantTest {
public:
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index cfe62bb..143ceff 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -1076,6 +1076,7 @@ void InstantLoader::LoadInstantURL(TabContentsWrapper* tab_contents,
preview_contents_->controller().LoadURL(instant_url, GURL(), transition_type,
std::string());
RenderViewHost* host = preview_contents_->render_view_host();
+ preview_contents_->tab_contents()->HideContents();
// If user_text is empty, this must be a preload of the search homepage. In
// that case, send down a SearchBoxResize message, which will switch the page
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 5045060..4023c19 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -4387,10 +4387,17 @@ void Browser::OnStateChanged() {
void Browser::ShowInstant(TabContentsWrapper* preview_contents) {
DCHECK(instant_->tab_contents() == GetSelectedTabContentsWrapper());
window_->ShowInstant(preview_contents);
+
+ GetSelectedTabContents()->HideContents();
+ preview_contents->tab_contents()->ShowContents();
}
void Browser::HideInstant() {
window_->HideInstant();
+ if (GetSelectedTabContents())
+ GetSelectedTabContents()->ShowContents();
+ if (instant_->GetPreviewContents())
+ instant_->GetPreviewContents()->tab_contents()->HideContents();
}
void Browser::CommitInstant(TabContentsWrapper* preview_contents) {