Fix a regression where the omnibox would re-enter extension keyword mode after

choosing a selection.

BUG=88552
TEST=see bug for repro


Review URL: http://codereview.chromium.org/7307033

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91780 0039d316-1c4b-4281-b951-d872f2087c98
parent 9a37fdf2
......@@ -461,8 +461,10 @@ void KeywordProvider::Observe(NotificationType type,
switch (type.value) {
case NotificationType::EXTENSION_OMNIBOX_INPUT_ENTERED:
// Input has been accepted, so we're done with this input session. Ensure
// we don't send the OnInputCancelled event.
// we don't send the OnInputCancelled event, or handle any more stray
// suggestions_ready events.
current_keyword_extension_id_.clear();
current_input_id_ = 0;
return;
case NotificationType::EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED: {
......
......@@ -200,3 +200,49 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
}
// Tests that the autocomplete popup doesn't reopen after accepting input for
// a given query.
// http://crbug.com/88552
IN_PROC_BROWSER_TEST_F(OmniboxApiTest, PopupStaysClosed) {
#if defined(TOOLKIT_GTK)
// Disable the timer because, on Lucid at least, it triggers resize/move
// behavior in the browser window, which dismisses the autocomplete popup
// before the results can be read.
static_cast<BrowserWindowGtk*>(
browser()->window())->DisableDebounceTimerForTests(true);
#endif
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(RunExtensionTest("omnibox")) << message_;
// The results depend on the TemplateURLService being loaded. Make sure it is
// loaded so that the autocomplete results are consistent.
WaitForTemplateURLServiceToLoad();
LocationBar* location_bar = GetLocationBar();
AutocompleteController* autocomplete_controller = GetAutocompleteController();
AutocompletePopupModel* popup_model =
GetLocationBar()->location_entry()->model()->popup_model();
// Input a keyword query and wait for suggestions from the extension.
autocomplete_controller->Start(
ASCIIToUTF16("keyword comman"), string16(), true, false, true,
AutocompleteInput::ALL_MATCHES);
WaitForAutocompleteDone(autocomplete_controller);
EXPECT_TRUE(autocomplete_controller->done());
EXPECT_TRUE(popup_model->IsOpen());
// Quickly type another query and accept it before getting suggestions back
// for the query. The popup will close after accepting input - ensure that it
// does not reopen when the extension returns its suggestions.
ResultCatcher catcher;
autocomplete_controller->Start(
ASCIIToUTF16("keyword command"), string16(), true, false, true,
AutocompleteInput::ALL_MATCHES);
location_bar->AcceptInput();
WaitForAutocompleteDone(autocomplete_controller);
EXPECT_TRUE(autocomplete_controller->done());
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
EXPECT_FALSE(popup_model->IsOpen());
}
......@@ -2,19 +2,19 @@
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
chrome.test.log("onInputChanged: " + text);
if (text != "suggestio")
return;
var desc = 'Description with style: <match>&lt;match&gt;</match>, ' +
'<dim>[dim]</dim>, <url>(url till end)</url>';
suggest([
{
content: text + "n1",
description: desc
},
{content: text + "n2", description: "description2"},
{content: text + "n3", description: "description3"},
]);
if (text == "suggestio") {
// First test, complete "suggestio"
var desc = 'Description with style: <match>&lt;match&gt;</match>, ' +
'<dim>[dim]</dim>, <url>(url till end)</url>';
suggest([
{content: text + "n1", description: desc},
{content: text + "n2", description: "description2"},
{content: text + "n3", description: "description3"},
]);
} else {
// Other tests, just provide a simple suggestion.
suggest([{content: text + " 1", description: "description"}]);
}
});
chrome.omnibox.onInputEntered.addListener(
......
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