Chromium Code Reviews| Index: chrome/browser/instant/instant_extended_browsertest.cc |
| diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc |
| index f0fc5143f6ea1b30c30654f6499c7fe5f927ff19..845339839b1ef7f54770e5694320bdda3edbc0ee 100644 |
| --- a/chrome/browser/instant/instant_extended_browsertest.cc |
| +++ b/chrome/browser/instant/instant_extended_browsertest.cc |
| @@ -4,7 +4,11 @@ |
| #include <sstream> |
| +#include "chrome/browser/extensions/extension_browsertest.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/favicon/favicon_tab_helper.h" |
| +#include "chrome/browser/history/history_types.h" |
| +#include "chrome/browser/history/top_sites.h" |
| #include "chrome/browser/instant/instant_commit_type.h" |
| #include "chrome/browser/instant/instant_ntp.h" |
| #include "chrome/browser/instant/instant_overlay.h" |
| @@ -12,20 +16,45 @@ |
| #include "chrome/browser/instant/instant_service_factory.h" |
| #include "chrome/browser/instant/instant_tab.h" |
| #include "chrome/browser/instant/instant_test_utils.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/themes/theme_service.h" |
| +#include "chrome/browser/themes/theme_service_factory.h" |
| +#include "chrome/browser/ui/omnibox/omnibox_view.h" |
| #include "chrome/browser/ui/search/search.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/browser/ui/webui/theme_source.h" |
| #include "chrome/common/chrome_notification_types.h" |
| +#include "chrome/common/thumbnail_score.h" |
| #include "chrome/common/url_constants.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/interactive_test_utils.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/render_process_host.h" |
| +#include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/site_instance.h" |
| +#include "content/public/browser/url_data_source.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_view.h" |
| +#include "content/public/common/bindings_policy.h" |
| #include "content/public/test/browser_test_utils.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| -class InstantExtendedTest : public InstantTestBase { |
| +namespace { |
| + |
| +// Creates a bitmap of the specified color. Caller takes ownership. |
| +gfx::Image CreateBitmap(SkColor color) { |
| + SkBitmap thumbnail; |
| + thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); |
| + thumbnail.allocPixels(); |
| + thumbnail.eraseColor(color); |
| + return gfx::Image::CreateFrom1xBitmap(thumbnail); // adds ref. |
| +} |
| + |
| +} // namespace |
| + |
| +class InstantExtendedTest : public InstantTestBase, |
| + public InProcessBrowserTest { |
| public: |
| InstantExtendedTest() |
| : on_most_visited_change_calls_(0), |
| @@ -35,21 +64,10 @@ class InstantExtendedTest : public InstantTestBase { |
| protected: |
| virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| chrome::search::EnableInstantExtendedAPIForTesting(); |
| - ASSERT_TRUE(https_test_server_.Start()); |
| - instant_url_ = https_test_server_. |
| - GetURL("files/instant_extended.html?strk=1&"); |
| - } |
| - |
| - void FocusOmniboxAndWaitForInstantSupport() { |
| - content::WindowedNotificationObserver ntp_observer( |
| - chrome::NOTIFICATION_INSTANT_NTP_SUPPORT_DETERMINED, |
| - content::NotificationService::AllSources()); |
| - content::WindowedNotificationObserver overlay_observer( |
| - chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, |
| - content::NotificationService::AllSources()); |
| - FocusOmnibox(); |
| - ntp_observer.Wait(); |
| - overlay_observer.Wait(); |
| + ASSERT_TRUE(https_test_server().Start()); |
| + GURL instant_url = https_test_server().GetURL( |
| + "files/instant_extended.html?strk=1&"); |
| + InstantTestBase::Init(instant_url); |
| } |
| std::string GetOmniboxText() { |
| @@ -88,14 +106,51 @@ class InstantExtendedTest : public InstantTestBase { |
| int first_most_visited_item_id_; |
| }; |
| +// Test class used to verify chrome-search: scheme and access policy from the |
| +// Instant overlay. This is a subclass of |ExtensionBrowserTest| because it |
| +// loads a theme that provides a background image. |
| +class InstantPolicyTest : public InstantTestBase, public ExtensionBrowserTest { |
| + public: |
| + InstantPolicyTest() {} |
| + |
| + protected: |
| + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| + chrome::search::EnableInstantExtendedAPIForTesting(); |
| + ASSERT_TRUE(https_test_server().Start()); |
| + GURL instant_url = https_test_server().GetURL( |
| + "files/instant_extended.html?strk=1&"); |
| + InstantTestBase::Init(instant_url); |
| + } |
| + |
| + void InstallThemeSource() { |
| + ThemeSource* theme = new ThemeSource(profile()); |
| + content::URLDataSource::Add(profile(), theme); |
| + } |
| + |
| + void InstallThemeAndVerify(const std::string& theme_dir, |
| + const std::string& theme_name) { |
| + const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); |
| + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| + theme_path, 1, ExtensionBrowserTest::browser())); |
| + const extensions::Extension* theme = |
| + ThemeServiceFactory::GetThemeForProfile( |
| + ExtensionBrowserTest::browser()->profile()); |
| + ASSERT_NE(static_cast<extensions::Extension*>(NULL), theme); |
| + ASSERT_EQ(theme->name(), theme_name); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); |
| +}; |
| + |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| EXPECT_TRUE(instant()->extended_enabled_); |
| } |
| // Test that Instant is preloaded when the omnibox is focused. |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| // Explicitly unfocus the omnibox. |
| EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| @@ -109,7 +164,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
| EXPECT_FALSE(instant()->GetPreviewContents()); |
| // Refocus the omnibox. The InstantController should've preloaded Instant. |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| EXPECT_TRUE(omnibox()->model()->has_focus()); |
| @@ -137,10 +192,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
| } |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| // Focus omnibox and confirm overlay isn't shown. |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| EXPECT_TRUE(preview_tab); |
| EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| @@ -155,7 +210,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| // Test that middle clicking on a suggestion opens the result in a new tab. |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| MiddleClickOnSuggestionOpensInNewTab) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| @@ -186,16 +241,15 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| // Check that the new tab URL is as expected. |
| content::WebContents* new_tab_contents = |
| browser()->tab_strip_model()->GetWebContentsAt(1); |
| - EXPECT_EQ(new_tab_contents->GetURL().spec(), instant_url_.spec()+"q=santa"); |
| + EXPECT_EQ(new_tab_contents->GetURL().spec(), instant_url().spec()+"q=santa"); |
| // Check that there are now two tabs. |
| EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| } |
| // Test that omnibox text is correctly set when overlay is committed with Enter. |
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| - OmniboxTextUponEnterCommit) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // The page will autocomplete once we set the omnibox value. |
| @@ -219,10 +273,9 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| } |
| // Test that omnibox text is correctly set when committed with focus lost. |
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| - OmniboxTextUponFocusLostCommit) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // Set autocomplete text (grey text). |
| EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); |
| @@ -248,7 +301,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| OmniboxTextUponFocusedCommittedSERP) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // Do a search and commit it. |
| @@ -276,8 +329,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| // This test simulates a search provider using the InstantExtended API to |
| // navigate through the suggested results and back to the original user query. |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| SetOmniboxTextAndWaitForInstantToShow("hello"); |
| EXPECT_EQ("hello", GetOmniboxText()); |
| @@ -314,7 +367,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { |
| // navigate through the suggested results and hitting escape to get back to the |
| // original user query. |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| SetOmniboxTextAndWaitForInstantToShow("hello"); |
| @@ -346,8 +399,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // NTP contents should be preloaded. |
| ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| @@ -357,8 +410,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // NTP contents should be preloaded. |
| ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| @@ -378,8 +431,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // NTP contents should be preloaded. |
| ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| @@ -399,8 +452,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // Explicitly unfocus the omnibox. |
| EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| @@ -420,8 +473,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // Open new tab. Preloaded NTP contents should have been used. |
| ui_test_utils::NavigateToURLWithDisposition( |
| @@ -434,9 +487,9 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { |
| EXPECT_TRUE(omnibox()->GetText().empty()); |
| } |
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoFaviconOnNewTabPage) { |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NoFaviconOnNewTabPage) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // Open new tab. Preloaded NTP contents should have been used. |
| @@ -461,10 +514,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoFaviconOnNewTabPage) { |
| } |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| // Focus omnibox and confirm overlay isn't shown. |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| EXPECT_TRUE(preview_tab); |
| EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| @@ -494,8 +547,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { |
| EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| - FocusOmniboxAndWaitForInstantSupport(); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| // The registered Instant render process should still exist. |
| EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| @@ -531,7 +584,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { |
| // Flaky: http://crbug.com/177516 |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| // Setup Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // Check that the uncommited ntp page and uncommited preview have unrelated |
| @@ -576,7 +629,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| // Tests that suggestions are sanity checked. |
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // Do not set gray text that is not a suffix of the query. |
| @@ -629,12 +682,12 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { |
| EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText()); |
| } |
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) { |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) { |
|
Charlie Reis
2013/03/02 04:41:09
Why is this disabled? Can you add a comment with
dhollowa
2013/03/04 18:39:35
I'm noticing flakes during my try-runs. This is a
|
| content::WindowedNotificationObserver observer( |
| chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
| content::NotificationService::AllSources()); |
| // Initialize Instant. |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| FocusOmniboxAndWaitForInstantSupport(); |
| // Get a handle to the NTP and the current state of the JS. |
| @@ -718,3 +771,121 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) { |
| // Make sure we have the same number of items as before. |
| EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { |
| + InstallThemeSource(); |
| + ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| + |
| + // The "Instant" New Tab should have access to chrome-search: scheme but not |
| + // chrome: scheme. |
| + ui_test_utils::NavigateToURLWithDisposition( |
| + browser(), |
| + GURL(chrome::kChromeUINewTabURL), |
| + NEW_FOREGROUND_TAB, |
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| + |
| + content::RenderViewHost* rvh = |
| + browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| + |
| + const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); |
| + const std::string search_url( |
| + "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); |
| + bool loaded = false; |
| + ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); |
| + EXPECT_FALSE(loaded) << chrome_url; |
| + ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); |
| + EXPECT_TRUE(loaded) << search_url; |
| +} |
| + |
| +#if defined(OS_LINUX) |
| +#define MAYBE_FaviconAccess DISABLED_FaviconAccess |
| +#else |
| +#define MAYBE_FaviconAccess FaviconAccess |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_FaviconAccess) { |
| + // Create a favicon. |
| + history::TopSites* top_sites = browser()->profile()->GetTopSites(); |
| + GURL url("http://www.google.com/foo.html"); |
| + gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); |
| + ThumbnailScore high_score(0.0, true, true, base::Time::Now()); |
| + EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); |
| + |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| + |
| + // The "Instant" New Tab should have access to chrome-search: scheme but not |
| + // chrome: scheme. |
| + ui_test_utils::NavigateToURLWithDisposition( |
| + browser(), |
| + GURL(chrome::kChromeUINewTabURL), |
| + NEW_FOREGROUND_TAB, |
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| + |
| + content::RenderViewHost* rvh = |
| + browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| + |
| + // Get the favicons. |
| + const std::string chrome_favicon_url( |
| + "chrome://favicon/largest/http://www.google.com/foo.html"); |
| + const std::string search_favicon_url( |
| + "chrome-search://favicon/largest/http://www.google.com/foo.html"); |
| + bool loaded = false; |
| + ASSERT_TRUE(LoadImage(rvh, chrome_favicon_url, &loaded)); |
| + EXPECT_FALSE(loaded) << chrome_favicon_url; |
| + ASSERT_TRUE(LoadImage(rvh, search_favicon_url, &loaded)); |
| + EXPECT_TRUE(loaded) << search_favicon_url; |
| +} |
| + |
| +// WebUIBindings should never be enabled on ANY Instant web contents. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnNTP) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| + |
| + ui_test_utils::NavigateToURLWithDisposition( |
| + browser(), |
| + GURL(chrome::kChromeUINewTabURL), |
| + NEW_FOREGROUND_TAB, |
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| + const content::WebContents* tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + |
| + // Instant-provided NTP should not have any bindings enabled. |
| + EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); |
| +} |
| + |
| +// WebUIBindings should never be enabled on ANY Instant web contents. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| + |
| + // Typing in the omnibox shows the overlay. |
| + SetOmniboxTextAndWaitForInstantToShow("query"); |
| + EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| + content::WebContents* preview = instant()->GetPreviewContents(); |
| + ASSERT_NE(static_cast<content::WebContents*>(NULL), preview); |
| + |
| + // Instant preview should not have any bindings enabled. |
| + EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings()); |
| +} |
| + |
| +// WebUIBindings should never be enabled on ANY Instant web contents. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantExtendedSupport(); |
| + |
| + // Typing in the omnibox shows the overlay. |
| + SetOmniboxTextAndWaitForInstantToShow("query"); |
| + content::WebContents* preview = instant()->GetPreviewContents(); |
| + EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| + // Commit the search by pressing Enter. |
| + browser()->window()->GetLocationBar()->AcceptInput(); |
| + EXPECT_TRUE(instant()->model()->mode().is_default()); |
| + const content::WebContents* tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_EQ(preview, tab); |
| + |
| + // The commited Instant page should not have any bindings enabled. |
| + EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); |
| +} |