js/src/jit-test/tests/proxy/bug-862848-1.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 // obj.hasOwnProperty(id), Object.getOwnPropertyDescriptor(obj, id), and
     2 // Object.defineProperty(obj, id, desc) do not look at obj's prototype.
     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);
    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 });
    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);

mercurial