Bug 1287007 - Remove dead code draft
authorRob Wu <rob@robwu.nl>
Tue, 06 Sep 2016 15:50:50 -0700
changeset 428435 2cb89c1b0f273070d2279d94aa074507faeb576a
parent 428434 a14afbabb0f8454e01c66e6bd70530a1083ccd57
child 428436 2eac95f806a789f9e6bf42132a8e5a623de0573d
push id33305
push userbmo:rob@robwu.nl
push dateSun, 23 Oct 2016 20:56:25 +0000
bugs1287007
milestone52.0a1
Bug 1287007 - Remove dead code MozReview-Commit-ID: LtuKY5DjB68
toolkit/components/extensions/ExtensionChild.jsm
toolkit/components/extensions/ext-backgroundPage.js
--- a/toolkit/components/extensions/ExtensionChild.jsm
+++ b/toolkit/components/extensions/ExtensionChild.jsm
@@ -185,19 +185,17 @@ class ExtensionContext extends BaseConte
     let chromeObj = Cu.createObjectIn(contentWindow, {defineAs: "chrome"});
     Schemas.inject(browserObj, this.childManager);
     Schemas.inject(chromeObj, chromeApiWrapper);
 
     if (viewType == "background") {
       apiManager.global.initializeBackgroundPage(contentWindow);
     }
 
-    if (this.externallyVisible) {
-      this.extension.views.add(this);
-    }
+    this.extension.views.add(this);
   }
 
   get cloneScope() {
     return this.contentWindow;
   }
 
   get principal() {
     return this.contentWindow.document.nodePrincipal;
@@ -205,20 +203,16 @@ class ExtensionContext extends BaseConte
 
   get windowId() {
     if (this.viewType == "tab" || this.viewType == "popup") {
       let globalView = ExtensionChild.contentGlobals.get(this.messageManager);
       return globalView ? globalView.windowId : -1;
     }
   }
 
-  get externallyVisible() {
-    return true;
-  }
-
   // Called when the extension shuts down.
   shutdown() {
     this.unload();
   }
 
   // This method is called when an extension page navigates away or
   // its tab is closed.
   unload() {
@@ -226,20 +220,17 @@ class ExtensionContext extends BaseConte
     // multiple times for tab pages closed by the "page-unload" handlers
     // triggered below.
     if (this.unloaded) {
       return;
     }
 
     super.unload();
     this.childManager.close();
-
-    if (this.externallyVisible) {
-      this.extension.views.delete(this);
-    }
+    this.extension.views.delete(this);
   }
 }
 
 // All subframes in a tab, background page, popup, etc. have the same view type.
 // This class keeps track of such global state.
 // Note that this is created even for non-extension tabs because at present we
 // do not have a way to distinguish regular tabs from extension tabs at the
 // initialization of a frame script.
--- a/toolkit/components/extensions/ext-backgroundPage.js
+++ b/toolkit/components/extensions/ext-backgroundPage.js
@@ -21,20 +21,18 @@ const XUL_URL = "data:application/vnd.mo
 // WeakMap[Extension -> BackgroundPage]
 var backgroundPagesMap = new WeakMap();
 
 // Responsible for the background_page section of the manifest.
 function BackgroundPage(options, extension) {
   this.extension = extension;
   this.page = options.page || null;
   this.isGenerated = !!options.scripts;
-  this.contentWindow = null;
   this.windowlessBrowser = null;
   this.webNav = null;
-  this.context = null;
 }
 
 BackgroundPage.prototype = {
   build: Task.async(function* () {
     let windowlessBrowser = Services.appShell.createWindowlessBrowser(true);
     this.windowlessBrowser = windowlessBrowser;
 
     let url;
@@ -86,20 +84,19 @@ BackgroundPage.prototype = {
 
     yield new Promise(resolve => {
       browser.messageManager.addMessageListener("Extension:ExtensionViewLoaded", function onLoad() {
         browser.messageManager.removeMessageListener("Extension:ExtensionViewLoaded", onLoad);
         resolve();
       });
     });
 
+    // TODO(robwu): This is not webext-oop compatible.
     this.webNav = browser.docShell.QueryInterface(Ci.nsIWebNavigation);
-
     let window = this.webNav.document.defaultView;
-    this.contentWindow = window;
 
 
     // Set the add-on's main debugger global, for use in the debugger
     // console.
     if (this.extension.addonData.instanceID) {
       AddonManager.getAddonByInstanceID(this.extension.addonData.instanceID)
                   .then(addon => addon.setDebugGlobal(window));
     }