tor-browser

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

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


      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.entries
      6 description: >
      7  Property names are returned in ascending chronological order of creation
      8  that is unaffected by [[DefineOwnProperty]].
      9 info: |
     10  Object.entries ( O )
     11 
     12  [...]
     13  2. Let nameList be ? EnumerableOwnPropertyNames(obj, key+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 obj.a = 1;
     35 obj.b = 2;
     36 Object.defineProperty(obj, "a", {writable: false});
     37 var objKeys = Object.entries(obj).map(e => e[0]);
     38 assert.compareArray(objKeys, ["a", "b"]);
     39 
     40 reportCompare(0, 0);