js/src/jit-test/tests/collections/Map-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

michael@0 1 // map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers.
michael@0 2
michael@0 3 load(libdir + "asserts.js");
michael@0 4 load(libdir + "eqArrayHelper.js");
michael@0 5 load(libdir + "iteration.js");
michael@0 6
michael@0 7 var g = newGlobal();
michael@0 8
michael@0 9 var iterator_fn = Map.prototype[std_iterator];
michael@0 10 assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
michael@0 11 assertThrowsInstanceOf(function () { iterator_fn.call(Set()); }, TypeError);
michael@0 12 var mapw = g.eval("Map([['x', 1], ['y', 2]])");
michael@0 13 assertEqArray(iterator_fn.call(mapw).next().value, ["x", 1]);
michael@0 14
michael@0 15 var next_fn = Map()[std_iterator]().next;
michael@0 16 assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
michael@0 17 assertThrowsInstanceOf(function () { next_fn.call(Set()[std_iterator]()); }, TypeError);
michael@0 18 var iterw = mapw[std_iterator]();
michael@0 19 assertEqArray(next_fn.call(iterw).value, ["x", 1]);
michael@0 20 assertEqArray(next_fn.call(iterw).value, ["y", 2]);
michael@0 21 assertEq(next_fn.call(iterw).done, true);

mercurial