diff --git a/toolkit/components/addoncompat/RemoteAddonsParent.jsm b/toolkit/components/addoncompat/RemoteAddonsParent.jsm index 4cc77fa4e68..63aeb0cb3e9 100644 --- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm @@ -86,16 +86,17 @@ NotificationTracker.init(); // getters, and setters. See multiprocessShims.js for an explanation // of how these are used. The constructor here just allows one // interposition to inherit members from another. -function Interposition(base) +function Interposition(name, base) { + this.name = name; if (base) { this.methods = Object.create(base.methods); this.getters = Object.create(base.getters); this.setters = Object.create(base.setters); } else { - this.methods = {}; - this.getters = {}; - this.setters = {}; + this.methods = Object.create(null); + this.getters = Object.create(null); + this.setters = Object.create(null); } } @@ -157,7 +158,7 @@ ContentPolicyParent.init(); // This interposition intercepts calls to add or remove new content // policies and forwards these requests to ContentPolicyParent. -let CategoryManagerInterposition = new Interposition(); +let CategoryManagerInterposition = new Interposition("CategoryManagerInterposition"); CategoryManagerInterposition.methods.addCategoryEntry = function(addon, target, category, entry, value, persist, replace) { @@ -248,7 +249,7 @@ let AboutProtocolParent = { }; AboutProtocolParent.init(); -let ComponentRegistrarInterposition = new Interposition(); +let ComponentRegistrarInterposition = new Interposition("ComponentRegistrarInterposition"); ComponentRegistrarInterposition.methods.registerFactory = function(addon, target, class_, className, contractID, factory) { @@ -319,7 +320,7 @@ let TOPIC_WHITELIST = ["content-document-global-created", // This interposition listens for // nsIObserverService.{add,remove}Observer. -let ObserverInterposition = new Interposition(); +let ObserverInterposition = new Interposition("ObserverInterposition"); ObserverInterposition.methods.addObserver = function(addon, target, observer, topic, ownsWeak) { @@ -457,7 +458,7 @@ let EventTargetParent = { dispatch: function(browser, type, isTrusted, event) { let targets = this.getTargets(browser); - for (target of targets) { + for (let target of targets) { let listeners = this._listeners.get(target); if (!listeners) { continue; @@ -483,7 +484,7 @@ EventTargetParent.init(); // This interposition redirects addEventListener and // removeEventListener to EventTargetParent. -let EventTargetInterposition = new Interposition(); +let EventTargetInterposition = new Interposition("EventTargetInterposition"); EventTargetInterposition.methods.addEventListener = function(addon, target, type, listener, useCapture, wantsUntrusted) { @@ -501,7 +502,7 @@ EventTargetInterposition.methods.removeEventListener = // process docshell. In the child, each docshell is its own // root. However, add-ons expect the root to be the chrome docshell, // so we make that happen here. -let ContentDocShellTreeItemInterposition = new Interposition(); +let ContentDocShellTreeItemInterposition = new Interposition("ContentDocShellTreeItemInterposition"); ContentDocShellTreeItemInterposition.getters.rootTreeItem = function(addon, target) { @@ -569,7 +570,7 @@ let SandboxParent = { // This interposition redirects calls to Cu.Sandbox and // Cu.evalInSandbox to SandboxParent if the principals are content // principals. -let ComponentsUtilsInterposition = new Interposition(); +let ComponentsUtilsInterposition = new Interposition("ComponentsUtilsInterposition"); ComponentsUtilsInterposition.methods.Sandbox = function(addon, target, principal, ...rest) { @@ -596,7 +597,7 @@ ComponentsUtilsInterposition.methods.evalInSandbox = // chrome XUL node into a content document. It doesn't actually do the // import, which we can't support. It just avoids throwing an // exception. -let ContentDocumentInterposition = new Interposition(); +let ContentDocumentInterposition = new Interposition("ContentDocumentInterposition"); ContentDocumentInterposition.methods.importNode = function(addon, target, node, deep) { @@ -614,7 +615,8 @@ ContentDocumentInterposition.methods.importNode = // This interposition ensures that calling browser.docShell from an // add-on returns a CPOW around the dochell. -let RemoteBrowserElementInterposition = new Interposition(EventTargetInterposition); +let RemoteBrowserElementInterposition = new Interposition("RemoteBrowserElementInterposition", + EventTargetInterposition); RemoteBrowserElementInterposition.getters.docShell = function(addon, target) { let remoteChromeGlobal = RemoteAddonsParent.browserToGlobal.get(target); @@ -633,7 +635,8 @@ RemoteBrowserElementInterposition.getters.contentDocument = function(addon, targ return target.contentDocumentAsCPOW; }; -let ChromeWindowInterposition = new Interposition(EventTargetInterposition); +let ChromeWindowInterposition = new Interposition("ChromeWindowInterposition", + EventTargetInterposition); ChromeWindowInterposition.getters.content = function(addon, target) { return target.gBrowser.selectedBrowser.contentWindowAsCPOW; diff --git a/toolkit/components/addoncompat/multiprocessShims.js b/toolkit/components/addoncompat/multiprocessShims.js index c1439645065..5be6ffc38f9 100644 --- a/toolkit/components/addoncompat/multiprocessShims.js +++ b/toolkit/components/addoncompat/multiprocessShims.js @@ -119,18 +119,17 @@ AddonInterpositionService.prototype = { let desc = { configurable: false, enumerable: true }; - if ("methods" in interp && interp.methods.hasOwnProperty(prop)) { + if ("methods" in interp && prop in interp.methods) { desc.writable = false; desc.value = function(...args) { return interp.methods[prop](addon, target, ...args); } return desc; - } else if ("getters" in interp && - interp.getters.hasOwnProperty(prop)) { + } else if ("getters" in interp && prop in interp.getters) { desc.get = function() { return interp.getters[prop](addon, target); }; - if ("setters" in interp && interp.setters.hasOwnProperty(prop)) { + if ("setters" in interp && prop in interp.setters) { desc.set = function(v) { return interp.setters[prop](addon, target, v); }; }