Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/strings/string_number_conversions.h" | |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_result.h" | 15 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/favicon/favicon_tab_helper.h" | 20 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 browser()->tab_strip_model()->GetActiveWebContents(); | 805 browser()->tab_strip_model()->GetActiveWebContents(); |
| 805 EXPECT_TRUE(instant_service->IsInstantProcess( | 806 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 806 active_tab->GetRenderProcessHost()->GetID())); | 807 active_tab->GetRenderProcessHost()->GetID())); |
| 807 | 808 |
| 808 // Navigating elsewhere should not use the Instant render process. | 809 // Navigating elsewhere should not use the Instant render process. |
| 809 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 810 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 810 EXPECT_FALSE(instant_service->IsInstantProcess( | 811 EXPECT_FALSE(instant_service->IsInstantProcess( |
| 811 active_tab->GetRenderProcessHost()->GetID())); | 812 active_tab->GetRenderProcessHost()->GetID())); |
| 812 } | 813 } |
| 813 | 814 |
| 815 // Test that a search query will not be displayed for navsuggest queries. | |
| 816 IN_PROC_BROWSER_TEST_F( | |
| 817 InstantExtendedTest, SearchQueryNotDisplayedForNavsuggest) { | |
| 818 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | |
| 819 FocusOmniboxAndWaitForInstantExtendedSupport(); | |
| 820 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
| 821 | |
| 822 // Typing in the omnibox should show the overlay. | |
| 823 SetOmniboxTextAndWaitForOverlayToShow("cnn.com"); | |
| 824 | |
| 825 // Create an event listener that opens the top suggestion in a new tab. | |
| 826 content::WebContents* overlay = instant()->GetOverlayContents(); | |
| 827 int i = 0; | |
| 828 while (true) { | |
| 829 std::string nativeSuggestionsAtIndex = | |
| 830 "chrome.embeddedSearch.searchBox.nativeSuggestions[" + | |
| 831 base::IntToString(i) + "]"; | |
| 832 | |
| 833 if (!ExecuteScript(nativeSuggestionsAtIndex)) | |
| 834 break; | |
| 835 | |
| 836 if (ExecuteScript(nativeSuggestionsAtIndex+".is_search")) { | |
| 837 bool is_search; | |
| 838 EXPECT_TRUE(GetBoolFromJS( | |
| 839 overlay, nativeSuggestionsAtIndex+".is_search", &is_search)); | |
| 840 | |
| 841 std::string type; | |
| 842 EXPECT_TRUE( | |
| 843 GetStringFromJS(overlay, nativeSuggestionsAtIndex+".type", &type)); | |
| 844 | |
| 845 EXPECT_FALSE(is_search && type == "navsuggest"); | |
| 846 } | |
| 847 | |
| 848 ++i; | |
| 849 } | |
| 850 } | |
|
sreeram
2013/04/18 17:51:40
This test uses the server overlay. We don't send a
dougw
2013/04/19 01:11:09
Done.
| |
| 851 | |
| 814 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in | 852 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in |
| 815 // a tab uses a new BrowsingInstance, to avoid conflicts in the | 853 // a tab uses a new BrowsingInstance, to avoid conflicts in the |
| 816 // NavigationController. | 854 // NavigationController. |
| 817 // Flaky: http://crbug.com/177516 | 855 // Flaky: http://crbug.com/177516 |
| 818 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { | 856 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| 819 // Setup Instant. | 857 // Setup Instant. |
| 820 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 858 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 821 FocusOmniboxAndWaitForInstantExtendedSupport(); | 859 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 822 | 860 |
| 823 // Check that the uncommited ntp page and uncommited overlay have unrelated | 861 // Check that the uncommited ntp page and uncommited overlay have unrelated |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1660 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 1698 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1661 | 1699 |
| 1662 // Make the page send an unexpected suggestion. | 1700 // Make the page send an unexpected suggestion. |
| 1663 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" | 1701 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" |
| 1664 "handleOnChange();")); | 1702 "handleOnChange();")); |
| 1665 | 1703 |
| 1666 // Verify that the suggestion is ignored. | 1704 // Verify that the suggestion is ignored. |
| 1667 EXPECT_EQ("result 1", GetOmniboxText()); | 1705 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1668 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 1706 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1669 } | 1707 } |
| OLD | NEW |