js/src/tests/ecma_6/Proxy/proxy-__proto__.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var gTestfile = 'proxy-__proto__.js';
     7 var BUGNUMBER = 950407;
     8 var summary = "Behavior of __proto__ on ES6 proxies";
    10 print(BUGNUMBER + ": " + summary);
    12 /**************
    13  * BEGIN TEST *
    14  **************/
    16 var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
    17 var protoGetter = protoDesc.get;
    18 var protoSetter = protoDesc.set;
    20 function testProxy(target, initialProto)
    21 {
    22   print("Now testing behavior for new Proxy(" + ("" + target) + ", {})");
    24   var pobj = new Proxy(target, {});
    26   // Check [[Prototype]] before attempted mutation
    27   assertEq(Object.getPrototypeOf(pobj), initialProto);
    28   assertEq(protoGetter.call(pobj), initialProto);
    30   // Attempt [[Prototype]] mutation
    31   protoSetter.call(pobj, null);
    33   // Check [[Prototype]] after attempted mutation
    34   assertEq(Object.getPrototypeOf(pobj), null);
    35   assertEq(protoGetter.call(pobj), null);
    36   assertEq(Object.getPrototypeOf(target), null);
    37 }
    39 // Proxy object with non-null [[Prototype]]
    40 var nonNullProto = { toString: function() { return "non-null prototype"; } };
    41 var target = Object.create(nonNullProto);
    42 testProxy(target, nonNullProto);
    44 // Proxy object with null [[Prototype]]
    45 target = Object.create(null);
    46 target.toString = function() { return "null prototype" };
    47 testProxy(target, null);
    49 // Proxy function with [[Call]]
    50 var callForCallOnly = function () { };
    51 callForCallOnly.toString = function() { return "callable target"; };
    52 testProxy(callForCallOnly, Function.prototype);
    54 /******************************************************************************/
    56 if (typeof reportCompare === "function")
    57   reportCompare(true, true);
    59 print("Tests complete");

mercurial