tor-browser

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

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


      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.getownpropertynames
      6 description: >
      7  Property names are returned in ascending chronological order of creation
      8  that is unaffected by [[DefineOwnProperty]].
      9 info: |
     10  Object.getOwnPropertyNames ( O )
     11 
     12  1. Return ? GetOwnPropertyKeys(O, String).
     13 
     14  GetOwnPropertyKeys ( O, type )
     15 
     16  1. Let obj be ? ToObject(O).
     17  2. Let keys be ? obj.[[OwnPropertyKeys]]().
     18  [...]
     19 
     20  OrdinaryOwnPropertyKeys ( O )
     21 
     22  [...]
     23  3. For each own property key P of O that is a String but is not an array index,
     24  in ascending chronological order of property creation, do
     25    a. Add P as the last element of keys.
     26  [...]
     27  5. Return keys.
     28 features: [arrow-function]
     29 includes: [compareArray.js]
     30 ---*/
     31 
     32 var obj = {};
     33 Object.defineProperty(obj, "a", {
     34  get: function() {},
     35  set: function(_value) {},
     36  enumerable: true,
     37  configurable: true,
     38 })
     39 obj.b = 2;
     40 Object.defineProperty(obj, "a", {
     41  set: function(_value) {},
     42 });
     43 assert.compareArray(Object.getOwnPropertyNames(obj), ["a", "b"]);
     44 
     45 var arr = [];
     46 arr.a = 1;
     47 Object.defineProperty(arr, "length", {value: 2});
     48 assert.compareArray(Object.getOwnPropertyNames(arr), ["length", "a"]);
     49 
     50 reportCompare(0, 0);