tor-browser

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

private-setter-is-not-a-own-property.js (1445B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/private-setter-is-not-a-own-property.case
      3 // - src/class-elements/default/cls-decl.template
      4 /*---
      5 description: Private setter is not stored as an own property of objects (field definitions in a class declaration)
      6 esid: prod-FieldDefinition
      7 features: [class-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        a. Let entry be PrivateFieldFind(P, O).
     15        b. If entry is empty, throw a TypeError exception.
     16        c. Return entry.[[PrivateFieldValue]].
     17      4. Perform ? PrivateBrandCheck(O, P).
     18      5. If P.[[Kind]] is "method",
     19        a. Return P.[[Value]].
     20      6. Else,
     21        a. Assert: P.[[Kind]] is "accessor".
     22        b. If P does not have a [[Get]] field, throw a TypeError exception.
     23        c. Let getter be P.[[Get]].
     24        d. Return ? Call(getter, O).
     25 
     26 ---*/
     27 
     28 
     29 class C {
     30  set #m(v) { this._v = v; }
     31 
     32  checkPrivateSetter() {
     33    assert.sameValue(this.hasOwnProperty("#m"), false);
     34    assert.sameValue("#m" in this, false);
     35 
     36    assert.sameValue(this.__lookupSetter__("#m"), undefined);
     37 
     38    this.#m = "Test262";
     39    assert.sameValue(this._v, "Test262");
     40 
     41    return 0;
     42  }
     43 }
     44 
     45 let c = new C();
     46 assert.sameValue(c.checkPrivateSetter(), 0);
     47 
     48 reportCompare(0, 0);