tor-browser

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

static-private-fields-proxy-default-handler-throws.js (695B)


      1 // Copyright (C) 2018 Rick Waldron. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-privatefieldget
      6 description: Static private fields not accessible via default Proxy handler
      7 info: |
      8  1. Assert: P is a Private Name value.
      9  2. If O is not an object, throw a TypeError exception.
     10  3. Let entry be PrivateFieldFind(P, O).
     11  4. If entry is empty, throw a TypeError exception.
     12 
     13 features: [class, class-static-fields-private]
     14 ---*/
     15 
     16 var C = class {
     17  static #x = 1;
     18  static x() {
     19    return this.#x;
     20  }
     21 }
     22 
     23 var P = new Proxy(C, {});
     24 
     25 assert.sameValue(C.x(), 1);
     26 assert.throws(TypeError, function() {
     27  P.x();
     28 });
     29 
     30 reportCompare(0, 0);