tor-browser

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

private-method-is-not-a-own-property.js (1363B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/private-method-is-not-a-own-property.case
      3 // - src/class-elements/default/cls-decl.template
      4 /*---
      5 description: Private method 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  #m() { return "Test262"; }
     31 
     32  checkPrivateMethod() {
     33    assert.sameValue(this.hasOwnProperty("#m"), false);
     34    assert.sameValue("#m" in this, false);
     35 
     36    assert.sameValue(this.#m(), "Test262");
     37    
     38    return 0;
     39  }
     40 }
     41 
     42 let c = new C();
     43 assert.sameValue(c.checkPrivateMethod(), 0);
     44 
     45 reportCompare(0, 0);