michael@0: // map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers. michael@0: michael@0: load(libdir + "asserts.js"); michael@0: load(libdir + "iteration.js"); michael@0: michael@0: var g = newGlobal(); michael@0: michael@0: var iterator_fn = Set.prototype[std_iterator]; michael@0: assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError); michael@0: assertThrowsInstanceOf(function () { iterator_fn.call(Map()); }, TypeError); michael@0: var setw = g.eval("Set(['x', 'y'])"); michael@0: assertIteratorNext(iterator_fn.call(setw), "x"); michael@0: michael@0: var next_fn = Set()[std_iterator]().next; michael@0: assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError); michael@0: assertThrowsInstanceOf(function () { next_fn.call(Map()[std_iterator]()); }, TypeError); michael@0: var iterw = setw[std_iterator](); michael@0: assertIteratorResult(next_fn.call(iterw), "x", false); michael@0: assertIteratorResult(next_fn.call(iterw), "y", false); michael@0: assertIteratorResult(next_fn.call(iterw), undefined, true);