tor-browser

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

order-after-define-property.js (1374B)


      1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-object.values
      6 description: >
      7  Property names are returned in ascending chronological order of creation
      8  that is unaffected by [[DefineOwnProperty]].
      9 info: |
     10  Object.values ( O )
     11 
     12  [...]
     13  2. Let nameList be ? EnumerableOwnPropertyNames(obj, value).
     14  3. Return CreateArrayFromList(nameList).
     15 
     16  EnumerableOwnPropertyNames ( O, kind )
     17 
     18  [...]
     19  2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
     20  [...]
     21 
     22  OrdinaryOwnPropertyKeys ( O )
     23 
     24  [...]
     25  3. For each own property key P of O that is a String but is not an array index,
     26  in ascending chronological order of property creation, do
     27    a. Add P as the last element of keys.
     28  [...]
     29  5. Return keys.
     30 includes: [compareArray.js]
     31 ---*/
     32 
     33 var obj = {};
     34 Object.defineProperty(obj, "a", {
     35  get: function() {},
     36  enumerable: true,
     37  configurable: true,
     38 });
     39 obj.b = "b";
     40 Object.defineProperty(obj, "a", {
     41  get: function() {
     42    return "a";
     43  },
     44 });
     45 assert.compareArray(Object.values(obj), ["a", "b"]);
     46 
     47 var proxy = new Proxy({}, {});
     48 Object.defineProperty(proxy, "a", {
     49  get: function() {},
     50  enumerable: true,
     51  configurable: true,
     52 });
     53 proxy.b = "b";
     54 Object.defineProperty(proxy, "a", {value: "a"});
     55 assert.compareArray(Object.values(proxy), ["a", "b"]);
     56 
     57 reportCompare(0, 0);