tor-browser

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

private-getter-is-not-clobbered-by-computed-property.js (1293B)


      1 // Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Private getter is not clobbered by computed property
      6 esid: sec-privatefieldget
      7 info: |
      8  PrivateFieldGet (P, O)
      9    1. Assert: P is a Private Name.
     10    2. If O is not an object, throw a TypeError exception.
     11    3. If P.[[Kind]] is "field",
     12      a. Let entry be PrivateFieldFind(P, O).
     13      b. If entry is empty, throw a TypeError exception.
     14      c. Return entry.[[PrivateFieldValue]].
     15    4. Perform ? PrivateBrandCheck(O, P).
     16    5. If P.[[Kind]] is "method",
     17      a. Return P.[[Value]].
     18    6. Else,
     19      a. Assert: P.[[Kind]] is "accessor".
     20      b. If P does not have a [[Get]] field, throw a TypeError exception.
     21      c. Let getter be P.[[Get]].
     22      d. Return ? Call(getter, O).
     23 features: [class-methods-private, class-fields-public, class]
     24 ---*/
     25 
     26 class C {
     27  get #m() { return "Test262"; }
     28  ["#m"] = 0;
     29  
     30  checkPrivateGetter() {
     31    assert.sameValue(this.hasOwnProperty("#m"), true);
     32    assert.sameValue("#m" in this, true);
     33  
     34    assert.sameValue(this["#m"], 0);
     35  
     36    assert.sameValue(this.#m, "Test262");
     37  
     38    return 0;
     39  }
     40 }
     41 
     42 let c = new C();
     43 assert.sameValue(c.checkPrivateGetter(), 0);
     44 
     45 reportCompare(0, 0);