js/src/jit-test/tests/for-of/array-iterator-generic.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 // Array.prototype.iterator is generic.
     2 // That is, it can be applied to arraylike objects and strings, not just arrays.
     4 load(libdir + "asserts.js");
     5 load(libdir + "iteration.js");
     7 function test(obj) {
     8     var it = Array.prototype[std_iterator].call(obj);
     9     var ki = Array.prototype.keys.call(obj);
    10     var ei = Array.prototype.entries.call(obj);
    11     for (var i = 0; i < (obj.length >>> 0); i++) {
    12         assertIteratorNext(it, obj[i]);
    13         assertIteratorNext(ki, i);
    14         assertIteratorNext(ei, [i, obj[i]]);
    15     }
    16     assertIteratorDone(it, undefined);
    17     assertIteratorDone(ki, undefined);
    18     assertIteratorDone(ei, undefined);
    19 }
    21 test({length: 0});
    22 test({length: 0, 0: 'x', 1: 'y'});
    23 test({length: 2, 0: 'x', 1: 'y'});
    24 test(Object.create(['x', 'y', 'z']));
    25 test(Object.create({length: 2, 0: 'x', 1: 'y'}));
    26 test("");
    27 test("ponies");
    29 // Perverse length values.
    30 test({length: 0x1f00000000});
    31 test({length: -0xfffffffe, 0: 'a', 1: 'b'});
    32 test({length: "011", 9: 9, 10: 10, 11: 11});
    33 test({length: -0});
    34 test({length: 2.7, 0: 0, 1: 1, 2: 2});
    35 test({length: {valueOf: function () { return 3; }}, 0: 0, 1: 1, 2: 2});

mercurial