Bug 1420974 - API to open bookmarks in new tab, r=mixedpuppy
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 28 Nov 2017 09:20:31 -0500
changeset 394239 5a46e18c726d10f37b48b564feae3997332c46ea
parent 394238 48af4f2082c7a5501eb75cb02bba25ea0f99c517
child 394240 77229a598e9fbcbbe1406e44e876ceb31dd7b6aa
push id56252
push userbsilverberg@mozilla.com
push dateWed, 29 Nov 2017 20:20:52 +0000
treeherderautoland@5a46e18c726d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1420974
milestone59.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 1420974 - API to open bookmarks in new tab, r=mixedpuppy This introduces browserSettings.openBookmarksInNewTabs which exposes the browser.tabs.loadBookmarksInTabs preference to extensions. MozReview-Commit-ID: AZlir2GoiCo
toolkit/components/extensions/ext-browserSettings.js
toolkit/components/extensions/schemas/browser_settings.json
toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
--- a/toolkit/components/extensions/ext-browserSettings.js
+++ b/toolkit/components/extensions/ext-browserSettings.js
@@ -80,33 +80,43 @@ ExtensionPreferencesManager.addSetting("
     let returnObj = {};
     for (let pref of this.prefNames) {
       returnObj[pref] = value;
     }
     return returnObj;
   },
 });
 
+ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
+  prefNames: [
+    "ui.context_menus.after_mouseup",
+  ],
+
+  setCallback(value) {
+    return {[this.prefNames[0]]: value === "mouseup"};
+  },
+});
+
 ExtensionPreferencesManager.addSetting("imageAnimationBehavior", {
   prefNames: [
     "image.animation_mode",
   ],
 
   setCallback(value) {
     return {[this.prefNames[0]]: value};
   },
 });
 
-ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
+ExtensionPreferencesManager.addSetting("openBookmarksInNewTabs", {
   prefNames: [
-    "ui.context_menus.after_mouseup",
+    "browser.tabs.loadBookmarksInTabs",
   ],
 
   setCallback(value) {
-    return {[this.prefNames[0]]: value === "mouseup"};
+    return {[this.prefNames[0]]: value};
   },
 });
 
 ExtensionPreferencesManager.addSetting("webNotificationsDisabled", {
   prefNames: [
     "permissions.default.desktop-notification",
   ],
 
@@ -126,32 +136,16 @@ this.browserSettings = class extends Ext
             return Services.prefs.getCharPref("dom.popup_allowed_events") != "";
           }),
         cacheEnabled: getSettingsAPI(extension,
           "cacheEnabled",
           () => {
             return Services.prefs.getBoolPref("browser.cache.disk.enable") &&
               Services.prefs.getBoolPref("browser.cache.memory.enable");
           }),
-        homepageOverride: getSettingsAPI(extension,
-          HOMEPAGE_OVERRIDE_SETTING,
-          () => {
-            return Services.prefs.getComplexValue(
-              HOMEPAGE_URL_PREF, Ci.nsIPrefLocalizedString).data;
-          }, undefined, true),
-        imageAnimationBehavior: getSettingsAPI(extension,
-          "imageAnimationBehavior",
-          () => {
-            return Services.prefs.getCharPref("image.animation_mode");
-          }),
-        newTabPageOverride: getSettingsAPI(extension,
-          NEW_TAB_OVERRIDE_SETTING,
-          () => {
-            return aboutNewTabService.newTabURL;
-          }, URL_STORE_TYPE, true),
         contextMenuShowEvent: Object.assign(
           getSettingsAPI(
             extension,
             "contextMenuShowEvent",
             () => {
               if (AppConstants.platform === "win") {
                 return "mouseup";
               }
@@ -171,16 +165,37 @@ this.browserSettings = class extends Ext
                    details.value === "mousedown")) {
                 return false;
               }
               return ExtensionPreferencesManager.setSetting(
                 extension.id, "contextMenuShowEvent", details.value);
             },
           }
         ),
