Backed out changeset 15e745e8ec74 (bug 1756162) for causing mochitest failures on browser_privacy_firefoxSuggest.js. CLOSED TREE
authorIulian Moraru <imoraru@mozilla.com>
Wed, 23 Feb 2022 03:53:19 +0200
changeset 608464 797882f5e83f572fe7428909e1371248d106ec51
parent 608463 82a58b494f745cee17f335848dac6fc69aee8e30
child 608465 56e0a1e5b84b080bb33f9bcf0d3f78a64ae630f4
push id158330
push userimoraru@mozilla.com
push dateWed, 23 Feb 2022 01:53:58 +0000
treeherderautoland@797882f5e83f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1756162
milestone99.0a1
backs out15e745e8ec7472bef6f455a222e961b731d31b70
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
Backed out changeset 15e745e8ec74 (bug 1756162) for causing mochitest failures on browser_privacy_firefoxSuggest.js. CLOSED TREE
browser/components/preferences/privacy.inc.xhtml
browser/components/preferences/privacy.js
browser/components/preferences/tests/browser_privacy_firefoxSuggest.js
--- a/browser/components/preferences/privacy.inc.xhtml
+++ b/browser/components/preferences/privacy.inc.xhtml
@@ -645,17 +645,17 @@
             preference="browser.urlbar.suggest.bookmark"/>
   <checkbox id="openpageSuggestion" data-l10n-id="addressbar-locbar-openpage-option"
             preference="browser.urlbar.suggest.openpage"/>
   <checkbox id="topSitesSuggestion"
             data-l10n-id="addressbar-locbar-shortcuts-option"
             preference="browser.urlbar.suggest.topsites"/>
   <checkbox id="enginesSuggestion" data-l10n-id="addressbar-locbar-engines-option"
             preference="browser.urlbar.suggest.engines"/>
