Bug 1287007 - Mark all browserAction methods as async r=billm
authorRob Wu <rob@robwu.nl>
Fri, 02 Sep 2016 14:22:09 -0700
changeset 428699 7292a34a169eec162d65b515a2c306cdb7bd0872
parent 428698 1edf5fa29a435f02b78980580543261afbd8db24
child 428700 3ca8f3e64eebe2b6cdcf5a3ddab89572db4d9e18
push id33405
push userbcampen@mozilla.com
push dateMon, 24 Oct 2016 15:32:53 +0000
reviewersbillm
bugs1287007
milestone52.0a1
Bug 1287007 - Mark all browserAction methods as async r=billm E.g. browser.browserAction.enable(...).then(...) now works as expected. Removed a Promise.resolve() because that is the default. MozReview-Commit-ID: 4Shxtn0rjYH
browser/components/extensions/ext-browserAction.js
browser/components/extensions/schemas/browser_action.json
--- a/browser/components/extensions/ext-browserAction.js
+++ b/browser/components/extensions/ext-browserAction.js
@@ -456,17 +456,16 @@ extensions.registerSchemaAPI("browserAct
         return Promise.resolve(title);
       },
 
       setIcon: function(details) {
         let tab = details.tabId !== null ? TabManager.getTab(details.tabId, context) : null;
 
         let icon = IconDetails.normalize(details, extension, context);
         BrowserAction.for(extension).setProperty(tab, "icon", icon);
-        return Promise.resolve();
       },
 
       setBadgeText: function(details) {
         let tab = details.tabId !== null ? TabManager.getTab(details.tabId, context) : null;
 
         BrowserAction.for(extension).setProperty(tab, "badgeText", details.text);
       },
 
--- a/browser/components/extensions/schemas/browser_action.json
+++ b/browser/components/extensions/schemas/browser_action.json
@@ -63,31 +63,38 @@
         "description": "Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element)."
       }
     ],
     "functions": [
       {
         "name": "setTitle",
         "type": "function",
         "description": "Sets the title of the browser action. This shows up in the tooltip.",
+        "async": "callback",
         "parameters": [
           {
             "name": "details",
             "type": "object",
             "properties": {
               "title": {
                 "type": "string",
                 "description": "The string the browser action should display when moused over."
               },
               "tabId": {
                 "type": "integer",
                 "optional": true,
                 "description": "Limits the change to when a particular tab is selected. Automatically resets when the tab is closed."
               }
             }
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "getTitle",
         "type": "function",
         "description": "Gets the title of the browser action.",
         "async": "callback",
@@ -161,32 +168,39 @@
             "parameters": []
           }
         ]
       },
       {
         "name": "setPopup",
         "type": "function",
         "description": "Sets the html document to be opened as a popup when the user clicks on the browser action's icon.",
+        "async": "callback",
         "parameters": [
           {
             "name": "details",
             "type": "object",
             "properties": {
               "tabId": {
                 "type": "integer",
                 "optional": true,
                 "minimum": 0,
                 "description": "Limits the change to when a particular tab is selected. Automatically resets when the tab is closed."
               },
               "popup": {
                 "type": "string",
                 "description": "The html file to show in a popup.  If set to the empty string (''), no popup is shown."
               }
             }
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "getPopup",
         "type": "function",
         "description": "Gets the html document set as the popup for this browser action.",
         "async": "callback",
@@ -213,31 +227,38 @@
             ]
           }
         ]
       },
       {
         "name": "setBadgeText",
         "type": "function",
         "description": "Sets the badge text for the browser action. The badge is displayed on top of the icon.",
+        "async": "callback",
         "parameters": [
           {
             "name": "details",
             "type": "object",
             "properties": {
               "text": {
                 "type": "string",
                 "description": "Any number of characters can be passed, but only about four can fit in the space."
               },
               "tabId": {
                 "type": "integer",
                 "optional": true,
                 "description": "Limits the change to when a particular tab is selected. Automatically resets when the tab is closed."
               }
             }
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "getBadgeText",
         "type": "function",
         "description": "Gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned.",
         "async": "callback",
@@ -264,16 +285,17 @@
             ]
           }
         ]
       },
       {
         "name": "setBadgeBackgroundColor",
         "type": "function",
         "description": "Sets the background color for the badge.",
+        "async": "callback",
         "parameters": [
           {
             "name": "details",
             "type": "object",
             "properties": {
               "color": {
                 "description": "An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is <code>[255, 0, 0, 255]</code>. Can also be a string with a CSS value, with opaque red being <code>#FF0000</code> or <code>#F00</code>.",
                 "choices": [
@@ -282,16 +304,22 @@
                 ]
               },
               "tabId": {
                 "type": "integer",
                 "optional": true,
                 "description": "Limits the change to when a particular tab is selected. Automatically resets when the tab is closed."
               }
             }
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "getBadgeBackgroundColor",
         "type": "function",
         "description": "Gets the background color of the browser action.",
         "async": "callback",
@@ -318,37 +346,51 @@
             ]
           }
         ]
       },
       {
         "name": "enable",
         "type": "function",
         "description": "Enables the browser action for a tab. By default, browser actions are enabled.",
+        "async": "callback",
         "parameters": [
           {
             "type": "integer",
             "optional": true,
             "name": "tabId",
             "minimum": 0,
             "description": "The id of the tab for which you want to modify the browser action."
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "disable",
         "type": "function",
         "description": "Disables the browser action for a tab.",
+        "async": "callback",
         "parameters": [
           {
             "type": "integer",
             "optional": true,
             "name": "tabId",
             "minimum": 0,
             "description": "The id of the tab for which you want to modify the browser action."
+          },
+          {
+            "type": "function",
+            "name": "callback",
+            "optional": true,
+            "parameters": []
           }
         ]
       },
       {
         "name": "openPopup",
         "type": "function",
         "description": "Opens the extension popup window in the active window but does not grant tab permissions.",
         "unsupported": true,