tor-browser

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

enumerable-configurable-accessor-descriptor.js (1102B)


      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-arguments-exotic-objects-defineownproperty-p-desc
      6 description: >
      7  Index gets unmapped when redefined with accessor. Unmapped index is created.
      8 info: |
      9  [[DefineOwnProperty]] ( P, Desc )
     10 
     11  [...]
     12  6. Let allowed be ? OrdinaryDefineOwnProperty(args, P, newArgDesc).
     13  7. If allowed is false, return false.
     14  8. If isMapped is true, then
     15    a. If IsAccessorDescriptor(Desc) is true, then
     16      i. Call map.[[Delete]](P).
     17    [...]
     18  9. Return true.
     19 flags: [noStrict]
     20 ---*/
     21 
     22 (function(a) {
     23  let setCalls = 0;
     24  Object.defineProperty(arguments, "0", {
     25    set(_v) { setCalls += 1; },
     26    enumerable: true,
     27    configurable: true,
     28  });
     29 
     30  arguments[0] = "foo";
     31 
     32  assert.sameValue(setCalls, 1);
     33  assert.sameValue(a, 0);
     34  assert.sameValue(arguments[0], undefined);
     35 
     36 
     37  Object.defineProperty(arguments, "1", {
     38    get: () => "bar",
     39    enumerable: true,
     40    configurable: true,
     41  });
     42 
     43  assert.sameValue(arguments[1], "bar");
     44 })(0);
     45 
     46 reportCompare(0, 0);