tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

call-parameters-object-getownpropertynames.js (823B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
      5 description: >
      6    [[OwnPropertyKeys]] ( )
      7 
      8    7. Let trapResultArray be ? Call(trap, handler, « target »).
      9 features: [Proxy]
     10 ---*/
     11 
     12 var _target, _handler;
     13 var target = {
     14  foo: 1,
     15  bar: 2
     16 };
     17 
     18 var handler = {
     19  ownKeys: function(t) {
     20    _handler = this;
     21    _target = t;
     22    return Object.getOwnPropertyNames(t);
     23  }
     24 }
     25 var p = new Proxy(target, handler);
     26 
     27 var names = Object.getOwnPropertyNames(p);
     28 
     29 assert.sameValue(names[0], "foo");
     30 assert.sameValue(names[1], "bar");
     31 assert.sameValue(names.length, 2);
     32 assert.sameValue(_handler, handler);
     33 assert.sameValue(_target, target);
     34 
     35 reportCompare(0, 0);