From 3eccbde5593537e9d3e14d83bc5d68fdc83afada Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Wed, 19 Mar 2014 16:21:00 +1300 Subject: [PATCH] Bug 985729 - Construct the [[Prototype]] chain given to DBAddonInternal instances without using mutable __proto__. r=Unfocused --- .../extensions/internal/XPIProviderUtils.js | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index a7a4a8340249..f4db5911cc93 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -341,31 +341,36 @@ function DBAddonInternal(aLoaded) { }); } -DBAddonInternal.prototype = { - applyCompatibilityUpdate: function DBA_applyCompatibilityUpdate(aUpdate, aSyncCompatibility) { - this.targetApplications.forEach(function(aTargetApp) { - aUpdate.targetApplications.forEach(function(aUpdateTarget) { - if (aTargetApp.id == aUpdateTarget.id && (aSyncCompatibility || - Services.vc.compare(aTargetApp.maxVersion, aUpdateTarget.maxVersion) < 0)) { - aTargetApp.minVersion = aUpdateTarget.minVersion; - aTargetApp.maxVersion = aUpdateTarget.maxVersion; - XPIDatabase.saveChanges(); - } +function DBAddonInternalPrototype() +{ + this.applyCompatibilityUpdate = + function(aUpdate, aSyncCompatibility) { + this.targetApplications.forEach(function(aTargetApp) { + aUpdate.targetApplications.forEach(function(aUpdateTarget) { + if (aTargetApp.id == aUpdateTarget.id && (aSyncCompatibility || + Services.vc.compare(aTargetApp.maxVersion, aUpdateTarget.maxVersion) < 0)) { + aTargetApp.minVersion = aUpdateTarget.minVersion; + aTargetApp.maxVersion = aUpdateTarget.maxVersion; + XPIDatabase.saveChanges(); + } + }); }); - }); - XPIProvider.updateAddonDisabledState(this); - }, + XPIProvider.updateAddonDisabledState(this); + }; - get inDatabase() { - return true; - }, + this.toJSON = + function() { + return copyProperties(this, PROP_JSON_FIELDS); + }; - toJSON: function() { - return copyProperties(this, PROP_JSON_FIELDS); - } + Object.defineProperty(this, "inDatabase", + { get: function() { return true; }, + enumerable: true, + configurable: true }); } +DBAddonInternalPrototype.prototype = AddonInternal.prototype; -DBAddonInternal.prototype.__proto__ = AddonInternal.prototype; +DBAddonInternal.prototype = new DBAddonInternalPrototype(); /** * Internal interface: find an addon from an already loaded addonDB