Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8539)

Unified Diff: chrome/browser/ui/search/instant_extended_browsertest.cc

Issue 13963014: Local omnibox treats navsuggest suggestions as queries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/instant_extended_browsertest.cc
diff --git a/chrome/browser/ui/search/instant_extended_browsertest.cc b/chrome/browser/ui/search/instant_extended_browsertest.cc
index aebd5781a011eea21ac53c382e3438f9a6de9966..3a67d061ed60a5527393235323f0b58da0f9b7ac 100644
--- a/chrome/browser/ui/search/instant_extended_browsertest.cc
+++ b/chrome/browser/ui/search/instant_extended_browsertest.cc
@@ -7,6 +7,7 @@
#include "base/prefs/pref_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
@@ -811,6 +812,65 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
active_tab->GetRenderProcessHost()->GetID()));
}
+// Test that a search query will not be displayed for navsuggest queries.
+IN_PROC_BROWSER_TEST_F(
+ InstantExtendedTest, SearchQueryNotDisplayedForNavsuggest) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+
+ // Use only the local overlay.
+ instant()->SetInstantEnabled(true, true);
+
+ FocusOmniboxAndWaitForInstantExtendedSupport();
+ EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+
+ SetOmniboxTextAndWaitForOverlayToShow("face");
+
+ // Add a navsuggest suggestion.
+ instant()->SetSuggestions(
+ instant()->overlay()->contents(),
+ std::vector<InstantSuggestion>(
+ 1,
+ InstantSuggestion(ASCIIToUTF16("face"),
sreeram 2013/04/22 16:25:49 Please set a valid URL (e.g.: "http://www.facemash
+ INSTANT_COMPLETE_NOW,
samarth 2013/04/22 16:22:09 If you're setting INSTANT_COMPLETE_NOW (aka doing
+ INSTANT_SUGGESTION_URL,
+ ASCIIToUTF16("face"))));
+
+ // Create an event listener that opens the top suggestion in a new tab.
+ content::WebContents* overlay = instant()->GetOverlayContents();
+ int i = 0;
+ std::string nativeSuggestionString =
+ "chrome.embeddedSearch.searchBox.nativeSuggestions";
+ while (true) {
+ std::string nativeSuggestionsAtIndex =
+ nativeSuggestionString + "[" + base::IntToString(i) + "]";
+
+ // Break if this nativeSuggestions index doesn't exist.
+ bool indexExists;
+ EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionString +
+ ".hasOwnProperty('" + base::IntToString(i) + "')", &indexExists));
+ if (!indexExists)
+ break;
+
+ bool isSearchPropertyExists;
+ EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionsAtIndex +
+ ".hasOwnProperty('is_search')", &isSearchPropertyExists));
+
+ // Verify that if this is a search suggestion the type is not navsuggest.
+ if (isSearchPropertyExists) {
+ bool is_search;
+ EXPECT_TRUE(GetBoolFromJS(
+ overlay, nativeSuggestionsAtIndex + ".is_search", &is_search));
+
+ std::string type;
+ EXPECT_TRUE(
+ GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type));
+
+ EXPECT_FALSE(is_search && type == "navsuggest");
+ }
+ ++i;
+ }
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.
+}
+
// Verification of fix for BUG=176365. Ensure that each Instant WebContents in
// a tab uses a new BrowsingInstance, to avoid conflicts in the
// NavigationController.
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698