tor-browser

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

privatefieldget-success-1.js (1171B)


      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 /*---
      5 description: Successfully access private field
      6 esid: sec-getvalue
      7 info: |
      8  GetValue ( V )
      9    ...
     10    5. If IsPropertyReference(V), then
     11      ...
     12      b. If IsPrivateReference(V), then
     13        i. Let env be the running execution context's PrivateNameEnvironment.
     14        ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
     15        iii. Assert: field is a Private Name.
     16        iv. Return ? PrivateFieldGet(field, base).
     17 
     18  PrivateFieldGet (P, O )
     19    1. Assert: P is a Private Name value.
     20    2. If O is not an object, throw a TypeError exception.
     21    3. Let entry be PrivateFieldFind(P, O).
     22    4. If entry is empty, throw a TypeError exception.
     23    5. Return entry.[[PrivateFieldValue]].
     24 
     25 features: [class, class-fields-private]
     26 ---*/
     27 
     28 class Outer {
     29  #x = 42;
     30 
     31  innerclass() {
     32    var self = this;
     33 
     34    return class extends Outer {
     35      f() {
     36        return self.#x;
     37      }
     38    }
     39  }
     40 }
     41 
     42 var Inner = new Outer().innerclass();
     43 var i = new Inner();
     44 var value = i.f();
     45 
     46 assert.sameValue(value, 42)
     47 
     48 reportCompare(0, 0);