Bug 1196032 - Don't show the urlbar search suggestions opt-in in private windows. r=mak

This commit is contained in:
Drew Willcoxon 2015-08-19 13:38:04 -07:00
Родитель 39d990834d
Коммит 55341c1c8e
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -130,6 +130,18 @@ add_task(function* enable() {
assertSuggestionsPresent(true);
});
add_task(function* privateWindow() {
// Since suggestions are disabled in private windows, the notification should
// not appear even when suggestions are otherwise enabled.
let win = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
win.gURLBar.blur();
win.gURLBar.focus();
yield promiseAutocompleteResultPopup("foo", win);
assertVisible(false, win);
win.gURLBar.blur();
yield BrowserTestUtils.closeWindow(win);
});
function assertSuggestionsPresent(expectedPresent) {
let controller = gURLBar.popup.input.controller;
let matchCount = controller.matchCount;
@ -147,9 +159,9 @@ function assertSuggestionsPresent(expectedPresent) {
Assert.equal(actualPresent, expectedPresent);
}
function assertVisible(visible) {
function assertVisible(visible, win=window) {
let style =
window.getComputedStyle(gURLBar.popup.searchSuggestionsNotification);
win.getComputedStyle(win.gURLBar.popup.searchSuggestionsNotification);
Assert.equal(style.visibility, visible ? "visible" : "collapse");
}

Просмотреть файл

@ -932,6 +932,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<property name="shouldShowSearchSuggestionsNotification" readonly="true">
<getter><![CDATA[
return !this._userMadeSearchSuggestionsChoice &&
!this.inPrivateContext &&
// When _urlbarFocused is true, tabbrowser would close the
// popup if it's opened here, so don't show the notification.
!gBrowser.selectedBrowser._urlbarFocused &&