Bug 1196032 - Don't show the urlbar search suggestions opt-in in private windows. r=mak
authorDrew Willcoxon <adw@mozilla.com>
Wed, 19 Aug 2015 13:38:04 -0700
changeset 258490 eba63213016d3d36110d2fcf53d97050f0e7495c
parent 258489 b7a37975cb98308a651a9b628d50c9df7f739b84
child 258491 c3438863c1738be6ea8d3e36b526836219db2456
push id29257
push userkwierso@gmail.com
push dateThu, 20 Aug 2015 19:28:18 +0000
treeherdermozilla-central@7a6cd1616542 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1196032
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1196032 - Don't show the urlbar search suggestions opt-in in private windows. r=mak
browser/base/content/test/general/browser_urlbarSearchSuggestionsNotification.js
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/test/general/browser_urlbarSearchSuggestionsNotification.js
+++ b/browser/base/content/test/general/browser_urlbarSearchSuggestionsNotification.js
@@ -125,16 +125,28 @@ add_task(function* enable() {
   assertSuggestionsPresent(true);
   gURLBar.blur();
   gURLBar.focus();
   // Suggestions should still be present in a new search of course.
   yield promiseAutocompleteResultPopup("bar");
   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;
   let actualPresent = false;
   for (let i = 0; i < matchCount; i++) {
     let url = controller.getValueAt(i);
     let [, type, paramStr] = url.match(/^moz-action:([^,]+),(.*)$/);
     let params = {};
@@ -142,19 +154,19 @@ function assertSuggestionsPresent(expect
       params = JSON.parse(paramStr);
     } catch (err) {}
     let isSuggestion = type == "searchengine" && "searchSuggestion" in params;
     actualPresent = actualPresent || isSuggestion;
   }
   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");
 }
 
 function promiseTransition() {
   return new Promise(resolve => {
     gURLBar.popup.addEventListener("transitionend", function onEnd() {
       gURLBar.popup.removeEventListener("transitionend", onEnd, true);
       // The urlbar needs to handle the transitionend first, but that happens
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -927,16 +927,17 @@ file, You can obtain one at http://mozil
 
       <field name="_userMadeSearchSuggestionsChoice"><![CDATA[
         false
       ]]></field>
 
       <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 &&
                  Services.prefs.getBoolPref("browser.search.suggest.enabled") &&
                  this._prefs.getBoolPref("unifiedcomplete");
         ]]></getter>
       </property>