1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/for-of/semantics-07.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,17 @@ 1.4 +// Deleting the .next method of an iterator in the middle of a for-of loop 1.5 +// causes a TypeError at the next iteration. 1.6 + 1.7 +load(libdir + "asserts.js"); 1.8 +load(libdir + "iteration.js"); 1.9 + 1.10 +var iterProto = Object.getPrototypeOf([][std_iterator]()); 1.11 +var s = ''; 1.12 +assertThrowsInstanceOf(function () { 1.13 + for (var v of ['duck', 'duck', 'duck', 'goose', 'FAIL']) { 1.14 + s += v; 1.15 + if (v === 'goose') 1.16 + delete iterProto.next; 1.17 + s += '.'; 1.18 + } 1.19 +}, TypeError); 1.20 +assertEq(s, 'duck.duck.duck.goose.');