tor-browser

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

indices-groups-object.js (1334B)


      1 // Copyright 2019 Ron Buckton. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: The groups object of indices is created with CreateDataProperty
      6 includes: [propertyHelper.js, compareArray.js]
      7 esid: sec-makeindicesarray
      8 features: [regexp-named-groups, regexp-match-indices]
      9 info: |
     10  MakeIndicesArray ( S, indices, groupNames, hasIndices )
     11    10. If _hasIndices_ is *true*, then
     12      a. Let _groups_ be ! ObjectCreate(*null*).
     13    11. Else,
     14      a. Let _groups_ be *undefined*.
     15    12. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
     16 ---*/
     17 
     18 // `groups` is created with Define, not Set.
     19 let counter = 0;
     20 Object.defineProperty(Array.prototype, "groups", {
     21  set() { counter++; }
     22 });
     23 
     24 let indices = /(?<x>.)/d.exec("a").indices;
     25 assert.sameValue(counter, 0);
     26 
     27 // `groups` is writable, enumerable and configurable
     28 // (from CreateDataProperty).
     29 verifyProperty(indices, 'groups', {
     30    writable: true,
     31    enumerable: true,
     32    configurable: true
     33 });
     34 
     35 // The `__proto__` property on the groups object is not special,
     36 // and does not affect the [[Prototype]] of the resulting groups object.
     37 let {groups} = /(?<__proto__>.)/d.exec("a").indices;
     38 assert.compareArray([0, 1], groups.__proto__);
     39 assert.sameValue(null, Object.getPrototypeOf(groups));
     40 
     41 reportCompare(0, 0);