Commit 42408884 authored by kmadhusu@chromium.org's avatar kmadhusu@chromium.org

Added test to verify that onmostvisitedchange event is dispatched when an user...

Added test to verify that onmostvisitedchange event is dispatched when an user navigate from SRP to NTP.

Added InstantExtendedTest.DispatchMVChangeEventWhileNavigatingBackToNTP.

BUG=248683
TEST=none

Review URL: https://chromiumcodereview.appspot.com/17424004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208109 0039d316-1c4b-4281-b951-d872f2087c98
parent 0eecc254
......@@ -308,6 +308,8 @@ class InstantController : public InstantPage::Delegate,
SearchDoesntReuseInstantTabWithoutSupport);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
TypedSearchURLDoesntReuseInstantTab);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
DispatchMVChangeEventWhileNavigatingBackToNTP);
// Overridden from InstantPage::Delegate:
// TODO(shishir): We assume that the WebContent's current RenderViewHost is
......
......@@ -1639,3 +1639,52 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) {
active_tab = browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
}
// Flaky on Windows and Mac try bots.
#if defined(OS_CHROMEOS)
#define MAYBE_DispatchMVChangeEventWhileNavigatingBackToNTP DispatchMVChangeEventWhileNavigatingBackToNTP
#else
#define MAYBE_DispatchMVChangeEventWhileNavigatingBackToNTP DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP
#endif
IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
MAYBE_DispatchMVChangeEventWhileNavigatingBackToNTP) {
// Setup Instant.
ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
FocusOmniboxAndWaitForInstantNTPSupport();
// Open new tab. Preloaded NTP contents should have been used.
ui_test_utils::NavigateToURLWithDisposition(
browser(),
GURL(chrome::kChromeUINewTabURL),
NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
content::WebContents* active_tab =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(UpdateSearchState(active_tab));
EXPECT_EQ(1, on_most_visited_change_calls_);
content::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
// Set the text and press enter to navigate from NTP.
SetOmniboxText("Pen");
PressEnterAndWaitForNavigation();
EXPECT_EQ(ASCIIToUTF16("Pen"), omnibox()->GetText());
observer.Wait();
// Navigate back to NTP.
content::WindowedNotificationObserver back_observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
active_tab = browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(active_tab->GetController().CanGoBack());
active_tab->GetController().GoBack();
back_observer.Wait();
// Verify that onmostvisitedchange event is dispatched when we navigate from
// SRP to NTP.
active_tab = browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(UpdateSearchState(active_tab));
EXPECT_EQ(1, on_most_visited_change_calls_);
}
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