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 | |
| 820 // Use only the local overlay. | |
| 821 instant()->SetInstantEnabled(true, true); | |
| 822 | |
| 823 FocusOmniboxAndWaitForInstantExtendedSupport(); | |
| 824 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
| 825 | |
| 826 SetOmniboxTextAndWaitForOverlayToShow("face"); | |
| 827 | |
| 828 // Add a navsuggest suggestion. | |
| 829 instant()->SetSuggestions( | |
| 830 instant()->overlay()->contents(), | |
| 831 std::vector<InstantSuggestion>( | |
| 832 1, | |
| 833 InstantSuggestion(ASCIIToUTF16("face"), | |
|
sreeram
2013/04/22 16:25:49
Please set a valid URL (e.g.: "http://www.facemash
| |
| 834 INSTANT_COMPLETE_NOW, | |
|
samarth
2013/04/22 16:22:09
If you're setting INSTANT_COMPLETE_NOW (aka doing
| |
| 835 INSTANT_SUGGESTION_URL, | |
| 836 ASCIIToUTF16("face")))); | |
| 837 | |
| 838 // Create an event listener that opens the top suggestion in a new tab. | |
| 839 content::WebContents* overlay = instant()->GetOverlayContents(); | |
| 840 int i = 0; | |
| 841 std::string nativeSuggestionString = | |
| 842 "chrome.embeddedSearch.searchBox.nativeSuggestions"; | |
| 843 while (true) { | |
| 844 std::string nativeSuggestionsAtIndex = | |
| 845 nativeSuggestionString + "[" + base::IntToString(i) + "]"; | |
| 846 | |
| 847 // Break if this nativeSuggestions index doesn't exist. | |
| 848 bool indexExists; | |
| 849 EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionString + | |
| 850 ".hasOwnProperty('" + base::IntToString(i) + "')", &indexExists)); | |
| 851 if (!indexExists) | |
| 852 break; | |
| 853 | |
| 854 bool isSearchPropertyExists; | |
| 855 EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionsAtIndex + | |
| 856 ".hasOwnProperty('is_search')", &isSearchPropertyExists)); | |
| 857 | |
| 858 // Verify that if this is a search suggestion the type is not navsuggest. | |
| 859 if (isSearchPropertyExists) { | |
| 860 bool is_search; | |
| 861 EXPECT_TRUE(GetBoolFromJS( | |
| 862 overlay, nativeSuggestionsAtIndex + ".is_search", &is_search)); | |
| 863 | |
| 864 std::string type; | |
| 865 EXPECT_TRUE( | |
| 866 GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type)); | |
| 867 | |
| 868 EXPECT_FALSE(is_search && type == "navsuggest"); | |
| 869 } | |
| 870 ++i; | |
| 871 } | |
|
sreeram
2013/04/22 16:25:49
I don't understand why you need this loop at all.
dougw
2013/04/26 18:38:54
A search-what-you-typed suggestion appears above t
samarth
2013/04/29 17:49:20
I think that's because the suggestions aren't in s
dougw
2013/04/29 21:57:07
Done.
| |
| 872 } | |
| 873 | |
| 814 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in | 874 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in |
| 815 // a tab uses a new BrowsingInstance, to avoid conflicts in the | 875 // a tab uses a new BrowsingInstance, to avoid conflicts in the |
| 816 // NavigationController. | 876 // NavigationController. |
| 817 // Flaky: http://crbug.com/177516 | 877 // Flaky: http://crbug.com/177516 |
| 818 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { | 878 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| 819 // Setup Instant. | 879 // Setup Instant. |
| 820 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 880 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 821 FocusOmniboxAndWaitForInstantExtendedSupport(); | 881 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 822 | 882 |
| 823 // Check that the uncommited ntp page and uncommited overlay have unrelated | 883 // 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()); | 1720 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1661 | 1721 |
| 1662 // Make the page send an unexpected suggestion. | 1722 // Make the page send an unexpected suggestion. |
| 1663 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" | 1723 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" |
| 1664 "handleOnChange();")); | 1724 "handleOnChange();")); |
| 1665 | 1725 |
| 1666 // Verify that the suggestion is ignored. | 1726 // Verify that the suggestion is ignored. |
| 1667 EXPECT_EQ("result 1", GetOmniboxText()); | 1727 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1668 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 1728 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1669 } | 1729 } |
| OLD | NEW |