Bug 1692303 - Flip default value to browser.ctrlTab.recentlyUsedOrder to false r=mstriemer,mconley,preferences-reviewers
authorBernard Igiri <bigiri@mozilla.com>
Fri, 26 Mar 2021 21:56:41 +0000
changeset 573341 75aeeb931c889373fed43d2bf39470be5f6c3900
parent 573340 611380247e15ee0e2238af6bd4ba4dfed7e4357a
child 573342 bef51c405b1f0ba979049f544c2de91615fca9a3
push id38325
push usercbrindusan@mozilla.com
push dateSat, 27 Mar 2021 09:43:11 +0000
treeherdermozilla-central@2c4ad7073241 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, mconley, preferences-reviewers
bugs1692303
milestone89.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 1692303 - Flip default value to browser.ctrlTab.recentlyUsedOrder to false r=mstriemer,mconley,preferences-reviewers Changed default Ctrl+Tab preference to false and added UI migration to reset it for users who haven't not used the feature before. Differential Revision: https://phabricator.services.mozilla.com/D109653
browser/app/profile/firefox.js
browser/base/content/browser-ctrlTab.js
browser/base/content/test/general/browser_ctrlTab.js
browser/base/content/test/general/browser_tabkeynavigation.js
browser/base/content/test/general/browser_visibleTabs_tabPreview.js
browser/base/content/test/webrtc/browser_tab_switch_warning.js
browser/components/BrowserGlue.jsm
browser/components/preferences/main.inc.xhtml
browser/components/preferences/main.js
browser/components/tests/unit/test_browserGlue_migration_ctrltab_recently_used_order.js
browser/components/tests/unit/xpcshell.ini
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -585,17 +585,17 @@ pref("browser.tabs.tooltipsShowPidAndAct
 pref("security.allow_eval_with_system_principal", false);
 pref("security.allow_eval_in_parent_process", false);
 
 pref("security.allow_parent_unrestricted_js_loads", false);
 
 // Unload tabs when available memory is running low
 pref("browser.tabs.unloadOnLowMemory", false);
 
-pref("browser.ctrlTab.recentlyUsedOrder", true);
+pref("browser.ctrlTab.sortByRecentlyUsed", false);
 
 // By default, do not export HTML at shutdown.
 // If true, at shutdown the bookmarks in your menu and toolbar will
 // be exported as HTML to the bookmarks.html file.
 pref("browser.bookmarks.autoExportHTML",          false);
 
 // The maximum number of daily bookmark backups to
 // keep in {PROFILEDIR}/bookmarkbackups. Special values:
@@ -1219,17 +1219,17 @@ pref("services.sync.prefs.sync.app.shiel
 // The addons prefs related to repository verification are intentionally
 // not synced for security reasons. If a system is compromised, a user
 // could weaken the pref locally, install an add-on from an untrusted
 // source, and this would propagate automatically to other,
 // uncompromised Sync-connected devices.
 pref("services.sync.prefs.sync.browser.contentblocking.category", true);
 pref("services.sync.prefs.sync.browser.contentblocking.features.strict", true);
 pref("services.sync.prefs.sync.browser.crashReports.unsubmittedCheck.autoSubmit2", true);
-pref("services.sync.prefs.sync.browser.ctrlTab.recentlyUsedOrder", true);
+pref("services.sync.prefs.sync.browser.ctrlTab.sortByRecentlyUsed", true);
 pref("services.sync.prefs.sync.browser.discovery.enabled", true);
 pref("services.sync.prefs.sync.browser.download.useDownloadDir", true);
 pref("services.sync.prefs.sync.browser.formfill.enable", true);
 pref("services.sync.prefs.sync.browser.link.open_newwindow", true);
 pref("services.sync.prefs.sync.browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", true);
 pref("services.sync.prefs.sync.browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", true);
 pref("services.sync.prefs.sync.browser.newtabpage.activity-stream.showSearch", true);
 pref("services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsored", true);
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -189,17 +189,17 @@ var ctrlTab = {
 
   uninit: function ctrlTab_uninit() {
     if (this._recentlyUsedTabs) {
       this._recentlyUsedTabs = null;
       this._init(false);
     }
   },
 
-  prefName: "browser.ctrlTab.recentlyUsedOrder",
+  prefName: "browser.ctrlTab.sortByRecentlyUsed",
   readPref: function ctrlTab_readPref() {
     var enable =
       Services.prefs.getBoolPref(this.prefName) &&
       !Services.prefs.getBoolPref(
         "browser.ctrlTab.disallowForScreenReaders",
         false
       );
 
--- a/browser/base/content/test/general/browser_ctrlTab.js
+++ b/browser/base/content/test/general/browser_ctrlTab.js
@@ -1,11 +1,11 @@
 add_task(async function() {
   await SpecialPowers.pushPrefEnv({
-    set: [["browser.ctrlTab.recentlyUsedOrder", true]],
+    set: [["browser.ctrlTab.sortByRecentlyUsed", true]],
   });
 
   BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.addTab(gBrowser);
 
   // While doing this test, we should make sure the selected tab in the tab
   // preview is not changed by mouse events.  That may happen after closing
@@ -180,17 +180,17 @@ add_task(async function() {
   }
 
   function isOpen() {
     return ctrlTab.isOpen;
   }
 
   function canOpen() {
     return (
-      Services.prefs.getBoolPref("browser.ctrlTab.recentlyUsedOrder") &&
+      Services.prefs.getBoolPref("browser.ctrlTab.sortByRecentlyUsed") &&
       gBrowser.tabs.length > 2
     );
   }
 
   function checkTabs(aTabs) {
     is(gBrowser.tabs.length, aTabs, "number of open tabs should be " + aTabs);
   }
 
--- a/browser/base/content/test/general/browser_tabkeynavigation.js
+++ b/browser/base/content/test/general/browser_tabkeynavigation.js
@@ -10,17 +10,17 @@ add_task(async function test() {
     "data:text/html,<html id='tab3'><body><button id='button3'>Tab 3</button></body></html>";
 
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage1);
   let browser1 = gBrowser.getBrowserForTab(tab1);
   let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage2);
   let tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage3);
 
   await SpecialPowers.pushPrefEnv({
-    set: [["browser.ctrlTab.recentlyUsedOrder", false]],
+    set: [["browser.ctrlTab.sortByRecentlyUsed", false]],
   });
 
   // Disable tab animations
   gReduceMotionOverride = true;
 
   gBrowser.selectedTab = tab1;
   browser1.focus();
 
--- a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
+++ b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({
-    set: [["browser.ctrlTab.recentlyUsedOrder", true]],
+    set: [["browser.ctrlTab.sortByRecentlyUsed", true]],
   });
 
   let [origTab] = gBrowser.visibleTabs;
   let tabOne = BrowserTestUtils.addTab(gBrowser);
   let tabTwo = BrowserTestUtils.addTab(gBrowser);
 
   // test the ctrlTab.tabList
   pressCtrlTab();
--- a/browser/base/content/test/webrtc/browser_tab_switch_warning.js
+++ b/browser/base/content/test/webrtc/browser_tab_switch_warning.js
@@ -14,17 +14,17 @@ const WARNING_PANEL_ID = "sharing-tabs-w
 const ALLOW_BUTTON_ID = "sharing-warning-proceed-to-tab";
 const DISABLE_WARNING_FOR_SESSION_CHECKBOX_ID =
   "sharing-warning-disable-for-session";
 const WINDOW_SHARING_HEADER_ID = "sharing-warning-window-panel-header";
 const SCREEN_SHARING_HEADER_ID = "sharing-warning-screen-panel-header";
 // The number of milliseconds we're willing to wait for the
 // warning panel before we decide that it's not coming.
 const WARNING_PANEL_TIMEOUT_MS = 1000;
-const CTRL_TAB_RUO_PREF = "browser.ctrlTab.recentlyUsedOrder";
+const CTRL_TAB_RUO_PREF = "browser.ctrlTab.sortByRecentlyUsed";
 
 /**
  * Common helper function that pretendToShareWindow and pretendToShareScreen
  * call into. Ensures that the first tab is selected, and then (optionally)
  * does the first "freebie" tab switch to the second tab.
  *
  * @param {boolean} doFirstTabSwitch - True if this function should take
  *   care of doing the "freebie" tab switch for you.
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -3127,17 +3127,17 @@ BrowserGlue.prototype = {
       );
     });
   },
 
   // eslint-disable-next-line complexity
   _migrateUI: function BG__migrateUI() {
     // Use an increasing number to keep track of the current migration state.
     // Completely unrelated to the current Firefox release number.
-    const UI_VERSION = 107;
+    const UI_VERSION = 108;
     const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
 
     if (!Services.prefs.prefHasUserValue("browser.migration.version")) {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
       this._isNewProfile = true;
       return;
     }
@@ -3701,16 +3701,39 @@ BrowserGlue.prototype = {
       let migrations = Services.prefs
         .getCharPref(kPref, "")
         .split(",")
         .filter(x => !!x);
       migrations.push("secure-mail");
       Services.prefs.setCharPref(kPref, migrations.join(","));
     }
 
+    if (currentUIVersion < 108) {
+      // Migrate old ctrlTab pref to new ctrlTab pref
+      let defaultValue = false;
+      let oldPrefName = "browser.ctrlTab.recentlyUsedOrder";
+      // Use old pref value if the user used Ctrl+Tab before, elsewise use new default value
+      if (Services.prefs.getBoolPref("browser.engagement.ctrlTab.has-used")) {
+        let newPrefValue = Services.prefs.getBoolPref(
+          oldPrefName,
+          defaultValue
+        );
+        Services.prefs.setBoolPref(
+          "browser.ctrlTab.sortByRecentlyUsed",
+          newPrefValue
+        );
+      } else {
+        Services.prefs.setBoolPref(
+          "browser.ctrlTab.sortByRecentlyUsed",
+          defaultValue
+        );
+      }
+      Services.prefs.clearUserPref(oldPrefName);
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _maybeShowDefaultBrowserPrompt() {
     Promise.all([
       DefaultBrowserCheck.willCheckDefaultBrowser(/* isStartupCheck */ true),
       ExperimentAPI.ready,
--- a/browser/components/preferences/main.inc.xhtml
+++ b/browser/components/preferences/main.inc.xhtml
@@ -63,17 +63,17 @@
 </groupbox>
 
 <!-- Tab preferences -->
 <groupbox data-category="paneGeneral"
           hidden="true">
     <label><html:h2 data-l10n-id="tabs-group-header"/></label>
 
     <checkbox id="ctrlTabRecentlyUsedOrder" data-l10n-id="ctrl-tab-recently-used-order"
-              preference="browser.ctrlTab.recentlyUsedOrder"/>
+              preference="browser.ctrlTab.sortByRecentlyUsed"/>
 
     <checkbox id="linkTargeting" data-l10n-id="open-new-link-as-tabs"
               preference="browser.link.open_newwindow"/>
 
     <checkbox id="warnCloseMultiple" data-l10n-id="warn-on-close-multiple-tabs"
               preference="browser.tabs.warnOnClose"/>
 
     <checkbox id="warnOpenMany" data-l10n-id="warn-on-open-many-tabs"
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -129,17 +129,17 @@ Preferences.addAll([
   browser.taskbar.previews.enable
   - true if tabs are to be shown in the Windows 7 taskbar
   */
 
   { id: "browser.link.open_newwindow", type: "int" },
   { id: "browser.tabs.loadInBackground", type: "bool", inverted: true },
   { id: "browser.tabs.warnOnClose", type: "bool" },
   { id: "browser.tabs.warnOnOpen", type: "bool" },
-  { id: "browser.ctrlTab.recentlyUsedOrder", type: "bool" },
+  { id: "browser.ctrlTab.sortByRecentlyUsed", type: "bool" },
 
   // CFR
   {
     id: "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons",
     type: "bool",
   },
   {
     id: "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features",
new file mode 100644
--- /dev/null
+++ b/browser/components/tests/unit/test_browserGlue_migration_ctrltab_recently_used_order.js
@@ -0,0 +1,92 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
+const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
+const RECENTLY_USED_ORDER_DEFAULT = false;
+const UI_VERSION = 107;
+
+const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
+  Ci.nsIObserver
+);
+
+add_task(async function has_not_used_ctrl_tab_and_its_off() {
+  Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
+  Services.prefs.setBoolPref("browser.engagement.ctrlTab.has-used", false);
+  Services.prefs.setBoolPref("browser.ctrlTab.recentlyUsedOrder", false);
+
+  // Simulate a migration.
+  gBrowserGlue.observe(
+    null,
+    TOPIC_BROWSERGLUE_TEST,
+    TOPICDATA_BROWSERGLUE_TEST
+  );
+
+  Assert.equal(
+    RECENTLY_USED_ORDER_DEFAULT,
+    Services.prefs.getBoolPref("browser.ctrlTab.sortByRecentlyUsed")
+  );
+});
+
+add_task(async function has_not_used_ctrl_tab_and_its_on() {
+  Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
+  Services.prefs.setBoolPref("browser.engagement.ctrlTab.has-used", false);
+  Services.prefs.setBoolPref("browser.ctrlTab.recentlyUsedOrder", true);
+
+  // Simulate a migration.
+  gBrowserGlue.observe(
+    null,
+    TOPIC_BROWSERGLUE_TEST,
+    TOPICDATA_BROWSERGLUE_TEST
+  );
+
+  Assert.equal(
+    RECENTLY_USED_ORDER_DEFAULT,
+    Services.prefs.getBoolPref("browser.ctrlTab.sortByRecentlyUsed")
+  );
+});
+
+add_task(async function has_used_ctrl_tab_and_its_off() {
+  Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
+  Services.prefs.setBoolPref("browser.engagement.ctrlTab.has-used", true);
+  Services.prefs.setBoolPref("browser.ctrlTab.recentlyUsedOrder", false);
+
+  // Simulate a migration.
+  gBrowserGlue.observe(
+    null,
+    TOPIC_BROWSERGLUE_TEST,
+    TOPICDATA_BROWSERGLUE_TEST
+  );
+
+  Assert.equal(
+    false,
+    Services.prefs.getBoolPref("browser.ctrlTab.sortByRecentlyUsed")
+  );
+});
+
+add_task(async function has_used_ctrl_tab_and_its_on() {
+  Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
+  Services.prefs.setBoolPref("browser.engagement.ctrlTab.has-used", true);
+  Services.prefs.setBoolPref("browser.ctrlTab.recentlyUsedOrder", true);
+
+  // Simulate a migration.
+  gBrowserGlue.observe(
+    null,
+    TOPIC_BROWSERGLUE_TEST,
+    TOPICDATA_BROWSERGLUE_TEST
+  );
+
+  Assert.equal(
+    true,
+    Services.prefs.getBoolPref("browser.ctrlTab.sortByRecentlyUsed")
+  );
+});
+
+registerCleanupFunction(() => {
+  Services.prefs.clearUserPref("browser.migration.version");
+  Services.prefs.clearUserPref("browser.engagement.ctrlTab.has-used");
+  Services.prefs.clearUserPref("browser.ctrlTab.recentlyUsedOrder");
+  Services.prefs.clearUserPref("browser.ctrlTab.sortByRecentlyUsed");
+});
--- a/browser/components/tests/unit/xpcshell.ini
+++ b/browser/components/tests/unit/xpcshell.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 head = head.js
 firefox-appdir = browser
 skip-if = toolkit == 'android'
 support-files =
   distribution.ini
 
+[test_browserGlue_migration_ctrltab_recently_used_order.js]
 [test_distribution.js]
 [test_distribution_cachedexistence.js]
 [test_browserGlue_migration_no_errors.js]
 [test_browserGlue_migration_social_cleanup.js]