Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // for-of on a proxy causes a predictable sequence of trap calls. |
michael@0 | 2 | |
michael@0 | 3 | load(libdir + "iteration.js"); |
michael@0 | 4 | |
michael@0 | 5 | var s = ''; |
michael@0 | 6 | |
michael@0 | 7 | var i = 0; |
michael@0 | 8 | var next_fn = Proxy.createFunction({}, function () { |
michael@0 | 9 | s += "n"; |
michael@0 | 10 | if (i == 3) |
michael@0 | 11 | return { value: undefined, done: true }; |
michael@0 | 12 | return { value: i++, done: false }; |
michael@0 | 13 | }); |
michael@0 | 14 | |
michael@0 | 15 | var it = Proxy.create({ |
michael@0 | 16 | get: function (receiver, name) { |
michael@0 | 17 | if (name == 'toSource') { |
michael@0 | 18 | s += '?'; |
michael@0 | 19 | return function () 'it'; |
michael@0 | 20 | } |
michael@0 | 21 | assertEq(name, "next"); |
michael@0 | 22 | s += "N"; |
michael@0 | 23 | return next_fn; |
michael@0 | 24 | } |
michael@0 | 25 | }); |
michael@0 | 26 | |
michael@0 | 27 | var iterator_fn = Proxy.createFunction({}, function () { |
michael@0 | 28 | s += 'i'; |
michael@0 | 29 | return it; |
michael@0 | 30 | }); |
michael@0 | 31 | |
michael@0 | 32 | var obj = Proxy.create({ |
michael@0 | 33 | get: function (receiver, name) { |
michael@0 | 34 | assertEq(name, std_iterator); |
michael@0 | 35 | s += "I"; |
michael@0 | 36 | return iterator_fn; |
michael@0 | 37 | } |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | for (var v of obj) |
michael@0 | 41 | s += v; |
michael@0 | 42 | |
michael@0 | 43 | assertEq(s, 'IiNn0Nn1Nn2Nn'); |