tor-browser

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

testDirectProxyKeys9.js (803B)


      1 // Cull non-existent names returned by the trap.
      2 var nullProtoAB = Object.create(null, {
      3    a: {
      4        enumerable: true,
      5        configurable: true
      6    },
      7    b: {
      8        enumerable: false,
      9        configurable: true
     10    }
     11 });
     12 var protoABWithCD = Object.create(nullProtoAB, {
     13    c: {
     14        enumerable: true,
     15        configurable: true
     16    },
     17    d: {
     18        enumerable: false,
     19        configurable: true
     20    }
     21 });
     22 
     23 var returnedNames;
     24 var handler = { ownKeys: () => returnedNames };
     25 
     26 for (let p of [new Proxy(protoABWithCD, handler), Proxy.revocable(protoABWithCD, handler).proxy]) {
     27    returnedNames = [ 'e' ];
     28    var names = Object.keys(p);
     29    assertEq(names.length, 0);
     30 
     31    returnedNames = [ 'c' ];
     32    names = Object.keys(p);
     33    assertEq(names.length, 1);
     34    assertEq(names[0], 'c');
     35 }