Bug 1473595 - Enable "Ctrl+Tab cycles through tabs in recently used order" feature by default in new profiles. draft
authorDão Gottwald <dao@mozilla.com>
Thu, 26 Jul 2018 11:13:34 +0200
changeset 822894 18631f0ed39732921c4988c43ec5eeda10461760
parent 822828 7ba07ef0e4532b644b812942aa38af4510dbc74f
child 822914 83b9bc59d745e240532b1ade57f8689b058880a7
push id117510
push userdgottwald@mozilla.com
push dateThu, 26 Jul 2018 09:13:58 +0000
bugs1473595
milestone63.0a1
Bug 1473595 - Enable "Ctrl+Tab cycles through tabs in recently used order" feature by default in new profiles. MozReview-Commit-ID: 5lmOj3k4tFf
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/components/nsBrowserGlue.js
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -469,17 +469,17 @@ pref("browser.tabs.extraDragSpace", fals
 // true   return to the tab that opened this tab (its owner)
 // false  return to the adjacent tab (old default)
 pref("browser.tabs.selectOwnerOnClose", true);
 
 pref("browser.tabs.showAudioPlayingIcon", true);
 // This should match Chromium's audio indicator delay.
 pref("browser.tabs.delayHidingAudioPlayingIconMS", 3000);
 
-pref("browser.ctrlTab.previews", false);
+pref("browser.ctrlTab.recentlyUsedOrder", true);
 
 // 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:
@@ -1145,17 +1145,17 @@ pref("services.sync.prefs.sync.accessibi
 pref("services.sync.prefs.sync.accessibility.typeaheadfind", true);
 pref("services.sync.prefs.sync.accessibility.typeaheadfind.linksonly", true);
 pref("services.sync.prefs.sync.addons.ignoreUserEnabledChanges", true);
 // 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.ctrlTab.previews", true);
+pref("services.sync.prefs.sync.browser.ctrlTab.recentlyUsedOrder", 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.enabled", true);
 pref("services.sync.prefs.sync.browser.newtabpage.pinned", true);
 pref("services.sync.prefs.sync.browser.offline-apps.notify", true);
 pref("services.sync.prefs.sync.browser.safebrowsing.phishing.enabled", true);
 pref("services.sync.prefs.sync.browser.safebrowsing.malware.enabled", true);
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -215,17 +215,17 @@ var ctrlTab = {
 
   uninit: function ctrlTab_uninit() {
     if (this._recentlyUsedTabs) {
       this._recentlyUsedTabs = null;
       this._init(false);
     }
   },
 
-  prefName: "browser.ctrlTab.previews",
+  prefName: "browser.ctrlTab.recentlyUsedOrder",
   readPref: function ctrlTab_readPref() {
     var enable =
       Services.prefs.getBoolPref(this.prefName) &&
       !Services.prefs.getBoolPref("browser.ctrlTab.disallowForScreenReaders", false);
 
     if (enable)
       this.init();
     else
--- a/browser/base/content/test/general/browser_ctrlTab.js
+++ b/browser/base/content/test/general/browser_ctrlTab.js
@@ -1,10 +1,10 @@
 add_task(async function() {
-  Services.prefs.setBoolPref("browser.ctrlTab.previews", true);
+  await SpecialPowers.pushPrefEnv({"set": [["browser.ctrlTab.recentlyUsedOrder", 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
   // the selected tab with ctrl+W.  Disable all mouse events to prevent it.
@@ -108,20 +108,16 @@ add_task(async function() {
     document.addEventListener("keypress", detectKeyEvent);
     await pressCtrlTab();
     document.removeEventListener("keypress", detectKeyEvent);
     ok(eventConsumed, "Ctrl+Tab consumed by the tabbed browser if one tab is open");
     is(focusedWindow, document.commandDispatcher.focusedWindow,
        "Ctrl+Tab doesn't change focus if one tab is open");
   }
 
-  // cleanup
-  if (Services.prefs.prefHasUserValue("browser.ctrlTab.previews"))
-    Services.prefs.clearUserPref("browser.ctrlTab.previews");
-
   /* private utility functions */
 
   function pressCtrlTab(aShiftKey) {
     let promise;
     if (!isOpen() && canOpen()) {
       promise = BrowserTestUtils.waitForEvent(ctrlTab.panel, "popupshown");
     } else {
       promise = BrowserTestUtils.waitForEvent(document, "keyup");
@@ -147,17 +143,18 @@ add_task(async function() {
     return promise;
   }
 
   function isOpen() {
     return ctrlTab.isOpen;
   }
 
   function canOpen() {
-    return Services.prefs.getBoolPref("browser.ctrlTab.previews") && gBrowser.tabs.length > 2;
+    return Services.prefs.getBoolPref("browser.ctrlTab.recentlyUsedOrder") &&
+           gBrowser.tabs.length > 2;
   }
 
   function checkTabs(aTabs) {
     is(gBrowser.tabs.length, aTabs, "number of open tabs should be " + aTabs);
   }
 
   function selectTabs(tabs) {
     tabs.forEach(function(index) {
--- a/browser/base/content/test/general/browser_tabkeynavigation.js
+++ b/browser/base/content/test/general/browser_tabkeynavigation.js
@@ -7,18 +7,20 @@ add_task(async function test() {
   let testPage2 = "data:text/html,<html id='tab2'><body><button id='button2'>Tab 2</button><script>function preventDefault(event) { event.preventDefault(); event.stopImmediatePropagation(); } window.addEventListener('keydown', preventDefault, true); window.addEventListener('keypress', preventDefault, true);</script></body></html>";
   let testPage3 = "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);
 
-  // Kill the animation for simpler test.
-  Services.prefs.setBoolPref("toolkit.cosmeticAnimations.enabled", false);
+  await SpecialPowers.pushPrefEnv({"set": [
+    ["toolkit.cosmeticAnimations.enabled", false],
+    ["browser.ctrlTab.recentlyUsedOrder", false],
+  ]});
 
   gBrowser.selectedTab = tab1;
   browser1.focus();
 
   is(gBrowser.selectedTab, tab1,
      "Tab1 should be activated");
   EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true });
   is(gBrowser.selectedTab, tab2,
@@ -146,11 +148,9 @@ add_task(async function test() {
       is(gBrowser.tabs.length, 3,
         "The count of tabs should be 3 since renaming key events shouldn't close other tabs");
   }
 
   gBrowser.selectedTab = tab3;
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeCurrentTab();
   }
-
-    Services.prefs.clearUserPref("toolkit.cosmeticAnimations.enabled");
 });
--- a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
+++ b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
@@ -1,14 +1,14 @@
 /* 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() {
-  Services.prefs.setBoolPref("browser.ctrlTab.previews", true);
+  await SpecialPowers.pushPrefEnv({"set": [["browser.ctrlTab.recentlyUsedOrder", true]]});
 
   let [origTab] = gBrowser.visibleTabs;
   let tabOne = BrowserTestUtils.addTab(gBrowser);
   let tabTwo = BrowserTestUtils.addTab(gBrowser);
 
   // test the ctrlTab.tabList
   pressCtrlTab();
   ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview");
@@ -22,19 +22,16 @@ add_task(async function test() {
   gBrowser.showOnlyTheseTabs([origTab, tabOne, tabTwo]);
   pressCtrlTab();
   ok(ctrlTab.isOpen, "With 3 tabs open, Ctrl+Tab does open the preview panel");
   releaseCtrl();
 
   // cleanup
   gBrowser.removeTab(tabOne);
   gBrowser.removeTab(tabTwo);
-
-  if (Services.prefs.prefHasUserValue("browser.ctrlTab.previews"))
-    Services.prefs.clearUserPref("browser.ctrlTab.previews");
 });
 
 function pressCtrlTab(aShiftKey) {
   EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey });
 }
 
 function releaseCtrl() {
   EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1808,17 +1808,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 = 69;
+    const UI_VERSION = 70;
     const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
 
     let currentUIVersion;
     if (Services.prefs.prefHasUserValue("browser.migration.version")) {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } else {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -2120,16 +2120,27 @@ BrowserGlue.prototype = {
       if (socialPrefs) {
         let socialPrefsArray = socialPrefs.getChildList("");
         for (let item of socialPrefsArray) {
           Services.prefs.clearUserPref("social." + item);
         }
       }
     }
 
+    if (currentUIVersion < 70) {
+      // Migrate old ctrl-tab pref to new one in existing profiles. (This code
+      // doesn't run at all in new profiles.)
+      Services.prefs.setBoolPref("browser.ctrlTab.recentlyUsedOrder",
+        Services.prefs.getBoolPref("browser.ctrlTab.previews", false));
+      Services.prefs.clearUserPref("browser.ctrlTab.previews");
+      // Remember that we migrated the pref in case we decide to flip it for
+      // these users.
+      Services.prefs.setBoolPref("browser.ctrlTab.migrated", true);
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _checkForDefaultBrowser() {
     // Perform default browser checking.
     if (!ShellService) {
       return;
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -138,17 +138,17 @@ Preferences.addAll([
   - 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.sessionstore.restore_on_demand", type: "bool" },
-  { id: "browser.ctrlTab.previews", type: "bool" },
+  { id: "browser.ctrlTab.recentlyUsedOrder", type: "bool" },
 
   // Fonts
   { id: "font.language.group", type: "wstring" },
 
   // Languages
   { id: "browser.translation.detectLanguage", type: "bool" },
 
   // General tab
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -72,17 +72,18 @@
 </groupbox>
 
 <!-- Tab preferences -->
 <groupbox data-category="paneGeneral"
           hidden="true">
     <caption><label data-l10n-id="tabs-group-header"/></caption>
 
     <checkbox id="ctrlTabRecentlyUsedOrder" data-l10n-id="ctrl-tab-recently-used-order"
-              preference="browser.ctrlTab.previews"/>
+              preference="browser.ctrlTab.recentlyUsedOrder"
+              oncommand="Services.prefs.clearUserPref('browser.ctrlTab.migrated');"/>
 
     <checkbox id="linkTargeting" data-l10n-id="open-new-link-as-tabs"
               preference="browser.link.open_newwindow"
               onsyncfrompreference="return gMainPane.readLinkTarget();"
               onsynctopreference="return gMainPane.writeLinkTarget();"/>
 
     <checkbox id="warnCloseMultiple" data-l10n-id="warn-on-close-multiple-tabs"
               preference="browser.tabs.warnOnClose"/>