tor-browser

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

bug1995289.js (831B)


      1 class Identity {
      2  constructor(target) {
      3    return target;
      4  }
      5 }
      6 
      7 class TargetHandler extends Identity {
      8  #proxy;
      9 
     10  constructor(target, proxy) {
     11    super(target);
     12    this.#proxy = proxy;
     13  }
     14 
     15  static getProxy(obj) {
     16    return obj.#proxy;
     17  }
     18 }
     19 
     20 class ReactiveHandler extends TargetHandler {
     21  #priv;
     22 
     23  constructor(target, proxy) {
     24    // Both the target and the proxy have the "#proxy" private field that stores the reference to the proxy
     25    new TargetHandler(target, proxy);
     26    super(proxy, proxy);
     27  }
     28 
     29  get(t, k, r) { throw "oops"; }
     30 
     31  defineProperty(t, k, desc) {
     32    ReactiveHandler.getProxy(t).#priv;
     33    return Reflect.defineProperty(t, k, desc);
     34  }
     35 }
     36 
     37 const target = {};
     38 const proxy = new ReactiveHandler(target, new Proxy(target, ReactiveHandler.prototype));
     39 
     40 for (var i = 0; i < 20; i++) {
     41  proxy[i] = i;
     42 }