js/src/jit-test/tests/for-of/proxy-1.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.
     3 function iterableProxy(arr) {
     4     return Proxy.create({
     5         getPropertyDescriptor: function (name) {
     6             for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) {
     7                 var desc = Object.getOwnPropertyDescriptor(obj, name);
     8                 if (desc)
     9                     return desc;
    10             }
    11             return undefined;
    12         }
    13     });
    14 }
    16 var s = '';
    17 var arr = ['a', 'b', 'c', 'd'];
    18 var p = iterableProxy(arr);
    20 // Test the same proxy twice. Each time through the loop, the proxy handler's
    21 // getPropertyDescriptor method will be called 10 times (once for 'iterator',
    22 // five times for 'length', and once for each of the four elements).
    23 for (var i = 0; i < 2; i++) {
    24     var j = 0;
    25     for (var x of p)
    26         assertEq(x, arr[j++]);
    27     assertEq(j, arr.length);
    28 }

mercurial