Bug 1336308: Part 1 - Fix the capitalization of innerWindowID properties. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Mon, 06 Feb 2017 11:55:53 -0800
changeset 340945 1fd5c80083bc2173955dd56bf9eb2663e8ad9bba
parent 340944 df0afcf0c3b6f0a225c4d5474f0e06cc93b29f3e
child 340946 46af1a86f5af07f8402541adbe70b4f1ee7171ae
push id86601
push usermaglione.k@gmail.com
push dateMon, 06 Feb 2017 20:27:30 +0000
treeherdermozilla-inbound@7129bea75942 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1336308
milestone54.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 1336308: Part 1 - Fix the capitalization of innerWindowID properties. r=aswan MozReview-Commit-ID: 1qp49K9zc40
browser/components/extensions/ext-browserAction.js
browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js
toolkit/components/extensions/ExtensionTabs.jsm
--- a/browser/components/extensions/ext-browserAction.js
+++ b/browser/components/extensions/ext-browserAction.js
@@ -216,17 +216,17 @@ BrowserAction.prototype = {
         break;
 
       case "mouseup":
         if (event.button == 0) {
           this.clearPopupTimeout();
           // If we have a pending pre-loaded popup, cancel it after we've waited
           // long enough that we can be relatively certain it won't be opening.
           if (this.pendingPopup) {
-            let {node} = this.widget.forWindow(window);
+            let node = window.gBrowser && this.widget.forWindow(window).node;
             if (isAncestorOrSelf(node, event.originalTarget)) {
               this.pendingPopupTimeout = setTimeout(() => this.clearPopup(),
                                                     POPUP_PRELOAD_TIMEOUT_MS);
             } else {
               this.clearPopup();
             }
           }
         }
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js
@@ -1,15 +1,17 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 let scriptPage = url => `<html><head><meta charset="utf-8"><script src="${url}"></script></head><body>${url}</body></html>`;
 
 add_task(function* testBrowserActionClickCanceled() {
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
+
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {
         "default_popup": "popup.html",
         "browser_style": true,
       },
       "permissions": ["activeTab"],
     },
@@ -22,17 +24,16 @@ add_task(function* testBrowserActionClic
   yield extension.startup();
 
   const {GlobalManager, Management: {global: {browserActionFor}}} = Cu.import("resource://gre/modules/Extension.jsm", {});
 
   let ext = GlobalManager.extensionMap.get(extension.id);
   let browserAction = browserActionFor(ext);
 
   let widget = getBrowserActionWidget(extension).forWindow(window);
-  let tab = window.gBrowser.selectedTab;
 
   // Test canceled click.
   EventUtils.synthesizeMouseAtCenter(widget.node, {type: "mousedown", button: 0}, window);
 
   isnot(browserAction.pendingPopup, null, "Have pending popup");
   is(browserAction.pendingPopup.window, window, "Have pending popup for the correct window");
 
   is(browserAction.pendingPopupTimeout, null, "Have no pending popup timeout");
@@ -71,16 +72,18 @@ add_task(function* testBrowserActionClic
 
   is(browserAction.pendingPopup, null, "Pending popup was cleared");
   is(browserAction.pendingPopupTimeout, null, "Pending popup timeout was cleared");
 
   yield promisePopupShown(getBrowserActionPopup(extension));
   yield closeBrowserAction(extension);
 
   yield extension.unload();
+
+  yield BrowserTestUtils.removeTab(tab);
 });
 
 add_task(function* testBrowserActionDisabled() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {
         "default_popup": "popup.html",
         "browser_style": true,
--- a/toolkit/components/extensions/ExtensionTabs.jsm
+++ b/toolkit/components/extensions/ExtensionTabs.jsm
@@ -28,31 +28,31 @@ const {
 } = ExtensionUtils;
 
 class TabBase {
   constructor(extension, tab, id) {
     this.extension = extension;
     this.tabManager = extension.tabManager;
     this.id = id;
     this.tab = tab;
-    this.activeTabWindowId = null;
+    this.activeTabWindowID = null;
   }
 
-  get innerWindowId() {
-    return this.browser.innerWindowId;
+  get innerWindowID() {
+    return this.browser.innerWindowID;
   }
 
   get hasTabPermission() {
     return this.extension.hasPermission("tabs") || this.hasActiveTabPermission;
   }
 
   get hasActiveTabPermission() {
     return (this.extension.hasPermission("activeTab") &&
-            this.activeTabWindowId !== null &&
-            this.activeTabWindowId === this.innerWindowId);
+            this.activeTabWindowID != null &&
+            this.activeTabWindowID === this.innerWindowID);
   }
 
   get incognito() {
     return PrivateBrowsingUtils.isBrowserPrivate(this.browser);
   }
 
   get _url() {
     return this.browser.currentURI.spec;
@@ -599,22 +599,22 @@ class TabManagerBase {
 
   addActiveTabPermission(tab) {
     if (this.extension.hasPermission("activeTab")) {
       // Note that, unlike Chrome, we don't currently clear this permission with
       // the tab navigates. If the inner window is revived from BFCache before
       // we've granted this permission to a new inner window, the extension
       // maintains its permissions for it.
       tab = this.getWrapper(tab);
-      tab.activeTabWindowId = tab.innerWindowId;
+      tab.activeTabWindowID = tab.innerWindowID;
     }
   }
 
   revokeActiveTabPermission(tab) {
-    this.getWrapper(tab).activeTabWindowId = null;
+    this.getWrapper(tab).activeTabWindowID = null;
   }
 
   // Returns true if the extension has the "activeTab" permission for this tab.
   // This is somewhat more permissive than the generic "tabs" permission, as
   // checked by |hasTabPermission|, in that it also allows programmatic script
   // injection without an explicit host permission.
   hasActiveTabPermission(tab) {
     return this.getWrapper(tab).hasActiveTabPermission;