tor-browser

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

groups-object-undefined.js (1074B)


      1 // Copyright 2017 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: The groups object is created unconditionally.
      6 includes: [propertyHelper.js]
      7 esid: sec-regexpbuiltinexec
      8 features: [regexp-named-groups]
      9 info: |
     10  Runtime Semantics: RegExpBuiltinExec ( R, S )
     11    24. If _R_ contains any |GroupName|, then
     12      a. Let _groups_ be ObjectCreate(*null*).
     13    25. Else,
     14      a. Let _groups_ be *undefined*.
     15    26. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
     16 ---*/
     17 
     18 const re = /./;
     19 const result = re.exec("a");
     20 assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
     21 assert(result.hasOwnProperty("groups"));
     22 assert.sameValue("a", result[0]);
     23 assert.sameValue(0, result.index);
     24 assert.sameValue(undefined, result.groups);
     25 verifyProperty(result, "groups", {
     26  writable: true,
     27  enumerable: true,
     28  configurable: true,
     29 });
     30 
     31 Array.prototype.groups = { a: "b" };
     32 assert.sameValue("$<a>", "a".replace(re, "$<a>"));
     33 Array.prototype.groups = undefined;
     34 
     35 reportCompare(0, 0);