summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/forEach
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Array/prototype/forEach
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/forEach')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js42
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js47
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js42
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js50
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js17
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js16
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js45
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js47
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js44
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js44
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js42
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js17
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js72
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/length.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js161
189 files changed, 5540 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js
new file mode 100644
index 0000000000..97ba0e7da3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to undefined
+---*/
+
+
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(undefined); // TypeError is thrown if value is undefined
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js
new file mode 100644
index 0000000000..5111e7439e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to the Math object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = ('[object Math]' === Object.prototype.toString.call(obj));
+}
+
+Math.length = 1;
+Math[0] = 1;
+Array.prototype.forEach.call(Math, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js
new file mode 100644
index 0000000000..b4f123e219
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to Date object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Date;
+}
+
+var obj = new Date();
+obj.length = 1;
+obj[0] = 1;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js
new file mode 100644
index 0000000000..75339e9910
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to RegExp object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof RegExp;
+}
+
+var obj = new RegExp();
+obj.length = 1;
+obj[0] = 1;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js
new file mode 100644
index 0000000000..02a8100a02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to the JSON object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = ('[object JSON]' === Object.prototype.toString.call(obj));
+}
+
+JSON.length = 1;
+JSON[0] = 1;
+Array.prototype.forEach.call(JSON, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js
new file mode 100644
index 0000000000..df44a2e13d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to Error object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Error;
+}
+
+var obj = new Error();
+obj.length = 1;
+obj[0] = 1;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js
new file mode 100644
index 0000000000..4a7d180d32
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to the Arguments object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = ('[object Arguments]' === Object.prototype.toString.call(obj));
+}
+
+var obj = (function() {
+ return arguments;
+}("a", "b"));
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js
new file mode 100644
index 0000000000..e098f04e7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to null
+---*/
+
+
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(null); // TypeError is thrown if value is null
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js
new file mode 100644
index 0000000000..dbeae73b60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to boolean primitive
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Boolean;
+}
+
+Boolean.prototype[0] = true;
+Boolean.prototype.length = 1;
+
+Array.prototype.forEach.call(false, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js
new file mode 100644
index 0000000000..75a5123bd3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to Boolean object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Boolean;
+}
+
+var obj = new Boolean(true);
+obj.length = 2;
+obj[0] = 11;
+obj[1] = 12;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js
new file mode 100644
index 0000000000..68178afdc4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to number primitive
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Number;
+}
+
+Number.prototype[0] = 1;
+Number.prototype.length = 1;
+
+Array.prototype.forEach.call(2.5, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js
new file mode 100644
index 0000000000..cc0ce7ab45
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to Number object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Number;
+}
+
+var obj = new Number(-128);
+obj.length = 2;
+obj[0] = 11;
+obj[1] = 12;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js
new file mode 100644
index 0000000000..50d0615659
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to string primitive
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof String;
+}
+
+Array.prototype.forEach.call("abc", callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js
new file mode 100644
index 0000000000..b87705bec5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to String object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof String;
+}
+
+var obj = new String("abc");
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js
new file mode 100644
index 0000000000..5c6a97e425
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach applied to Function object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = obj instanceof Function;
+}
+
+var obj = function(a, b) {
+ return a + b;
+};
+obj[0] = 11;
+obj[1] = 9;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js
new file mode 100644
index 0000000000..049761cb71
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'length' is own data property on an
+ Array-like object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var obj = {
+ 0: 12,
+ 1: 11,
+ 2: 9,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js
new file mode 100644
index 0000000000..87dd30422d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an inherited accessor property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js
new file mode 100644
index 0000000000..510a7ed21e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an own accessor property without a get function
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+Object.defineProperty(obj, "length", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js
new file mode 100644
index 0000000000..a8bbd6f1af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'length' is own accessor property
+ without a get function that overrides an inherited accessor
+ property on an Array
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+Object.defineProperty(Object.prototype, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+var obj = {
+ 0: 12,
+ 1: 11
+};
+Object.defineProperty(obj, "length", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js
new file mode 100644
index 0000000000..540a8394cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to the Array-like object that
+ 'length' is inherited accessor property without a get function
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var proto = {};
+Object.defineProperty(proto, "length", {
+ set: function() {},
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 11;
+child[1] = 12;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js
new file mode 100644
index 0000000000..f0c0721d9c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to the Array-like object that
+ 'length' property doesn't exist
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js
new file mode 100644
index 0000000000..331c567413
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to the Arguments object, which
+ implements its own property get method
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var func = function(a, b) {
+ arguments[2] = 9;
+ Array.prototype.forEach.call(arguments, callbackfn);
+ return result;
+};
+
+assert(func(12, 11), 'func(12, 11) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js
new file mode 100644
index 0000000000..0635558208
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to String object, which implements
+ its own property get method
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 3);
+}
+
+var str = new String("012");
+
+Array.prototype.forEach.call(str, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js
new file mode 100644
index 0000000000..a18c47d3e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Function object, which
+ implements its own property get method
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var fun = function(a, b) {
+ return a + b;
+};
+fun[0] = 12;
+fun[1] = 11;
+fun[2] = 9;
+
+Array.prototype.forEach.call(fun, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js
new file mode 100644
index 0000000000..9bd8645233
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - 'length' is own data property on an Array
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+[12, 11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js
new file mode 100644
index 0000000000..19b2e2c686
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'length' is an own data property that
+ overrides an inherited data property on an Array-like object
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {
+ length: 3
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js
new file mode 100644
index 0000000000..bc7c2f0566
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'length' is own data property that
+ overrides an inherited data property on an Array
+---*/
+
+var result = false;
+var arrProtoLen;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+arrProtoLen = Array.prototype.length;
+Array.prototype.length = 0;
+[12, 11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js
new file mode 100644
index 0000000000..4b7348b4d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an own data property that overrides an inherited accessor property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+Object.defineProperty(child, "length", {
+ value: 2,
+ configurable: true
+});
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js
new file mode 100644
index 0000000000..19a8f05448
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an inherited data property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {
+ length: 2
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js
new file mode 100644
index 0000000000..cf5c407755
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an own accessor property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+obj[0] = 12;
+obj[1] = 11;
+obj[2] = 9;
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js
new file mode 100644
index 0000000000..0cc7d8f8fe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an own accessor property that overrides an inherited data property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {
+ length: 3
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+Object.defineProperty(child, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js
new file mode 100644
index 0000000000..418e0fd618
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach applied to Array-like object, 'length' is
+ an own accessor property that overrides an inherited accessor
+ property
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+Object.defineProperty(child, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js
new file mode 100644
index 0000000000..1ed6f554e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - value of 'length' is undefined
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 0,
+ 1: 1,
+ length: undefined
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js
new file mode 100644
index 0000000000..d55c5ae5a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ NaN)
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 9,
+ length: NaN
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js
new file mode 100644
index 0000000000..5f38eed122
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-11
+description: >
+ Array.prototype.forEach - 'length' is a string containing a
+ positive number
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js
new file mode 100644
index 0000000000..88182344e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-12
+description: >
+ Array.prototype.forEach - 'length' is a string containing a
+ negative number
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "-4294967294"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js
new file mode 100644
index 0000000000..2e02b153dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-13
+description: >
+ Array.prototype.forEach - 'length' is a string containing a
+ decimal number
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2.5"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js
new file mode 100644
index 0000000000..caea1bfe8a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-14
+description: Array.prototype.forEach - 'length' is a string containing -Infinity
+---*/
+
+var accessed2 = false;
+
+function callbackfn2(val, idx, obj) {
+ accessed2 = true;
+}
+
+var obj2 = {
+ 0: 9,
+ length: "-Infinity"
+};
+
+Array.prototype.forEach.call(obj2, callbackfn2);
+
+assert.sameValue(accessed2, false, 'accessed2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js
new file mode 100644
index 0000000000..ad9ff226e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-15
+description: >
+ Array.prototype.forEach - 'length' is a string containing an
+ exponential number
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2E0"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js
new file mode 100644
index 0000000000..142e67ae2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-16
+description: >
+ Array.prototype.forEach - 'length' is a string containing a hex
+ number
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "0x0002"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js
new file mode 100644
index 0000000000..02f6f4a92c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-17
+description: >
+ Array.prototype.forEach - 'length' is a string containing a number
+ with leading zeros
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "0002.00"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js
new file mode 100644
index 0000000000..e86eadea72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-18
+description: >
+ Array.prototype.forEach - value of 'length' is a string that can't
+ convert to a number
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 9,
+ length: "asdf!_"
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js
new file mode 100644
index 0000000000..eca8094b8c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-19
+description: >
+ Array.prototype.forEach - value of 'length' is an Object which has
+ an own toString method.
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ toString: function() {
+ return '2';
+ }
+ }
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js
new file mode 100644
index 0000000000..f4a7dd3612
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-2
+description: >
+ Array.prototype.forEach - value of 'length' is a boolean (value is
+ true)
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 0: 11,
+ 1: 9,
+ length: true
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js
new file mode 100644
index 0000000000..a8afca0e75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-20
+description: >
+ Array.prototype.forEach - value of 'length' is an Object which has
+ an own valueOf method.
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ valueOf: function() {
+ return 2;
+ }
+ }
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js
new file mode 100644
index 0000000000..f03f2ac619
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-21
+description: >
+ Array.prototype.forEach - 'length' is an object that has an own
+ valueOf method that returns an object and toString method that
+ returns a string
+---*/
+
+var testResult = false;
+var firstStepOccured = false;
+var secondStepOccured = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ valueOf: function() {
+ firstStepOccured = true;
+ return {};
+ },
+ toString: function() {
+ secondStepOccured = true;
+ return '2';
+ }
+ }
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(firstStepOccured, 'firstStepOccured !== true');
+assert(secondStepOccured, 'secondStepOccured !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js
new file mode 100644
index 0000000000..db0322d283
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-22
+description: >
+ Array.prototype.forEach throws TypeError exception when 'length'
+ is an object with toString and valueOf methods that don�t return
+ primitive values
+---*/
+
+var accessed = false;
+var firstStepOccured = false;
+var secondStepOccured = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 1: 11,
+ 2: 12,
+
+ length: {
+ valueOf: function() {
+ firstStepOccured = true;
+ return {};
+ },
+ toString: function() {
+ secondStepOccured = true;
+ return {};
+ }
+ }
+};
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(obj, callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js
new file mode 100644
index 0000000000..924f5cf975
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-23
+description: >
+ Array.prototype.forEach uses inherited valueOf method when
+ 'length' is an object with an own toString and inherited valueOf
+ methods
+---*/
+
+var testResult = false;
+var valueOfAccessed = false;
+var toStringAccessed = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var proto = {
+ valueOf: function() {
+ valueOfAccessed = true;
+ return 2;
+ }
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+child.toString = function() {
+ toStringAccessed = true;
+ return '1';
+};
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: child
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(valueOfAccessed, 'valueOfAccessed !== true');
+assert.sameValue(toStringAccessed, false, 'toStringAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js
new file mode 100644
index 0000000000..b0f05c4b35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-24
+description: >
+ Array.prototype.forEach - value of 'length' is a positive
+ non-integer, ensure truncation occurs in the proper direction
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: 2.685
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js
new file mode 100644
index 0000000000..06371424a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-25
+description: >
+ Array.prototype.forEach - value of 'length' is a negative
+ non-integer
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ testResult = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: -4294967294.5
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js
new file mode 100644
index 0000000000..19040140b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-3
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ 0)
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 1,
+ 1: 1,
+ length: 0
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js
new file mode 100644
index 0000000000..4f57dcd698
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-4
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ +0)
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ length: +0
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js
new file mode 100644
index 0000000000..083c6ae27f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-5
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ -0)
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ length: -0
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js
new file mode 100644
index 0000000000..81758b3626
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-6
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ positive)
+---*/
+
+var testResult1 = false;
+
+function callbackfn(val, idx, obj) {
+ testResult1 = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult1, 'testResult1 !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js
new file mode 100644
index 0000000000..bb62f0389b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-7
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ negative)
+---*/
+
+var testResult1 = false;
+
+function callbackfn(val, idx, obj) {
+ testResult1 = (val > 10);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: -4294967294
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(testResult1, false, 'testResult1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js
new file mode 100644
index 0000000000..9fb4239a2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-3-9
+description: >
+ Array.prototype.forEach - value of 'length' is a number (value is
+ -Infinity)
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 9,
+ length: -Infinity
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js
new file mode 100644
index 0000000000..1d2e1adb25
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-1
+description: Array.prototype.forEach throws TypeError if callbackfn is undefined
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js
new file mode 100644
index 0000000000..4cfc18c34a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-10
+description: >
+ Array.prototype.forEach - the exception is not thrown if exception
+ was thrown by step 2
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.forEach.call(obj, undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js
new file mode 100644
index 0000000000..b1c38f7f26
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-11
+description: >
+ Array.prototype.forEach - the exception is not thrown if exception
+ was thrown by step 3
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ throw new Test262Error();
+ }
+ };
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.forEach.call(obj, undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js
new file mode 100644
index 0000000000..7193be7253
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-12
+description: Array.prototype.forEach - 'callbackfn' is a function
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+[11, 9].forEach(callbackfn);
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js
new file mode 100644
index 0000000000..1f21e7ce32
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-15
+description: >
+ Array.prototype.forEach - calling with no callbackfn is the same
+ as passing undefined for callbackfn
+---*/
+
+var obj = {
+ 10: 10
+};
+var lengthAccessed = false;
+var loopAccessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ lengthAccessed = true;
+ return 20;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ loopAccessed = true;
+ return 10;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(obj);
+});
+assert(lengthAccessed, 'lengthAccessed !== true');
+assert.sameValue(loopAccessed, false, 'loopAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js
new file mode 100644
index 0000000000..d2314173b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js
@@ -0,0 +1,17 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-2
+description: >
+ Array.prototype.forEach throws ReferenceError if callbackfn is
+ unreferenced
+---*/
+
+var arr = new Array(10);
+assert.throws(ReferenceError, function() {
+ arr.forEach(foo);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js
new file mode 100644
index 0000000000..7ac0d0c314
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-3
+description: Array.prototype.forEach throws TypeError if callbackfn is null
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach(null);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js
new file mode 100644
index 0000000000..99a096fa93
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-4
+description: Array.prototype.forEach throws TypeError if callbackfn is boolean
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach(true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js
new file mode 100644
index 0000000000..5a755627e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-5
+description: Array.prototype.forEach throws TypeError if callbackfn is number
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach(5);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js
new file mode 100644
index 0000000000..c4d9f4388f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+es5id: 15.4.4.18-4-6
+description: Array.prototype.forEach throws TypeError if callbackfn is string
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach("abc");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js
new file mode 100644
index 0000000000..300b7b9b13
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach throws TypeError if callbackfn is Object
+ without Call internal method
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.forEach(new Object());
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js
new file mode 100644
index 0000000000..7bec9f84e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - side effects produced by step 2 are
+ visible when an exception occurs
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ accessed = true;
+ return 2;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(obj, null);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js
new file mode 100644
index 0000000000..4d9a7dc9c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - side effects produced by step 3 are
+ visible when an exception occurs
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ accessed = true;
+ return "2";
+ }
+ };
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.forEach.call(obj, null);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js
new file mode 100644
index 0000000000..8278ff7e27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg not passed to strict callbackfn
+flags: [noStrict]
+---*/
+
+var innerThisCorrect = false;
+
+function callbackfn(val, idx, obj) {
+ "use strict";
+ innerThisCorrect = this === undefined;
+ return true;
+}
+
+[1].forEach(callbackfn);
+
+assert(innerThisCorrect, 'innerThisCorrect !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js
new file mode 100644
index 0000000000..51cf3aa3b4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg is passed
+flags: [noStrict]
+---*/
+
+(function() {
+ this._15_4_4_18_5_1 = false;
+ var _15_4_4_18_5_1 = true;
+ var result;
+
+ function callbackfn(val, idx, obj) {
+ result = this._15_4_4_18_5_1;
+ }
+ var arr = [1];
+ arr.forEach(callbackfn)
+
+ assert.sameValue(result, false, 'result');
+})();
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js
new file mode 100644
index 0000000000..b08d9a9bbf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Array Object can be used as thisArg
+---*/
+
+var result = false;
+var objArray = [];
+
+function callbackfn(val, idx, obj) {
+ result = (this === objArray);
+}
+
+[11].forEach(callbackfn, objArray);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js
new file mode 100644
index 0000000000..d8117261de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - String Object can be used as thisArg
+---*/
+
+var result = false;
+var objString = new String();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objString);
+}
+
+[11].forEach(callbackfn, objString);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js
new file mode 100644
index 0000000000..e8f8fd0b10
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Boolean Object can be used as thisArg
+---*/
+
+var result = false;
+var objBoolean = new Boolean();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objBoolean);
+}
+
+[11].forEach(callbackfn, objBoolean);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js
new file mode 100644
index 0000000000..ca75a95c46
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Number Object can be used as thisArg
+---*/
+
+var result = false;
+var objNumber = new Number();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objNumber);
+}
+
+[11].forEach(callbackfn, objNumber);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js
new file mode 100644
index 0000000000..1fecc909bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - the Math object can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this === Math);
+}
+
+[11].forEach(callbackfn, Math);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js
new file mode 100644
index 0000000000..a4d1caf0f3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Date Object can be used as thisArg
+---*/
+
+var result = false;
+var objDate = new Date();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objDate);
+}
+
+[11].forEach(callbackfn, objDate);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js
new file mode 100644
index 0000000000..76619c117a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - RegExp Object can be used as thisArg
+---*/
+
+var result = false;
+var objRegExp = new RegExp();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objRegExp);
+}
+
+[11].forEach(callbackfn, objRegExp);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js
new file mode 100644
index 0000000000..5285ac8814
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - the JSON object can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this === JSON);
+}
+
+[11].forEach(callbackfn, JSON);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js
new file mode 100644
index 0000000000..a0dc54973e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Error Object can be used as thisArg
+---*/
+
+var result = false;
+var objError = new RangeError();
+
+function callbackfn(val, idx, obj) {
+ result = (this === objError);
+}
+
+[11].forEach(callbackfn, objError);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js
new file mode 100644
index 0000000000..85a5e1eb73
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - the Arguments object can be used as
+ thisArg
+---*/
+
+var result = false;
+var arg;
+
+function callbackfn(val, idx, obj) {
+ result = (this === arg);
+}
+
+(function fun() {
+ arg = arguments;
+}(1, 2, 3));
+
+[11].forEach(callbackfn, arg);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js
new file mode 100644
index 0000000000..43b1b871e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg is Object
+---*/
+
+var res = false;
+var o = new Object();
+o.res = true;
+var result;
+
+function callbackfn(val, idx, obj)
+{
+ result = this.res;
+}
+
+var arr = [1];
+arr.forEach(callbackfn, o)
+
+assert.sameValue(result, true, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js
new file mode 100644
index 0000000000..6fdb94c24f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - the global object can be used as thisArg
+---*/
+
+var global = this;
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this === global);
+}
+
+[11].forEach(callbackfn, this);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js
new file mode 100644
index 0000000000..e947218cdb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - boolean primitive can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this.valueOf() === false);
+}
+
+[11].forEach(callbackfn, false);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js
new file mode 100644
index 0000000000..6a4c52b911
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - number primitive can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this.valueOf() === 101);
+}
+
+[11].forEach(callbackfn, 101);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js
new file mode 100644
index 0000000000..7888f3042f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - string primitive can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this.valueOf() === "abc");
+}
+
+[11].forEach(callbackfn, "abc");
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js
new file mode 100644
index 0000000000..32ab29eaf1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg not passed
+flags: [noStrict]
+---*/
+
+function innerObj() {
+ this._15_4_4_18_5_25 = true;
+ var _15_4_4_18_5_25 = false;
+ var result;
+
+ function callbackfn(val, idx, obj) {
+ result = this._15_4_4_18_5_25;
+ }
+ var arr = [1];
+ arr.forEach(callbackfn)
+ this.retVal = !result;
+}
+
+assert(new innerObj().retVal, 'new innerObj().retVal !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js
new file mode 100644
index 0000000000..f31bf20aac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg is Array
+---*/
+
+var res = false;
+var a = new Array();
+a.res = true;
+var result;
+
+function callbackfn(val, idx, obj)
+{
+ result = this.res;
+}
+
+var arr = [1];
+arr.forEach(callbackfn, a)
+
+assert.sameValue(result, true, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js
new file mode 100644
index 0000000000..fe1ed7f8bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - thisArg is object from object
+ template(prototype)
+---*/
+
+var res = false;
+var result;
+
+function callbackfn(val, idx, obj)
+{
+ result = this.res;
+}
+
+function foo() {}
+foo.prototype.res = true;
+var f = new foo();
+var arr = [1];
+arr.forEach(callbackfn, f)
+
+assert.sameValue(result, true, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js
new file mode 100644
index 0000000000..7ebb9bec1a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg is object from object template
+---*/
+
+var res = false;
+var result;
+
+function callbackfn(val, idx, obj)
+{
+ result = this.res;
+}
+
+function foo() {}
+var f = new foo();
+f.res = true;
+
+var arr = [1];
+arr.forEach(callbackfn, f)
+
+assert.sameValue(result, true, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js
new file mode 100644
index 0000000000..e0d807f48f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - thisArg is function
+---*/
+
+var res = false;
+var result;
+
+function callbackfn(val, idx, obj)
+{
+ result = this.res;
+}
+
+function foo() {}
+foo.res = true;
+
+var arr = [1];
+arr.forEach(callbackfn, foo)
+
+assert.sameValue(result, true, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js
new file mode 100644
index 0000000000..367fef55bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - built-in functions can be used as thisArg
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this === eval);
+}
+
+[11].forEach(callbackfn, eval);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js
new file mode 100644
index 0000000000..c5dd67ec2e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - Function Object can be used as thisArg
+---*/
+
+var result = false;
+var objString = function() {};
+
+function callbackfn(val, idx, obj) {
+ result = (this === objString);
+}
+
+[11].forEach(callbackfn, objString);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js
new file mode 100644
index 0000000000..0c29176657
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't consider new elements added to
+ array after the call
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ callCnt++;
+ arr[2] = 3;
+ arr[5] = 6;
+}
+
+var arr = [1, 2, , 4, 5];
+arr.forEach(callbackfn);
+
+assert.sameValue(callCnt, 5, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js
new file mode 100644
index 0000000000..1fc9736bf3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't visit deleted elements in array
+ after the call
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ if (callCnt == 0)
+ delete arr[3];
+ callCnt++;
+}
+
+var arr = [1, 2, 3, 4, 5];
+arr.forEach(callbackfn)
+
+assert.sameValue(callCnt, 4, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js
new file mode 100644
index 0000000000..a45f1903ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't visit deleted elements when
+ Array.length is decreased
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ arr.length = 3;
+ callCnt++;
+}
+
+var arr = [1, 2, 3, 4, 5];
+arr.forEach(callbackfn);
+
+assert.sameValue(callCnt, 3, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js
new file mode 100644
index 0000000000..28e8d05102
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't consider newly added elements in
+ sparse array
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ arr[1000] = 3;
+ callCnt++;
+}
+
+var arr = new Array(10);
+arr[1] = 1;
+arr[2] = 2;
+arr.forEach(callbackfn);
+
+assert.sameValue(callCnt, 2, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js
new file mode 100644
index 0000000000..aa7a3a8904
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach visits deleted element in array after the
+ call when same index is also present in prototype
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ delete arr[4];
+ callCnt++;
+}
+
+Array.prototype[4] = 5;
+
+var arr = [1, 2, 3, 4, 5];
+arr.forEach(callbackfn)
+delete Array.prototype[4];
+
+assert.sameValue(callCnt, 5, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js
new file mode 100644
index 0000000000..18acb0f63f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - considers new value of elements in array
+ after the call
+---*/
+
+var result = false;
+var arr = [1, 2, 3, 4, 5];
+
+function callbackfn(val, Idx, obj) {
+ arr[4] = 6;
+ if (val >= 6) {
+ result = true;
+ }
+}
+
+arr.forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js
new file mode 100644
index 0000000000..f51e436e8e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - no observable effects occur if len is 0
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ 1: 12,
+ length: 0
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js
new file mode 100644
index 0000000000..ea7e1ad1be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - modifications to length don't change
+ number of iterations
+---*/
+
+var called = 0;
+
+function callbackfn(val, idx, obj) {
+ called++;
+}
+
+var obj = {
+ 1: 12,
+ 2: 9,
+ length: 2
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ obj.length = 3;
+ return 11;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert.sameValue(called, 2, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js
new file mode 100644
index 0000000000..70ea37fdaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn not called for indexes never
+ been assigned values
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ callCnt++;
+}
+
+var arr = new Array(10);
+arr[1] = undefined;
+arr.forEach(callbackfn);
+
+assert.sameValue(callCnt, 1, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js
new file mode 100644
index 0000000000..ac9a9d81d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting property of prototype causes
+ prototype index property not to be visited on an Array-like Object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 3) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 2: 2,
+ length: 20
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete Object.prototype[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[1] = 1;
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js
new file mode 100644
index 0000000000..e0d9dfd150
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting property of prototype causes
+ prototype index property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [0, , ];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete Array.prototype[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js
new file mode 100644
index 0000000000..38910365bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting own property with prototype
+ property causes prototype index property to be visited on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ 0: 0,
+ 1: 111,
+ length: 10
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[1] = 1;
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js
new file mode 100644
index 0000000000..cf28d94eba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting own property with prototype
+ property causes prototype index property to be visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+var arr = [0, 111];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js
new file mode 100644
index 0000000000..d2f5569cd6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - decreasing length of array causes index
+ property not to be visited
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 3) {
+ testResult = false;
+ }
+}
+
+var arr = [0, 1, 2, "last"];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 3;
+ return 0;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js
new file mode 100644
index 0000000000..f62b2ac9ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - decreasing length of array with
+ prototype property causes prototype index property to be visited
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 2 && val === "prototype") {
+ testResult = true;
+ }
+}
+var arr = [0, 1, 2];
+
+Object.defineProperty(Array.prototype, "2", {
+ get: function() {
+ return "prototype";
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js
new file mode 100644
index 0000000000..f29cfd513a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - decreasing length of array does not
+ delete non-configurable properties
+flags: [noStrict]
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 2 && val === "unconfigurable") {
+ testResult = true;
+ }
+}
+
+var arr = [0, 1, 2];
+
+Object.defineProperty(arr, "2", {
+ get: function() {
+ return "unconfigurable";
+ },
+ configurable: false
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js
new file mode 100644
index 0000000000..abf2a576a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - added properties in step 2 are visible
+ here
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 2 && val === "length") {
+ testResult = true;
+ }
+}
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ obj[2] = "length";
+ return 3;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js
new file mode 100644
index 0000000000..8e0f1cc5f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleted properties in step 2 are visible
+ here
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 8) {
+ testResult = false;
+ }
+}
+var obj = {
+ 2: 6.99,
+ 8: 19
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ delete obj[8];
+ return 10;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js
new file mode 100644
index 0000000000..adcf620909
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - properties added into own object after
+ current position are visited on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 2
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ Object.defineProperty(obj, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js
new file mode 100644
index 0000000000..d655dd4446
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - properties added into own object after
+ current position are visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(arr, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js
new file mode 100644
index 0000000000..1d2e41de3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - properties can be added to prototype
+ after current position are visited on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 2
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ Object.defineProperty(Object.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js
new file mode 100644
index 0000000000..7763aba2ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - properties can be added to prototype
+ after current position are visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js
new file mode 100644
index 0000000000..9a9280f206
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting own property causes index
+ property not to be visited on an Array-like object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ length: 2
+};
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js
new file mode 100644
index 0000000000..87215222d1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - deleting own property causes index
+ property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [1, 2];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ return "6.99";
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js
new file mode 100644
index 0000000000..2429652961
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property on an Array-like object
+---*/
+
+var kValue = {};
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 5) {
+ testResult = (val === kValue);
+ }
+}
+
+var obj = {
+ 5: kValue,
+ length: 100
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js
new file mode 100644
index 0000000000..bb272475be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 2) {
+ testResult = (val === 12);
+ }
+}
+
+var arr = [];
+
+Object.defineProperty(arr, "2", {
+ get: function() {
+ return 12;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js
new file mode 100644
index 0000000000..18dc9af824
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property that overrides an inherited data property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+var proto = {
+ 0: 5
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 10;
+
+Object.defineProperty(child, "0", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js
new file mode 100644
index 0000000000..5b34577fdf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 111);
+ }
+}
+
+var arr = [];
+
+Array.prototype[0] = 10;
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ return 111;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js
new file mode 100644
index 0000000000..7fb479567f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (val === 12);
+ }
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "1", {
+ get: function() {
+ return 6;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 10;
+
+Object.defineProperty(child, "1", {
+ get: function() {
+ return 12;
+ },
+ configurable: true
+});
+
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js
new file mode 100644
index 0000000000..080e5935e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+var arr = [];
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 5;
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js
new file mode 100644
index 0000000000..5740ee349d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (val === 11);
+ }
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "1", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 20;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js
new file mode 100644
index 0000000000..ea98a4d6b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+[, , , ].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js
new file mode 100644
index 0000000000..d9bf6b0a33
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+var obj = {
+ length: 2
+};
+Object.defineProperty(obj, "1", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js
new file mode 100644
index 0000000000..88a693c4cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property without a get function on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+var arr = [];
+
+Object.defineProperty(arr, "0", {
+ set: function() {},
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js
new file mode 100644
index 0000000000..9f1fef59e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+var obj = {
+ length: 2
+};
+
+Object.defineProperty(obj, "1", {
+ set: function() {},
+ configurable: true
+});
+
+Object.defineProperty(Object.prototype, "1", {
+ get: function() {
+ return 10;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js
new file mode 100644
index 0000000000..c4e3437176
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+[11].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js
new file mode 100644
index 0000000000..bc7eece0d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+var arr = [];
+
+Object.defineProperty(arr, "0", {
+ set: function() {},
+ configurable: true
+});
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 100;
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js
new file mode 100644
index 0000000000..65b1578f4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ accessor property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+var proto = {};
+Object.defineProperty(proto, "1", {
+ set: function() {},
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js
new file mode 100644
index 0000000000..030984b6ae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ accessor property without a get function on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (typeof val === "undefined");
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ set: function() {},
+ configurable: true
+});
+
+[, 1].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js
new file mode 100644
index 0000000000..4bc4a559d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - This object is the Arguments object
+ which implements its own property get method (number of arguments
+ is less than number of parameters)
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+var func = function(a, b) {
+ return Array.prototype.forEach.call(arguments, callbackfn);
+};
+
+func(11);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js
new file mode 100644
index 0000000000..ad057763a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - This object is the Arguments object
+ which implements its own property get method (number of arguments
+ equals number of parameters)
+---*/
+
+var called = 0;
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ called++;
+ if (called !== 1 && !testResult) {
+ return;
+ }
+ if (idx === 0) {
+ testResult = (val === 11);
+ } else if (idx === 1) {
+ testResult = (val === 9);
+ } else {
+ testResult = false;
+ }
+}
+
+var func = function(a, b) {
+ Array.prototype.forEach.call(arguments, callbackfn);
+};
+
+func(11, 9);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js
new file mode 100644
index 0000000000..df73d8e952
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - This object is the Arguments object
+ which implements its own property get method (number of arguments
+ is greater than number of parameters)
+---*/
+
+var called = 0;
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ called++;
+ if (called !== 1 && !testResult) {
+ return;
+ }
+ if (idx === 0) {
+ testResult = (val === 11);
+ } else if (idx === 1) {
+ testResult = (val === 12);
+ } else if (idx === 2) {
+ testResult = (val === 9);
+ } else {
+ testResult = false;
+ }
+}
+
+var func = function(a, b) {
+ return Array.prototype.forEach.call(arguments, callbackfn);
+};
+
+func(11, 12, 9);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js
new file mode 100644
index 0000000000..abc425cba1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element changed by getter on previous
+ iterations is observed on an Array
+---*/
+
+var preIterVisible = false;
+var arr = [];
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (val === 9);
+ }
+}
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 11;
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 9;
+ } else {
+ return 13;
+ }
+ },
+ configurable: true
+});
+
+arr.forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js
new file mode 100644
index 0000000000..9305183494
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element changed by getter on previous
+ iterations is observed on an Array-like object
+---*/
+
+var preIterVisible = false;
+var obj = {
+ length: 2
+};
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (val === 9);
+ }
+}
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 11;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 9;
+ } else {
+ return 13;
+ }
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js
new file mode 100644
index 0000000000..452169dd64
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property that overrides an inherited data property on an Array
+---*/
+
+var kValue = "abc";
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 5) {
+ testResult = (val === kValue);
+ }
+}
+
+var proto = {
+ 5: 100
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[5] = kValue;
+child.length = 10;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js
new file mode 100644
index 0000000000..a5f13d4a8f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - unnhandled exceptions happened in getter
+ terminate iteration on an Array-like object
+---*/
+
+var obj = {
+ 0: 11,
+ 5: 10,
+ 10: 8,
+ length: 20
+};
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx > 1) {
+ accessed = true;
+ }
+}
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "2", {
+ get: function() {
+ accessed = true;
+ return 100;
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ Array.prototype.forEach.call(obj, callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js
new file mode 100644
index 0000000000..ff02a77f42
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - unnhandled exceptions happened in getter
+ terminate iteration on an Array-like object
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx > 1) {
+ accessed = true;
+ }
+}
+
+var arr = [];
+arr[5] = 10;
+arr[10] = 100;
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "2", {
+ get: function() {
+ accessed = true;
+ return 100;
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ arr.forEach(callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js
new file mode 100644
index 0000000000..77723a140d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 12);
+ }
+}
+
+Array.prototype[0] = 11;
+
+[12].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js
new file mode 100644
index 0000000000..28cd165e2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "0", {
+ get: function() {
+ return 5;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+Object.defineProperty(child, "0", {
+ value: 11,
+ configurable: true
+});
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js
new file mode 100644
index 0000000000..ac934eb873
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own data
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 9;
+ },
+ configurable: true
+});
+
+[11].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js
new file mode 100644
index 0000000000..0305cacd69
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ data property on an Array-like object
+---*/
+
+var kValue = 'abc';
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 5) {
+ testResult = (val === kValue);
+ }
+}
+
+var proto = {
+ 5: kValue
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 10;
+
+Array.prototype.forEach.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js
new file mode 100644
index 0000000000..dc0ec1d057
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is inherited
+ data property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 1) {
+ testResult = (val === 13);
+ }
+}
+
+Array.prototype[1] = 13;
+
+[, , , ].forEach(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js
new file mode 100644
index 0000000000..9d1965e41e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element to be retrieved is own accessor
+ property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ testResult = (val === 11);
+ }
+}
+
+var obj = {
+ 10: 10,
+ length: 20
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js
new file mode 100644
index 0000000000..1f3b53eb79
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - callbackfn called with correct parameters
+---*/
+
+var bPar = true;
+var bCalled = false;
+
+function callbackfn(val, idx, obj)
+{
+ bCalled = true;
+ if (obj[idx] !== val)
+ bPar = false;
+}
+
+var arr = [0, 1, true, null, new Object(), "five"];
+arr[999999] = -6.6;
+arr.forEach(callbackfn);
+
+assert.sameValue(bCalled, true, 'bCalled');
+assert.sameValue(bPar, true, 'bPar');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js
new file mode 100644
index 0000000000..99217f9bf4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn is called with 1 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(val) {
+ result = (val > 10);
+}
+
+[11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js
new file mode 100644
index 0000000000..a1a127ca15
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn is called with 2 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(val, idx) {
+ result = (val > 10 && arguments[2][idx] === val);
+}
+
+[11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js
new file mode 100644
index 0000000000..fb47d7acd2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn is called with 3 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (val > 10 && obj[idx] === val);
+}
+
+[11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js
new file mode 100644
index 0000000000..086f238342
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - callbackfn that uses arguments
+---*/
+
+var result = false;
+
+function callbackfn() {
+ result = (arguments[2][arguments[1]] === arguments[0]);
+}
+
+[11].forEach(callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js
new file mode 100644
index 0000000000..a7c21f463c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'this' of 'callbackfn' is a Boolean
+ object when T is not an object (T is a boolean)
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (this.valueOf() !== false);
+}
+
+var obj = {
+ 0: 11,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn, false);
+
+assert.sameValue(result, false, 'result');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js
new file mode 100644
index 0000000000..2e7607e51c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'this' of 'callbackfn' is a Number
+ object when T is not an object (T is a number)
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, o) {
+ result = (5 === this.valueOf());
+}
+
+var obj = {
+ 0: 11,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn, 5);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js
new file mode 100644
index 0000000000..cf17e5b042
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - 'this' of 'callbackfn' is an String
+ object when T is not an object (T is a string)
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = ('hello' === this.valueOf());
+}
+
+var obj = {
+ 0: 11,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn, "hello");
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js
new file mode 100644
index 0000000000..245fc6dace
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - non-indexed properties are not called
+---*/
+
+var accessed = false;
+var result = true;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+ if (val === 8) {
+ result = false;
+ }
+}
+
+var obj = {
+ 0: 11,
+ 10: 12,
+ non_index_property: 8,
+ length: 20
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js
new file mode 100644
index 0000000000..2e5856e588
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - callbackfn takes 3 arguments
+---*/
+
+var parCnt = 3;
+var bCalled = false
+
+function callbackfn(val, idx, obj)
+{
+ bCalled = true;
+ if (arguments.length !== 3)
+ parCnt = arguments.length; //verify if callbackfn was called with 3 parameters
+}
+
+var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+arr.forEach(callbackfn);
+
+assert.sameValue(bCalled, true, 'bCalled');
+assert.sameValue(parCnt, 3, 'parCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js
new file mode 100644
index 0000000000..e496519e96
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn called with correct
+ parameters (thisArg is correct)
+---*/
+
+var result = false;
+
+function callbackfn(val, idx, obj) {
+ result = (10 === this.threshold);
+}
+
+var thisArg = {
+ threshold: 10
+};
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+Array.prototype.forEach.call(obj, callbackfn, thisArg);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js
new file mode 100644
index 0000000000..3db90a4e84
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn called with correct
+ parameters (kValue is correct)
+---*/
+
+var resultOne = false;
+var resultTwo = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx === 0) {
+ resultOne = (val === 11);
+ }
+
+ if (idx === 1) {
+ resultTwo = (val === 12);
+ }
+
+}
+
+var obj = {
+ 0: 11,
+ 1: 12,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(resultOne, 'resultOne !== true');
+assert(resultTwo, 'resultTwo !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js
new file mode 100644
index 0000000000..5d985427a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn called with correct
+ parameters (the index k is correct)
+---*/
+
+var resultOne = false;
+var resultTwo = false;
+
+function callbackfn(val, idx, obj) {
+ if (val === 11) {
+ resultOne = (idx === 0);
+ }
+
+ if (val === 12) {
+ resultTwo = (idx === 1);
+ }
+
+}
+
+var obj = {
+ 0: 11,
+ 1: 12,
+ length: 2
+};
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(resultOne, 'resultOne !== true');
+assert(resultTwo, 'resultTwo !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js
new file mode 100644
index 0000000000..1a4e848648
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn called with correct
+ parameters (this object O is correct)
+---*/
+
+var result = false;
+var obj = {
+ 0: 11,
+ length: 2
+};
+
+function callbackfn(val, idx, o) {
+ result = (obj === o);
+}
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js
new file mode 100644
index 0000000000..0be07076bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - k values are passed in ascending numeric
+ order
+---*/
+
+var arr = [0, 1, 2, 3, 4, 5];
+var lastIdx = 0;
+var called = 0;
+var result = true;
+
+function callbackfn(val, idx, o) {
+ called++;
+ if (lastIdx !== idx) {
+ result = false;
+ } else {
+ lastIdx++;
+ }
+}
+
+arr.forEach(callbackfn);
+
+assert(result, 'result !== true');
+assert.sameValue(arr.length, called, 'arr.length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js
new file mode 100644
index 0000000000..b2576859b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - k values are accessed during each
+ iteration and not prior to starting the loop on an Array
+---*/
+
+var result = true;
+var kIndex = [];
+
+//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time.
+function callbackfn(val, idx, obj) {
+ //Each position should be visited one time, which means k is accessed one time during iterations.
+ if (typeof kIndex[idx] === "undefined") {
+ //when current position is visited, its previous index should has been visited.
+ if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") {
+ result = false;
+ }
+ kIndex[idx] = 1;
+ } else {
+ result = false;
+ }
+}
+
+[11, 12, 13, 14].forEach(callbackfn, undefined);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js
new file mode 100644
index 0000000000..725d0cfe81
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - arguments to callbackfn are self
+ consistent
+---*/
+
+var result = false;
+var obj = {
+ 0: 11,
+ length: 1
+};
+var thisArg = {};
+
+function callbackfn() {
+ result = (this === thisArg &&
+ arguments[0] === 11 &&
+ arguments[1] === 0 &&
+ arguments[2] === obj);
+}
+
+Array.prototype.forEach.call(obj, callbackfn, thisArg);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js
new file mode 100644
index 0000000000..412f00a381
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - unhandled exceptions happened in
+ callbackfn terminate iteration
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ if (idx > 0) {
+ accessed = true;
+ }
+ if (idx === 0) {
+ throw new Error("Exception occurred in callbackfn");
+ }
+}
+
+var obj = {
+ 0: 11,
+ 4: 10,
+ 10: 8,
+ length: 20
+};
+assert.throws(Error, function() {
+ Array.prototype.forEach.call(obj, callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js
new file mode 100644
index 0000000000..a6f9f43845
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - element changed by callbackfn on
+ previous iterations is observed
+---*/
+
+var result = false;
+var obj = {
+ 0: 11,
+ 1: 12,
+ length: 2
+};
+
+function callbackfn(val, idx, o) {
+ if (idx === 0) {
+ obj[idx + 1] = 8;
+ }
+
+ if (idx === 1) {
+ result = (val === 8);
+ }
+}
+
+Array.prototype.forEach.call(obj, callbackfn);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js
new file mode 100644
index 0000000000..39f3a8822e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - callbackfn is called with 0 formal
+ parameter
+---*/
+
+var called = 0;
+
+function callbackfn() {
+ called++;
+}
+
+[11, 12].forEach(callbackfn);
+
+assert.sameValue(called, 2, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js
new file mode 100644
index 0000000000..c31720f83e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (empty array)
+---*/
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = [].forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js
new file mode 100644
index 0000000000..e420981f80
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach - subclassed array when length is reduced
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = 1;
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 1, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js
new file mode 100644
index 0000000000..7dfb750468
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't mutate the array on which it is
+ called on
+---*/
+
+function callbackfn(val, idx, obj)
+{
+ return true;
+}
+var arr = [1, 2, 3, 4, 5];
+arr.forEach(callbackfn);
+
+assert.sameValue(arr[0], 1, 'arr[0]');
+assert.sameValue(arr[1], 2, 'arr[1]');
+assert.sameValue(arr[2], 3, 'arr[2]');
+assert.sameValue(arr[3], 4, 'arr[3]');
+assert.sameValue(arr[4], 5, 'arr[4]');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js
new file mode 100644
index 0000000000..d763c47310
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: Array.prototype.forEach doesn't visit expandos
+---*/
+
+var callCnt = 0;
+
+function callbackfn(val, idx, obj)
+{
+ callCnt++;
+}
+var arr = [1, 2, 3, 4, 5];
+arr["i"] = 10;
+arr[true] = 11;
+
+arr.forEach(callbackfn);
+
+assert.sameValue(callCnt, 5, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js
new file mode 100644
index 0000000000..90614a656e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach - undefined will be returned when 'len' is
+ 0
+---*/
+
+var accessed = false;
+
+function callbackfn(val, idx, obj) {
+ accessed = true;
+}
+
+var result = [].forEach(callbackfn);
+
+assert.sameValue(typeof result, "undefined", 'typeof result');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js
new file mode 100644
index 0000000000..1a23bdfd29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden to null (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = null;
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js
new file mode 100644
index 0000000000..91efb92f37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden to false (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = false;
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js
new file mode 100644
index 0000000000..a207068ae4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden to 0 (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = 0;
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js
new file mode 100644
index 0000000000..f9832c79d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden to '0' (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = '0';
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js
new file mode 100644
index 0000000000..e3663c28d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden with obj with valueOf)
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ valueOf: function() {
+ return 0;
+ }
+};
+f.length = o;
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js
new file mode 100644
index 0000000000..8e3ff6bc9a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden with obj w/o valueOf
+ (toString))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ toString: function() {
+ return '0';
+ }
+};
+f.length = o;
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js
new file mode 100644
index 0000000000..0d12ee5fef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden with []
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+f.length = [];
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+//
+// The toString( ) method on Array converts the array elements to strings,
+// then returns the result of concatenating these strings, with commas in
+// between. An array with no elements converts to the empty string, which
+// converts to the number 0. If an array has a single element that is a
+// number n, the array converts to a string representation of n, which is
+// then converted back to n itself. If an array contains more than one element,
+// or if its one element is not a number, the array converts to NaN.
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js
new file mode 100644
index 0000000000..86b1401585
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach doesn't call callbackfn if 'length' is 0
+ (subclassed Array, length overridden with [0]
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+f.length = [0];
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+//
+// The toString( ) method on Array converts the array elements to strings,
+// then returns the result of concatenating these strings, with commas in
+// between. An array with no elements converts to the empty string, which
+// converts to the number 0. If an array has a single element that is a
+// number n, the array converts to a string representation of n, which is
+// then converted back to n itself. If an array contains more than one element,
+// or if its one element is not a number, the array converts to NaN.
+
+var callCnt = 0;
+
+function cb() {
+ callCnt++
+}
+var i = f.forEach(cb);
+
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js
new file mode 100644
index 0000000000..1b43537136
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js
@@ -0,0 +1,14 @@
+// Copyright 2011 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: array.forEach can be frozen while in progress
+esid: sec-array.prototype.foreach
+description: Freezes array.forEach during a forEach to see if it works
+---*/
+
+['z'].forEach(function() {
+ Object.freeze(Array.prototype.forEach);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js
new file mode 100644
index 0000000000..9a0f116a3a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js
@@ -0,0 +1,17 @@
+// Copyright 2011 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: array.forEach can be frozen while in progress
+esid: sec-array.prototype.foreach
+description: Freezes array.forEach during a forEach to see if it works
+---*/
+
+function foo() {
+ ['z'].forEach(function() {
+ Object.freeze(Array.prototype.forEach);
+ });
+}
+foo();
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js
new file mode 100644
index 0000000000..792044dc69
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.forEach
+description: Array.prototype.forEach applied to boolean primitive
+---*/
+
+assert.sameValue(
+ Array.prototype.forEach.call(true, () => {}),
+ undefined,
+ 'Array.prototype.forEach.call(true, () => {}) must return undefined'
+);
+assert.sameValue(
+ Array.prototype.forEach.call(false, () => {}),
+ undefined,
+ 'Array.prototype.forEach.call(false, () => {}) must return undefined'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js
new file mode 100644
index 0000000000..402b9a7007
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js
@@ -0,0 +1,72 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-array.prototype.forEach
+description: TypedArray instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = Array.prototype.forEach.call(sample, function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (shrink)');
+ assert.compareArray(indices, expectedIndices, 'indices (shrink)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (shrink)');
+ assert.sameValue(result, undefined, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = Array.prototype.forEach.call(sample, function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, undefined, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js
new file mode 100644
index 0000000000..8ca4a6185e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.forEach
+description: >
+ The "length" property of Array.prototype.forEach
+info: |
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Array.prototype.forEach.length, 1);
+
+verifyNotEnumerable(Array.prototype.forEach, 'length');
+verifyNotWritable(Array.prototype.forEach, 'length');
+verifyConfigurable(Array.prototype.forEach, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js
new file mode 100644
index 0000000000..08beb915e8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.foreach
+description: >
+ Array.prototype.forEach.name is "forEach".
+info: |
+ Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Array.prototype.forEach.name, "forEach");
+
+verifyNotEnumerable(Array.prototype.forEach, "name");
+verifyNotWritable(Array.prototype.forEach, "name");
+verifyConfigurable(Array.prototype.forEach, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js
new file mode 100644
index 0000000000..9662abaf98
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ Array.prototype.forEach does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(Array.prototype.forEach),
+ false,
+ 'isConstructor(Array.prototype.forEach) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new Array.prototype.forEach(() => {});
+}, '`new Array.prototype.forEach(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js
new file mode 100644
index 0000000000..d26cffd102
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.forEach
+description: >
+ "forEach" property of Array.prototype
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(typeof Array.prototype.forEach, 'function', 'typeof');
+
+verifyNotEnumerable(Array.prototype, "forEach");
+verifyWritable(Array.prototype, "forEach");
+verifyConfigurable(Array.prototype, "forEach");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js
new file mode 100644
index 0000000000..05fecd6ef1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js
@@ -0,0 +1,161 @@
+// GENERATED, DO NOT EDIT
+// file: testTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of TypedArray objects.
+defines:
+ - floatArrayConstructors
+ - nonClampedIntArrayConstructors
+ - intArrayConstructors
+ - typedArrayConstructors
+ - TypedArray
+ - testWithTypedArrayConstructors
+ - nonAtomicsFriendlyTypedArrayConstructors
+ - testWithAtomicsFriendlyTypedArrayConstructors
+ - testWithNonAtomicsFriendlyTypedArrayConstructors
+ - testTypedArrayConversions
+---*/
+
+var floatArrayConstructors = [
+ Float64Array,
+ Float32Array
+];
+
+var nonClampedIntArrayConstructors = [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array
+];
+
+var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]);
+
+// Float16Array is a newer feature
+// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it
+if (typeof Float16Array !== 'undefined') {
+ floatArrayConstructors.push(Float16Array);
+}
+
+/**
+ * Array containing every non-bigint typed array constructor.
+ */
+
+var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors);
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Callback for testing a typed array constructor.
+ *
+ * @callback typedArrayConstructorCallback
+ * @param {Function} Constructor the constructor object to test with.
+ */
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithTypedArrayConstructors(f, selected) {
+ var constructors = selected || typedArrayConstructors;
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
+
+var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]);
+/**
+ * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors);
+}
+
+/**
+ * Calls the provided function for every "Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ ]);
+}
+
+/**
+ * Helper for conversion operations on TypedArrays, the expected values
+ * properties are indexed in order to match the respective value for each
+ * TypedArray constructor
+ * @param {Function} fn - the function to call for each constructor and value.
+ * will be called with the constructor, value, expected
+ * value, and a initial value that can be used to avoid
+ * a false positive with an equivalent expected value.
+ */
+function testTypedArrayConversions(byteConversionValues, fn) {
+ var values = byteConversionValues.values;
+ var expected = byteConversionValues.expected;
+
+ testWithTypedArrayConstructors(function(TA) {
+ var name = TA.name.slice(0, -5);
+
+ return values.forEach(function(value, index) {
+ var exp = expected[name][index];
+ var initial = 0;
+ if (exp === 0) {
+ initial = 1;
+ }
+ fn(TA, value, exp, initial);
+ });
+ });
+}
+
+/**
+ * Checks if the given argument is one of the float-based TypedArray constructors.
+ *
+ * @param {constructor} ctor - the value to check
+ * @returns {boolean}
+ */
+function isFloatTypedArrayConstructor(arg) {
+ return floatArrayConstructors.indexOf(arg) !== -1;
+}
+
+/**
+ * Determines the precision of the given float-based TypedArray constructor.
+ *
+ * @param {constructor} ctor - the value to check
+ * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively.
+ */
+function floatTypedArrayConstructorPrecision(FA) {
+ if (typeof Float16Array !== "undefined" && FA === Float16Array) {
+ return "half";
+ } else if (FA === Float32Array) {
+ return "single";
+ } else if (FA === Float64Array) {
+ return "double";
+ } else {
+ throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray");
+ }
+}