Debian Codegraph @

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

raw
1 // map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers.
2
3 load(libdir + "asserts.js");
4 load(libdir + "iteration.js");
5
6 var g = newGlobal();
7
8 var iterator_fn = Set.prototype[Symbol.iterator];
9 assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
10 assertThrowsInstanceOf(function () { iterator_fn.call(new Map()); }, TypeError);
11 var setw = g.eval("new Set(['x', 'y'])");
12 assertIteratorNext(iterator_fn.call(setw), "x");
13
14 var next_fn = (new Set())[Symbol.iterator]().next;
15 assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
16 assertThrowsInstanceOf(function () { next_fn.call((new Map())[Symbol.iterator]()); }, TypeError);
17 var iterw = setw[Symbol.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);