js/src/jit-test/tests/collections/Set-iterator-proxies-2.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers.
     3 load(libdir + "asserts.js");
     4 load(libdir + "iteration.js");
     6 var g = newGlobal();
     8 var iterator_fn = Set.prototype[std_iterator];
     9 assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
    10 assertThrowsInstanceOf(function () { iterator_fn.call(Map()); }, TypeError);
    11 var setw = g.eval("Set(['x', 'y'])");
    12 assertIteratorNext(iterator_fn.call(setw), "x");
    14 var next_fn = Set()[std_iterator]().next;
    15 assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
    16 assertThrowsInstanceOf(function () { next_fn.call(Map()[std_iterator]()); }, TypeError);
    17 var iterw = setw[std_iterator]();
    18 assertIteratorResult(next_fn.call(iterw), "x", false);
    19 assertIteratorResult(next_fn.call(iterw), "y", false);
    20 assertIteratorResult(next_fn.call(iterw), undefined, true);

mercurial