tor-browser

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

private-static-method-not-writable.js (730B)


      1 // Copyright (C) 2021 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6  Throws TypeError when attempting to overwrite a private static method.
      7 esid: sec-privateset
      8 info: |
      9  7.3.30 PrivateSet ( P, O, value )
     10  1. Let entry be ! PrivateElementFind(P, O).
     11  2. If entry is empty, throw a TypeError exception.
     12  3. If entry.[[Kind]] is field, then
     13    ...
     14  4. Else if entry.[[Kind]] is method, then
     15    a. Throw a TypeError exception.
     16  5. ...
     17 
     18 features: [class, class-static-methods-private]
     19 ---*/
     20 
     21 class C {
     22  static #m() {}
     23 
     24  static assign() {
     25    this.#m = 0;
     26  }
     27 }
     28 
     29 assert.throws(TypeError, function() {
     30  C.assign();
     31 });
     32 
     33 reportCompare(0, 0);