+        homepageOverride: getSettingsAPI(extension,
+          HOMEPAGE_OVERRIDE_SETTING,
+          () => {
+            return Services.prefs.getComplexValue(
+              HOMEPAGE_URL_PREF, Ci.nsIPrefLocalizedString).data;
+          }, undefined, true),
+        imageAnimationBehavior: getSettingsAPI(extension,
+          "imageAnimationBehavior",
+          () => {
+            return Services.prefs.getCharPref("image.animation_mode");
+          }),
+        newTabPageOverride: getSettingsAPI(extension,
+          NEW_TAB_OVERRIDE_SETTING,
+          () => {
+            return aboutNewTabService.newTabURL;
+          }, URL_STORE_TYPE, true),
+        openBookmarksInNewTabs: getSettingsAPI(extension,
+          "openBookmarksInNewTabs",
+          () => {
+            return Services.prefs.getBoolPref("browser.tabs.loadBookmarksInTabs");
+          }),
         webNotificationsDisabled: getSettingsAPI(extension,
           "webNotificationsDisabled",
           () => {
             let prefValue =
               Services.prefs.getIntPref(
                 "permissions.default.desktop-notification", null);
             return prefValue === PERM_DENY_ACTION;
           }),
--- a/toolkit/components/extensions/schemas/browser_settings.json
+++ b/toolkit/components/extensions/schemas/browser_settings.json
@@ -39,31 +39,35 @@
       "allowPopupsForUserEvents": {
         "$ref": "types.Setting",
         "description": "Allows or disallows pop-up windows from opening in response to user events."
       },
       "cacheEnabled": {
         "$ref": "types.Setting",
         "description": "Enables or disables the browser cache."
       },
+      "contextMenuShowEvent": {
+        "$ref": "types.Setting",
+        "description": "Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent, which has possible values of <code>mouseup</code> and <code>mousedown</code>."
+      },
       "homepageOverride": {
         "$ref": "types.Setting",
         "description": "Returns the value of the overridden home page. Read-only."
       },
       "imageAnimationBehavior": {
         "$ref": "types.Setting",
         "description": "Controls the behaviour of image animation in the browser. This setting's value is of type ImageAnimationBehavior, defaulting to <code>normal</code>."
       },
       "newTabPageOverride": {
         "$ref": "types.Setting",
         "description": "Returns the value of the overridden new tab page. Read-only."
       },
-      "contextMenuShowEvent": {
+      "openBookmarksInNewTabs": {
         "$ref": "types.Setting",
-        "description": "Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent, which has possible values of <code>mouseup</code> and <code>mousedown</code>."
+        "description": "This boolean setting controls whether bookmarks are opened in the current tab or in a new tab."
       },
       "webNotificationsDisabled": {
         "$ref": "types.Setting",
         "description": "Disables webAPI notifications."
       }
     }
   }
 ]
--- a/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
@@ -24,16 +24,17 @@ add_task(async function test_browser_set
   // Create an object to hold the values to which we will initialize the prefs.
   const PREFS = {
     "browser.cache.disk.enable": true,
     "browser.cache.memory.enable": true,
     "dom.popup_allowed_events": Preferences.get("dom.popup_allowed_events"),
     "image.animation_mode": "none",
     "permissions.default.desktop-notification": PERM_UNKNOWN_ACTION,
     "ui.context_menus.after_mouseup": false,
+    "browser.tabs.loadBookmarksInTabs": false,
   };
 
   async function background() {
     browser.test.onMessage.addListener(async (msg, apiName, value) => {
       let apiObj = browser.browserSettings[apiName];
       let result = await apiObj.set({value});
       if (msg === "set") {
         browser.test.assertTrue(result, "set returns true.");
@@ -140,16 +141,23 @@ add_task(async function test_browser_set
     await testNoOpSetting("contextMenuShowEvent", "mousedown",
       {"ui.context_menus.after_mouseup": AppConstants.platform === "win"});
   } else {
     await testSetting(
       "contextMenuShowEvent", "mousedown",
       {"ui.context_menus.after_mouseup": false});
   }
 
+  await testSetting(
+    "openBookmarksInNewTabs", true,
+    {"browser.tabs.loadBookmarksInTabs": true});
+  await testSetting(
+    "openBookmarksInNewTabs", false,
+    {"browser.tabs.loadBookmarksInTabs": false});
+
   await extension.unload();
   await promiseShutdownManager();
 });
 
 add_task(async function test_bad_value() {
   async function background() {
     await browser.test.assertRejects(
       browser.browserSettings.contextMenuShowEvent.set({value: "bad"}),