diff options
Diffstat (limited to 'toolkit/mozapps')
-rw-r--r-- | toolkit/mozapps/extensions/AddonManager.jsm | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 38303726b..51030cb56 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -641,53 +641,6 @@ var AddonManagerInternal = { // Store telemetry details per addon provider telemetryDetails: {}, - // A read-only wrapper around the types dictionary - typesProxy: Proxy.create({ - getOwnPropertyDescriptor: function typesProxy_getOwnPropertyDescriptor(aName) { - if (!(aName in AddonManagerInternal.types)) - return undefined; - - return { - value: AddonManagerInternal.types[aName].type, - writable: false, - configurable: false, - enumerable: true - } - }, - - getPropertyDescriptor: function typesProxy_getPropertyDescriptor(aName) { - return this.getOwnPropertyDescriptor(aName); - }, - - getOwnPropertyNames: function typesProxy_getOwnPropertyNames() { - return Object.keys(AddonManagerInternal.types); - }, - - getPropertyNames: function typesProxy_getPropertyNames() { - return this.getOwnPropertyNames(); - }, - - delete: function typesProxy_delete(aName) { - // Not allowed to delete properties - return false; - }, - - defineProperty: function typesProxy_defineProperty(aName, aProperty) { - // Ignore attempts to define properties - }, - - fix: function typesProxy_fix(){ - return undefined; - }, - - // Despite MDC's claims to the contrary, it is required that this trap - // be defined - enumerate: function typesProxy_enumerate() { - // All properties are enumerable - return this.getPropertyNames(); - } - }), - recordTimestamp: function AMI_recordTimestamp(name, value) { this.TelemetryTimestamps.add(name, value); }, @@ -2423,7 +2376,53 @@ var AddonManagerInternal = { }, get addonTypes() { - return this.typesProxy; + // A read-only wrapper around the types dictionary + return new Proxy(this.types, { + defineProperty(target, property, descriptor) { + // Not allowed to define properties + return false; + }, + + deleteProperty(target, property) { + // Not allowed to delete properties + return false; + }, + + get(target, property, receiver) { + if (!target.hasOwnProperty(property)) + return undefined; + + return target[property].type; + }, + + getOwnPropertyDescriptor(target, property) { + if (!target.hasOwnProperty(property)) + return undefined; + + return { + value: target[property].type, + writable: false, + // Claim configurability to maintain the proxy invariants. + configurable: true, + enumerable: true + } + }, + + preventExtensions(target) { + // Not allowed to prevent adding new properties + return false; + }, + + set(target, property, value, receiver) { + // Not allowed to set properties + return false; + }, + + setPrototypeOf(target, prototype) { + // Not allowed to change prototype + return false; + } + }); }, get autoUpdateDefault() { |