Bug 1435142 - Part 3: expose closeTabByDblclick to WebExtension. r?mixedpuppy draft
authorHector Zhao <bzhao@mozilla.com>
Tue, 06 Mar 2018 17:11:49 +0800
changeset 766602 7f36b6898940b74b0ddf233454d8e7356adb080a
parent 766601 2a48c1e6da56816dd44da0537dd79d208b2b9fd9
push id102369
push userbmo:bzhao@mozilla.com
push dateTue, 13 Mar 2018 05:08:06 +0000
reviewersmixedpuppy
bugs1435142
milestone61.0a1
Bug 1435142 - Part 3: expose closeTabByDblclick to WebExtension. r?mixedpuppy MozReview-Commit-ID: GVgDdNFP0qL
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
@@ -100,16 +100,26 @@ ExtensionPreferencesManager.addSetting("
     let returnObj = {};
     for (let pref of this.prefNames) {
       returnObj[pref] = value;
     }
     return returnObj;
   },
 });
 
+ExtensionPreferencesManager.addSetting("closeTabsByDoubleClick", {
+  prefNames: [
+    "browser.tabs.closeTabByDblclick",
+  ],
+
+  setCallback(value) {
+    return {[this.prefNames[0]]: value};
+  },
+});
+
 ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
   prefNames: [
     "ui.context_menus.after_mouseup",
   ],
 
   setCallback(value) {
     return {[this.prefNames[0]]: value === "mouseup"};
   },
@@ -216,16 +226,21 @@ 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");
           }),
+        closeTabsByDoubleClick: getSettingsAPI(
+          extension, "closeTabsByDoubleClick",
+          () => {
+            return Services.prefs.getBoolPref("browser.tabs.closeTabByDblclick");
+          }, undefined, false, ["android"]),
         contextMenuShowEvent: Object.assign(
           getSettingsAPI(
             extension, "contextMenuShowEvent",
             () => {
               if (AppConstants.platform === "win") {
                 return "mouseup";
               }
               let prefValue = Services.prefs.getBoolPref(
--- a/toolkit/components/extensions/schemas/browser_settings.json
+++ b/toolkit/components/extensions/schemas/browser_settings.json
@@ -112,16 +112,20 @@
       "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."
       },
+      "closeTabsByDoubleClick": {
+        "$ref": "types.Setting",
+        "description": "This boolean setting controls whether the selected tab can be closed with a double click."
+      },
       "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."
       },
--- a/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
@@ -25,16 +25,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.closeTabByDblclick": false,
     "browser.tabs.loadBookmarksInTabs": false,
     "browser.search.openintab": false,
     "network.proxy.type": proxySvc.PROXYCONFIG_SYSTEM,
     "network.proxy.http": "",
     "network.proxy.http_port": 0,
     "network.proxy.share_proxy_settings": false,
     "network.proxy.ftp": "",
     "network.proxy.ftp_port": 0,
@@ -159,16 +160,29 @@ add_task(async function test_browser_set
       "contextMenuShowEvent", "mousedown",
       {"ui.context_menus.after_mouseup": AppConstants.platform === "win"});
   } else {
     await testSetting(
       "contextMenuShowEvent", "mousedown",
       {"ui.context_menus.after_mouseup": false});
   }
 
+  if (AppConstants.platform === "android") {
+    await testNoOpSetting(
+      "closeTabsByDoubleClick", true,
+      {"browser.tabs.closeTabByDblclick": false});
+  } else {
+    await testSetting(
+      "closeTabsByDoubleClick", true,
+      {"browser.tabs.closeTabByDblclick": true});
+    await testSetting(
+      "closeTabsByDoubleClick", false,
+      {"browser.tabs.closeTabByDblclick": false});
+  }
+
   await testSetting(
     "openBookmarksInNewTabs", true,
     {"browser.tabs.loadBookmarksInTabs": true});
   await testSetting(
     "openBookmarksInNewTabs", false,
     {"browser.tabs.loadBookmarksInTabs": false});
 
   await testSetting(