tor-browser

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

static-private-setter-access-on-inner-arrow-function.js (1277B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/static-private-setter-access-on-inner-arrow-function.case
      3 // - src/class-elements/default/cls-expr.template
      4 /*---
      5 description: static private setter access inside of an arrow function (field definitions in a class expression)
      6 esid: prod-FieldDefinition
      7 features: [class-static-methods-private, class]
      8 flags: [generated]
      9 info: |
     10    PrivateFieldGet (P, O)
     11      1. Assert: P is a Private Name.
     12      2. If O is not an object, throw a TypeError exception.
     13      3. If P.[[Kind]] is "field",
     14      ...
     15      4. Perform ? PrivateBrandCheck(O, P).
     16      5. If P.[[Kind]] is "method",
     17        a. Return P.[[Value]].
     18      ...
     19 
     20    PrivateBrandCheck(O, P)
     21      1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true,
     22        a. Throw a TypeError exception.
     23 
     24 ---*/
     25 
     26 
     27 var C = class {
     28  static set #f(v) {
     29    this._v = v;
     30  }
     31 
     32  static access() {
     33    const arrowFunction = () => {
     34      this.#f = 'Test262';
     35    };
     36 
     37    arrowFunction();
     38  }
     39 }
     40 
     41 C.access();
     42 assert.sameValue(C._v, 'Test262');
     43 assert.throws(TypeError, function() {
     44  C.access.call({});
     45 }, 'Accessed static private setter from an object which did not contain it');
     46 
     47 reportCompare(0, 0);