tor-browser

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

bug-862848-1.js (793B)


      1 // obj.hasOwnProperty(id), Object.getOwnPropertyDescriptor(obj, id), and
      2 // Object.defineProperty(obj, id, desc) do not look at obj's prototype.
      3 
      4 var angryHandler = new Proxy({}, {
      5    has: () => true,
      6    get: (t, id) => {
      7        throw new Error("angryHandler should not be queried (" + id + ")");
      8    }
      9 });
     10 var angryProto = new Proxy({}, angryHandler);
     11 
     12 var obj = Object.create(angryProto, {
     13    // Define hasOwnProperty directly on obj since we are poisoning its
     14    // prototype chain.
     15    hasOwnProperty: {
     16        value: Object.prototype.hasOwnProperty
     17    }
     18 });
     19 
     20 assertEq(Object.getOwnPropertyDescriptor(obj, "foo"), undefined);
     21 assertEq(obj.hasOwnProperty("foo"), false);
     22 Object.defineProperty(obj, "foo", {value: 5});
     23 assertEq(obj.hasOwnProperty("foo"), true);
     24 assertEq(obj.foo, 5);