Bug 1388066 - Fix message sender.tab when tabId is 0 on Firefox for Android. draft
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 10 Aug 2017 14:59:25 -0700
changeset 645655 4092ff015370ba60f56db33df08d2da69c229832
parent 645634 8a12a4fcdb0519ec686ec7ec31b6296429f9fb3e
child 645656 deee35958b6ff8999a3758cd1ee072d36b2beee9
push id73818
push userluca.greco@alcacoop.it
push dateSun, 13 Aug 2017 20:45:14 +0000
bugs1388066
milestone57.0a1
Bug 1388066 - Fix message sender.tab when tabId is 0 on Firefox for Android. MozReview-Commit-ID: DPu6EZVg1nN
mobile/android/components/extensions/ext-android.js
--- a/mobile/android/components/extensions/ext-android.js
+++ b/mobile/android/components/extensions/ext-android.js
@@ -1,28 +1,28 @@
 "use strict";
 
 XPCOMUtils.defineLazyModuleGetter(global, "EventEmitter",
                                   "resource://gre/modules/EventEmitter.jsm");
 
 // This function is pretty tightly tied to Extension.jsm.
 // Its job is to fill in the |tab| property of the sender.
 const getSender = (extension, target, sender) => {
-  let tabId;
+  let tabId = -1;
   if ("tabId" in sender) {
     // The message came from a privileged extension page running in a tab. In
     // that case, it should include a tabId property (which is filled in by the
     // page-open listener below).
     tabId = sender.tabId;
     delete sender.tabId;
   } else if (target instanceof Ci.nsIDOMXULElement) {
     tabId = tabTracker.getBrowserData(target).tabId;
   }
 
-  if (tabId) {
+  if (tabId != null && tabId >= 0) {
     let tab = extension.tabManager.get(tabId, null);
     if (tab) {
       sender.tab = tab.convert();
     }
   }
 };
 
 // Used by Extension.jsm