diff -r 000000000000 -r 6474c204b198 js/src/jit-test/tests/for-of/proxy-2.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/jit-test/tests/for-of/proxy-2.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,29 @@ +// Basic for-of test with Proxy whose iterator method is a generator. + +var arr = ['a', 'b', 'c', 'd']; +var proxy = Proxy.create({ + getPropertyDescriptor: function (name) { + if (name == 'iterator') { + return { + configurable: false, + enumerable: false, + writeable: false, + value: function () { + for (var i = 0; i < arr.length; i++) + yield arr[i]; + } + }; + } + + // Otherwise, inherit the property from arr. + for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) { + var desc = Object.getOwnPropertyDescriptor(obj, name); + if (desc) + return desc; + } + return undefined; + } +}); + +for (var i = 0; i < 2; i++) + assertEq([v for (v of proxy)].join(","), "a,b,c,d");