On 10/8/13 1:16 PM, David Rajchenbach-Teller wrote:
A (not very) long time ago, our extension model was based on XPCOM – if
you didn't like a component, you could just replace it in an add-on.
These days, we have shifted to providing JavaScript modules and
suggesting JavaScript add-ons.
Now, by default, any JavaScript module can be monkey-patched. Some
developers prefer to Object.freeze() them, to ensure that this doesn't
happen, while others leave them open voluntarily and use monkey-patching
in test suites.
Object.freeze() is typically only used on the prototype object from what
I've seen (and written myself). You can still monkeypatch individual
object instances by replacing the .prototype or using
Object.defineProperty() on the object instance to "override" the
prototype's method without touching the frozen prototype object.
Actually, I think you can replace the .prototype property on the "new"
function when you Cu.import(), no? Object.freeze(Foo.prototype) just
makes it /slightly/ more difficult to monkeypatch while eliminating some
footguns associated with accidental prototype mutation.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform