tor-browser

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

proxy-for-in.js (859B)


      1 // Any copyright is dedicated to the Public Domain.
      2 // http://creativecommons.org/licenses/publicdomain/
      3 
      4 // SKIP test262 export
      5 // Pending review.
      6 
      7 "use strict";
      8 
      9 let steps = [];
     10 
     11 const object = {
     12    __proto__: {
     13        "xyz": 42
     14    }
     15 };
     16 const proxy = new Proxy(object, {
     17    ownKeys(target) {
     18        steps.push("ownKeys")
     19        return ["a", "b"];
     20    },
     21 
     22    getOwnPropertyDescriptor(target, property) {
     23        steps.push("getOwn-" + property);
     24        return {
     25            value: undefined,
     26            configurable: true,
     27            writable: true,
     28            enumerable: (property === "a")
     29        };
     30    }
     31 });
     32 
     33 let iterated = [];
     34 for (let x in proxy)
     35    iterated.push(x);
     36 
     37 assertEq(iterated.toString(), "a,xyz");
     38 assertEq(steps.toString(), "ownKeys,getOwn-a,getOwn-b");
     39 
     40 if (typeof reportCompare === "function")
     41    reportCompare(true, true);