js/src/jit-test/tests/for-of/proxy-2.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 // Basic for-of test with Proxy whose iterator method is a generator.
     3 var arr = ['a', 'b', 'c', 'd'];
     4 var proxy = Proxy.create({
     5     getPropertyDescriptor: function (name) {
     6         if (name == 'iterator') {
     7             return {
     8                 configurable: false,
     9                 enumerable: false,
    10                 writeable: false,
    11                 value:  function () {
    12                     for (var i = 0; i < arr.length; i++)
    13                         yield arr[i];
    14                 }
    15             };
    16         }
    18         // Otherwise, inherit the property from arr.
    19         for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) {
    20             var desc = Object.getOwnPropertyDescriptor(obj, name);
    21             if (desc)
    22                 return desc;
    23         }
    24         return undefined;
    25     }
    26 });
    28 for (var i = 0; i < 2; i++)
    29     assertEq([v for (v of proxy)].join(","), "a,b,c,d");

mercurial