michael@0: // Basic for-of test with Proxy whose iterator method is a generator. michael@0: michael@0: var arr = ['a', 'b', 'c', 'd']; michael@0: var proxy = Proxy.create({ michael@0: getPropertyDescriptor: function (name) { michael@0: if (name == 'iterator') { michael@0: return { michael@0: configurable: false, michael@0: enumerable: false, michael@0: writeable: false, michael@0: value: function () { michael@0: for (var i = 0; i < arr.length; i++) michael@0: yield arr[i]; michael@0: } michael@0: }; michael@0: } michael@0: michael@0: // Otherwise, inherit the property from arr. michael@0: for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) { michael@0: var desc = Object.getOwnPropertyDescriptor(obj, name); michael@0: if (desc) michael@0: return desc; michael@0: } michael@0: return undefined; michael@0: } michael@0: }); michael@0: michael@0: for (var i = 0; i < 2; i++) michael@0: assertEq([v for (v of proxy)].join(","), "a,b,c,d");