Bug 1192347 - Don't show urlbar search suggestions opt-in until user types a query. r=Mossop

This commit is contained in:
Drew Willcoxon 2015-08-07 15:55:06 -07:00
parent a8eefc5829
commit 73557ea526
2 changed files with 22 additions and 42 deletions

View File

@ -23,29 +23,14 @@ add_task(function* prepare() {
});
});
add_task(function* focus_allSuggestionsDisabled() {
Services.prefs.setBoolPref(SUGGEST_ALL_PREF, false);
Services.prefs.setBoolPref(CHOICE_PREF, false);
gURLBar.blur();
gURLBar.focus();
Assert.ok(!gURLBar.popup.popupOpen, "popup should be closed");
yield promiseAutocompleteResultPopup("foo");
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(false);
});
add_task(function* focus_noChoiceMade() {
add_task(function* focus() {
// Focusing the urlbar used to open the popup in order to show the
// notification, but it doesn't anymore. Make sure it does not.
Services.prefs.setBoolPref(SUGGEST_ALL_PREF, true);
Services.prefs.setBoolPref(CHOICE_PREF, false);
gURLBar.blur();
gURLBar.focus();
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
gURLBar.blur();
Assert.ok(!gURLBar.popup.popupOpen, "popup should be closed");
gURLBar.focus();
Assert.ok(gURLBar.popup.popupOpen, "popup should be open again");
assertVisible(true);
Assert.ok(!gURLBar.popup.popupOpen, "popup should remain closed");
});
add_task(function* dismissWithoutResults() {
@ -53,6 +38,9 @@ add_task(function* dismissWithoutResults() {
Services.prefs.setBoolPref(CHOICE_PREF, false);
gURLBar.blur();
gURLBar.focus();
let popupPromise = promisePopupShown(gURLBar.popup);
gURLBar.openPopup();
yield popupPromise;
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
Assert.equal(gURLBar.popup._matchCount, 0, "popup should have no results");
@ -76,9 +64,9 @@ add_task(function* dismissWithResults() {
Services.prefs.setBoolPref(CHOICE_PREF, false);
gURLBar.blur();
gURLBar.focus();
yield promiseAutocompleteResultPopup("foo");
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
yield promiseAutocompleteResultPopup("foo");
Assert.ok(gURLBar.popup._matchCount > 0, "popup should have results");
let disableButton = document.getAnonymousElementByAttribute(
gURLBar.popup, "anonid", "search-suggestions-notification-disable"
@ -100,6 +88,7 @@ add_task(function* disable() {
Services.prefs.setBoolPref(CHOICE_PREF, false);
gURLBar.blur();
gURLBar.focus();
yield promiseAutocompleteResultPopup("foo");
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
let disableButton = document.getAnonymousElementByAttribute(

View File

@ -929,20 +929,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
false
]]></field>
<method name="_maybeShowSearchSuggestionsNotification">
<body><![CDATA[
let showNotification =
!this._userMadeSearchSuggestionsChoice &&
// When _urlbarFocused is true, tabbrowser would close the popup if
// it's opened here, so don't show the notification.
!gBrowser.selectedBrowser._urlbarFocused &&
Services.prefs.getBoolPref("browser.search.suggest.enabled") &&
this._prefs.getBoolPref("unifiedcomplete");
if (showNotification) {
this.popup.showSearchSuggestionsNotification(this, this);
}
]]></body>
</method>
<property name="shouldShowSearchSuggestionsNotification" readonly="true">
<getter><![CDATA[
return !this._userMadeSearchSuggestionsChoice &&
// When _urlbarFocused is true, tabbrowser would close the
// popup if it's opened here, so don't show the notification.
!gBrowser.selectedBrowser._urlbarFocused &&
Services.prefs.getBoolPref("browser.search.suggest.enabled") &&
this._prefs.getBoolPref("unifiedcomplete");
]]></getter>
</property>
</implementation>
@ -974,7 +970,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
if (event.originalTarget == this.inputField) {
this._hideURLTooltip();
this.formatValue();
this._maybeShowSearchSuggestionsNotification();
}
]]></handler>
@ -1643,11 +1638,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// to avoid impacting startup / new window performance
aInput.popup.hidden = false;
// The popup may already be open if it's showing the search
// suggestions notification. In that case, its footer visibility
// needs to be updated.
if (this.popupOpen) {
this._updateFooterVisibility();
if (aInput.shouldShowSearchSuggestionsNotification) {
this._showSearchSuggestionsNotification();
}
this._openAutocompletePopup(aInput, aElement);
@ -1663,7 +1655,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
</body>
</method>
<method name="showSearchSuggestionsNotification">
<method name="_showSearchSuggestionsNotification">
<parameter name="aInput"/>
<parameter name="aElement"/>
<body>
@ -1691,7 +1683,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this.classList.add("showSearchSuggestionsNotification");
this._updateFooterVisibility();
this.openAutocompletePopup(aInput, aElement);
]]>
</body>
</method>