tor-browser

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

privatename-not-valid-eval-earlyerr-2.js (797B)


      1 // Copyright (C) 2017 Valerie Young. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-scripts-static-semantics-early-errors
      5 description: Early error when referencing privatename in function in class without declaring in field
      6 info: |
      7  Static Semantics: Early Errors
      8    ScriptBody : StatementList
      9 
     10    It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
     11 
     12 features: [class, class-fields-private]
     13 ---*/
     14 
     15 var executed = false;
     16 
     17 class C {
     18  f() {
     19    eval("executed = true; this.#x;");
     20  }
     21 }
     22 
     23 assert.throws(SyntaxError, function() {
     24  new C().f();
     25 });
     26 
     27 assert.sameValue(executed, false);
     28 
     29 reportCompare(0, 0);