js/src/jit-test/tests/for-of/array-iterator-proxy.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 // An array iterator for a proxy calls the traps in a predictable order.
     3 load(libdir + "asserts.js");
     4 load(libdir + "iteration.js");
     6 var s = '';
     8 var proxyObj = {
     9     get: function (recipient, name) {
    10         if (name == 'length') {
    11             s += 'L';
    12             return 2;
    13         } else {
    14             s += name;
    15             return name;
    16         }
    17     }
    18 };
    20 var it = Array.prototype[std_iterator].call(Proxy.create(proxyObj));
    22 assertIteratorNext(it, "0");
    23 s += ' ';
    24 assertIteratorNext(it, "1");
    25 s += ' ';
    26 assertIteratorDone(it, undefined);
    27 assertEq(s, "L0 L1 L");
    29 s = '';
    30 var ki = Array.prototype.keys.call(Proxy.create(proxyObj));
    32 assertIteratorNext(ki, 0);
    33 s += ' ';
    34 assertIteratorNext(ki, 1);
    35 s += ' ';
    36 assertIteratorDone(ki, undefined);
    37 assertEq(s, "L L L");
    39 s = '';
    40 var ei = Array.prototype.entries.call(Proxy.create(proxyObj));
    42 assertIteratorNext(ei, [0, "0"]);
    43 s += ' ';
    44 assertIteratorNext(ei, [1, "1"]);
    45 s += ' ';
    46 assertIteratorDone(ei, undefined);
    47 assertEq(s, "L0 L1 L");

mercurial