tor-browser

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

private-field-presence-accessor-shadowed.js (1233B)


      1 // Copyright 2021 the V8 project authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Value when private name describes an accessor method
      6 info: |
      7  7. Let privateName be ? GetValue(privateNameBinding).
      8  8. Assert: privateName is a Private Name.
      9  [...]
     10  10. Else,
     11      a. Assert: privateName.[[Kind]] is "method" or "accessor".
     12      b. If PrivateBrandCheck(rval, privateName) is not an abrupt completion,
     13         then return true.
     14  11. Return false.
     15 esid: sec-relational-operators-runtime-semantics-evaluation
     16 features: [class-static-methods-private, class-fields-private-in]
     17 ---*/
     18 
     19 let Child;
     20 let parentCount = 0;
     21 let childCount = 0;
     22 
     23 class Parent {
     24  get #accessor() {
     25    parentCount += 1;
     26  }
     27 
     28  static init() {
     29    Child = class {
     30      get #accessor() {
     31        childCount += 1;
     32      }
     33 
     34      static isNameIn(value) {
     35        return #accessor in value;
     36      }
     37    };
     38  }
     39 }
     40 
     41 Parent.init();
     42 
     43 assert.sameValue(Child.isNameIn(new Parent()), false);
     44 assert.sameValue(parentCount, 0, 'parent accessor not invoked');
     45 assert.sameValue(Child.isNameIn(new Child()), true);
     46 assert.sameValue(childCount, 0, 'child accessor not invoked');
     47 
     48 
     49 reportCompare(0, 0);