defineProperty invariants

David Bruant bruant.d at gmail.com
Thu Oct 4 02:19:53 PDT 2012


Hi,

I think it's the dual of the getOwnPropertyDescriptor invariant I talked
about recently.

  var t = {a:1};

  var p = new Proxy(t, {
    defineProperty: function(target, name, desc){
      return true; // pretend it's always successful
    }
  });

  Object.defineProperty(p, 'a', {configurable: false});

My reading of the current spec is that this doesn't throw, so it means that
Object.defineProperty pretends that 'a' has been successfully made
non-configurable while it's actually not the case.
Programs relying Object.defineProperty output being true can be fooled.
I think the invariant should be:
ToBoolean(definePropertyTrapOutput) === true => (descArgument.configurable
=== targetDesc.configurable)

Basically, it says that if the operation succeeded, the new target
descriptor and the descriptor on the target after the trap call are the
same.

Do we want invariants regarding when ToBoolean(definePropertyTrapOutput) is
false?

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121004/ffab0690/attachment.html>


More information about the es-discuss mailing list