Bug 1501294 - Stop returning some useless properties in a WebExtensions tab object; r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 07 Dec 2018 12:33:24 +1300
changeset 33860 c474610d2c81ffb2986c8f20dff94adb29f8d3e7
parent 33859 0e2cd56c3a6c626b0cd377d385f9a90f9646b2a9
child 33861 e993eb9d7c1b74cf3506fe74be8b44fa5dfac86e
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersmkmelin
bugs1501294
Bug 1501294 - Stop returning some useless properties in a WebExtensions tab object; r=mkmelin
mail/components/extensions/parent/ext-mail.js
mail/components/extensions/schemas/tabs.json
--- a/mail/components/extensions/parent/ext-mail.js
+++ b/mail/components/extensions/parent/ext-mail.js
@@ -499,16 +499,41 @@ class TabTracker extends TabTrackerBase 
 tabTracker = new TabTracker();
 windowTracker = new WindowTracker();
 Object.assign(global, { tabTracker, windowTracker });
 
 /**
  * Extension-specific wrapper around a Thunderbird tab.
  */
 class Tab extends TabBase {
+  /** Removes some useless properties from a tab object. */
+  convert(fallback) {
+    let result = super.convert(fallback);
+
+    // These properties are not useful to Thunderbird extensions and are not returned.
+    for (let key of [
+      "attention",
+      "audible",
+      "discarded",
+      "hidden",
+      "incognito",
+      "isArticle",
+      "isInReaderMode",
+      "lastAccessed",
+      "mutedInfo",
+      "pinned",
+      "sharingState",
+      "successorTabId",
+    ]) {
+      delete result[key];
+    }
+
+    return result;
+  }
+
   /** Returns the XUL browser for the tab. */
   get browser() {
     return getTabBrowser(this.nativeTab);
   }
 
   /** Returns the tabmail element for the tab. */
   get tabmail() {
     return this.browser.ownerDocument.getElementById("tabmail");
--- a/mail/components/extensions/schemas/tabs.json
+++ b/mail/components/extensions/schemas/tabs.json
@@ -28,17 +28,16 @@
         "type": "object",
         "properties": {
           "id": {"type": "integer", "minimum": -1, "optional": true, "description": "The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID, for example when querying foreign tabs using the $(ref:sessions) API, in which case a session ID may be present. Tab ID can also be set to $(ref:tabs.TAB_ID_NONE) for apps and devtools windows."},
           "index": {"type": "integer", "minimum": -1, "description": "The zero-based index of the tab within its window."},
           "windowId": {"type": "integer", "optional": true, "minimum": 0, "description": "The ID of the window the tab is contained within."},
           "selected": {"type": "boolean", "description": "Whether the tab is selected.", "deprecated": "Please use $(ref:tabs.Tab.highlighted).", "unsupported": true},
           "highlighted": {"type": "boolean", "description": "Whether the tab is highlighted. Works as an alias of active"},
           "active": {"type": "boolean", "description": "Whether the tab is active in its window. (Does not necessarily mean the window is focused.)"},
-          "lastAccessed": {"type": "integer", "optional": true, "description": "The last time the tab was accessed as the number of milliseconds since epoch."},
           "url": {"type": "string", "optional": true, "permissions": ["tabs"], "description": "The URL the tab is displaying. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission."},
           "title": {"type": "string", "optional": true, "permissions": ["tabs"], "description": "The title of the tab. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission."},
           "favIconUrl": {"type": "string", "optional": true, "permissions": ["tabs"], "description": "The URL of the tab's favicon. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission. It may also be an empty string if the tab is loading."},
           "status": {"type": "string", "optional": true, "description": "Either <em>loading</em> or <em>complete</em>."},
           "width": {"type": "integer", "optional": true, "description": "The width of the tab in pixels."},
           "height": {"type": "integer", "optional": true, "description": "The height of the tab in pixels."}
         }
       },