-  <hbox id="firefoxSuggestBestMatchContainer" align="center" hidden="true">
+  <hbox id="firefoxSuggestBestMatchContainer" align="center">
     <checkbox id="firefoxSuggestBestMatch"
               class="tail-with-learn-more"
               data-l10n-id="addressbar-firefox-suggest-best-match-option"
               preference="browser.urlbar.suggest.bestmatch"/>
     <label id="firefoxSuggestBestMatchLearnMore"
            class="learnMore"
            is="text-link"
            data-l10n-id="addressbar-best-match-learn-more"/>
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -1993,21 +1993,16 @@ var gPrivacyPane = {
   /**
    * Updates the Firefox Suggest section (in the address bar section) depending
    * on whether the user is enrolled in a Firefox Suggest rollout.
    *
    * @param {boolean} [onInit]
    *   Pass true when calling this when initializing the pane.
    */
   _updateFirefoxSuggestSection(onInit = false) {
-    // Show the best match checkbox container as appropriate.
-    document.getElementById(
-      "firefoxSuggestBestMatchContainer"
-    ).hidden = !UrlbarPrefs.get("bestMatchEnabled");
-
     let container = document.getElementById("firefoxSuggestContainer");
 
     if (UrlbarPrefs.get("quickSuggestEnabled")) {
       // Update the l10n IDs of text elements.
       let l10nIdByElementId = {
         locationBarGroupHeader: "addressbar-header-firefox-suggest",
         locationBarSuggestionLabel: "addressbar-suggest-firefox-suggest",
       };
@@ -2017,16 +2012,21 @@ var gPrivacyPane = {
         element.dataset.l10nId = l10nId;
       }
 
       // Add the extraMargin class to the engine-prefs link.
       document
         .getElementById("openSearchEnginePreferences")
         .classList.add("extraMargin");
 
+      // Show the best match checkbox container as appropriate.
+      document.getElementById(
+        "firefoxSuggestBestMatchContainer"
+      ).hidden = !UrlbarPrefs.get("bestMatchEnabled");
+
       // Show the container.
       this._updateFirefoxSuggestInfoBox();
       container.removeAttribute("hidden");
     } else if (!onInit) {
       // Firefox Suggest is not enabled. This is the default, so to avoid
       // accidentally messing anything up, only modify the doc if we're being
       // called due to a change in the rollout-enabled status (!onInit).
       container.setAttribute("hidden", "true");
--- a/browser/components/preferences/tests/browser_privacy_firefoxSuggest.js
+++ b/browser/components/preferences/tests/browser_privacy_firefoxSuggest.js
@@ -3,17 +3,16 @@
 
 // This tests the Privacy pane's Firefox Suggest UI.
 
 "use strict";
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   UrlbarProviderQuickSuggest:
     "resource:///modules/UrlbarProviderQuickSuggest.jsm",
-  UrlbarQuickSuggest: "resource:///modules/UrlbarQuickSuggest.jsm",
 });
 
 XPCOMUtils.defineLazyGetter(this, "QuickSuggestTestUtils", () => {
   const { QuickSuggestTestUtils: module } = ChromeUtils.import(
     "resource://testing-common/QuickSuggestTestUtils.jsm"
   );
   module.init(this);
   registerCleanupFunction(() => module.uninit());
@@ -122,26 +121,22 @@ add_task(async function onlineToOffline(
 async function doVisibilityTest({
   initialScenario,
   initialExpectedVisibility,
   newScenario,
   newExpectedVisibility,
 }) {
   info(
     "Running visibility test: " +
-      JSON.stringify(
-        {
-          initialScenario,
-          initialExpectedVisibility,
-          newScenario,
-          newExpectedVisibility,
-        },
-        null,
-        2
-      )
+      JSON.stringify({
+        initialScenario,
+        initialExpectedVisibility,
+        newScenario,
+        newExpectedVisibility,
+      })
   );
 
   // Set the initial scenario.
   await QuickSuggestTestUtils.setScenario(initialScenario);
 
   Assert.equal(
     Services.prefs.getBoolPref("browser.urlbar.quicksuggest.enabled"),
     initialExpectedVisibility,
@@ -500,122 +495,83 @@ add_task(async function clickLearnMore()
     gBrowser.removeCurrentTab();
     gBrowser.selectedTab = prefsTab;
   }
 
   gBrowser.removeCurrentTab();
   await SpecialPowers.popPrefEnv();
 });
 
-// Tests the visibility of the best match checkbox based on the values of
-// `browser.urlbar.quicksuggest.enabled` and `browser.urlbar.bestMatch.enabled`.
-add_task(async function bestMatchVisibility() {
-  for (let initialQuickSuggest of [false, true]) {
-    for (let initialBestMatch of [false, true]) {
-      for (let newQuickSuggest of [false, true]) {
-        for (let newBestMatch of [false, true]) {
-          await doBestMatchVisibilityTest({
-            initialQuickSuggest,
-            initialBestMatch,
-            newQuickSuggest,
-            newBestMatch,
-          });
-        }
-      }
-    }
-  }
+// Tests the visibility of the best match checkbox when the best match feature is
+// initially disabled and is then enabled via preferences.
+add_task(async function bestMatchVisibility_falseToTrue() {
+  await doBestMatchVisibilityTest(false, true);
+});
+
+// Tests the visibility of the best match checkbox when the best match feature is
+// initially enabled and is then disabled via preferences.
+add_task(async function bestMatchVisibility_trueToFalse() {
+  await doBestMatchVisibilityTest(true, false);
 });
 
 /**
  * Runs a test that checks the visibility of the Firefox Suggest best match
- * checkbox. It does the following:
- *
- * 1. Sets the quick suggest and best match feature prefs
- * 2. Opens about:preferences and checks the visibility of the checkbox
- * 3. Sets the quick suggest and best match feature prefs again
- * 4. Checks the visibility of the checkbox again
+ * checkbox. It sets the best match feature pref, opens about:preferences and
+ * checks the visibility of the toggle, sets the feature pref again, and checks
+ * the visibility of the toggle again.
  *
- * @param {boolean} initialQuickSuggest
- *   The value to set for `browser.urlbar.quicksuggest.enabled` before
- *   about:preferences is opened.
- * @param {boolean} initialBestMatch
- *   The value to set for `browser.urlbar.bestMatch.enabled` before
- *   about:preferences is opened.
- * @param {boolean} newQuickSuggest
- *   The value to set for `browser.urlbar.quicksuggest.enabled` while
- *   about:preferences is open.
- * @param {boolean} newBestMatch
- *   The value to set for `browser.urlbar.bestMatch.enabled` while
- *   about:preferences is open.
+ * @param {boolean} initialEnabled
+ *   Whether to enable the best match feature before about:preferences is
+ *   opened.
+ * @param {boolean} newEnabled
+ *   Whether to enable the best match feature after about:preferences is
+ *   opened.
  */
-async function doBestMatchVisibilityTest({
-  initialQuickSuggest,
-  initialBestMatch,
-  newQuickSuggest,
-  newBestMatch,
-}) {
+async function doBestMatchVisibilityTest(initialEnabled, newEnabled) {
   info(
     "Running best match visibility test: " +
-      JSON.stringify(
-        {
-          initialQuickSuggest,
-          initialBestMatch,
-          newQuickSuggest,
-          newBestMatch,
-        },
-        null,
-        2
-      )
+      JSON.stringify({ initialEnabled, newEnabled })
   );
 
-  // Set the initial pref values.
-  Services.prefs.setBoolPref(
-    "browser.urlbar.quicksuggest.enabled",
-    initialQuickSuggest
-  );
-  Services.prefs.setBoolPref(
-    "browser.urlbar.bestMatch.enabled",
-    initialBestMatch
-  );
-  await UrlbarQuickSuggest.readyPromise;
+  // Set the initial enabled status.
+  await SpecialPowers.pushPrefEnv({
+    set: [["browser.urlbar.bestMatch.enabled", initialEnabled]],
+  });
 
   // Open prefs and check the initial visibility.
   await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
+
   let doc = gBrowser.selectedBrowser.contentDocument;
   let container = doc.getElementById(BEST_MATCH_CONTAINER_ID);
   Assert.equal(
     BrowserTestUtils.is_visible(container),
-    initialBestMatch,
+    initialEnabled,
     "The checkbox container has the expected initial visibility"
   );
 
-  // Set the new pref values.
-  Services.prefs.setBoolPref(
-    "browser.urlbar.quicksuggest.enabled",
-    newQuickSuggest
-  );
-  Services.prefs.setBoolPref("browser.urlbar.bestMatch.enabled", newBestMatch);
-  await UrlbarQuickSuggest.readyPromise;
+  // Set the new enabled status.
+  await SpecialPowers.pushPrefEnv({
+    set: [["browser.urlbar.bestMatch.enabled", newEnabled]],
+  });
 
   // Check visibility again.
   Assert.equal(
     BrowserTestUtils.is_visible(container),
-    newBestMatch,
-    "The checkbox container has the expected visibility after setting prefs"
+    newEnabled,
+    "The checkbox container has the expected visibility after setting enabled status"
   );
 
   // Clean up.
   gBrowser.removeCurrentTab();
-  Services.prefs.clearUserPref("browser.urlbar.quicksuggest.enabled");
-  Services.prefs.clearUserPref("browser.urlbar.bestMatch.enabled");
-  await UrlbarQuickSuggest.readyPromise;
+  await SpecialPowers.popPrefEnv();
+  await SpecialPowers.popPrefEnv();
 }
 
-// Tests the visibility of the best match checkbox when the best match feature
-// is enabled via a Nimbus experiment before about:preferences is opened.
+// Tests the visibility of the best match checkbox container when the best match feature is
+// enabled via a Nimbus experiment before about:preferences is opened.
 add_task(async function bestMatchVisibility_experiment_beforeOpen() {
   await QuickSuggestTestUtils.withExperiment({
     valueOverrides: {
       bestMatchEnabled: true,
     },
     callback: async () => {
       await openPreferencesViaOpenPreferencesAPI("privacy", {
         leaveOpen: true,
@@ -626,18 +582,18 @@ add_task(async function bestMatchVisibil
         BrowserTestUtils.is_visible(container),
         "The checkbox container is visible"
       );
       gBrowser.removeCurrentTab();
     },
   });
 });
 
-// Tests the visibility of the best match checkbox when the best match feature
-// is enabled via a Nimbus experiment after about:preferences is opened.
+// Tests the visibility of the best match checkbox container when the best match feature is
+// enabled via a Nimbus experiment after about:preferences is opened.
 add_task(async function bestMatchVisibility_experiment_afterOpen() {
   // Open prefs and check the initial visibility.
   await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
   let doc = gBrowser.selectedBrowser.contentDocument;
   let container = doc.getElementById(BEST_MATCH_CONTAINER_ID);
   Assert.ok(
     BrowserTestUtils.is_hidden(container),
     "The checkbox container is hidden initially"
@@ -701,18 +657,17 @@ add_task(async function bestMatchToggle(
   }
 
   // Clean up.
   Services.prefs.clearUserPref("browser.urlbar.suggest.bestmatch");
   gBrowser.removeCurrentTab();
   await SpecialPowers.popPrefEnv();
 });
 
-// Clicks the learn-more link for best match and checks the help page is opened
-// in a new tab.
+// Clicks the learn-more link for best match and checks the help page is opened in a new tab.
 add_task(async function clickBestMatchLearnMore() {
   await SpecialPowers.pushPrefEnv({
     set: [["browser.urlbar.bestMatch.enabled", true]],
   });
 
   await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
 
   const doc = gBrowser.selectedBrowser.contentDocument;