tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / js / script-tests / array-proto-func-property-getter-except.js
1 description(
2 "This test checks that functions on the array prototype correctly handle exceptions from property getters when called on non-array objects."
3 );
4
5 function test(f) {
6
7     var testObj = {
8         length: 3
9     };
10     var propertyGetter = {
11         get: (function() { throw true; })
12     }
13     Object.defineProperty(testObj, 0, propertyGetter);
14     Object.defineProperty(testObj, 1, propertyGetter);
15     Object.defineProperty(testObj, 2, propertyGetter);
16
17     try {
18         f.call(testObj, function(){});
19         return false;
20     } catch (e) {
21         return e === true;
22     }
23 }
24
25 // This test makes sense for these functions: (they should get all properties on the array)
26 shouldBeTrue("test(Array.prototype.sort)");
27 shouldBeTrue("test(Array.prototype.every)");
28 shouldBeTrue("test(Array.prototype.some)");
29 shouldBeTrue("test(Array.prototype.forEach)");
30 shouldBeTrue("test(Array.prototype.map)");
31 shouldBeTrue("test(Array.prototype.filter)");
32 shouldBeTrue("test(Array.prototype.reduce)");
33 shouldBeTrue("test(Array.prototype.reduceRight)");
34
35 // Probably not testing much of anything in these cases, but make sure they don't crash!
36 shouldBeTrue("test(Array.prototype.join)");
37 shouldBeTrue("test(Array.prototype.pop)");
38 shouldBeFalse("test(Array.prototype.push)");
39 shouldBeTrue("test(Array.prototype.reverse)");
40 shouldBeTrue("test(Array.prototype.shift)");
41 shouldBeTrue("test(Array.prototype.slice)");
42 shouldBeTrue("test(Array.prototype.splice)");
43 shouldBeTrue("test(Array.prototype.unshift)");
44 shouldBeTrue("test(Array.prototype.indexOf)");
45 shouldBeTrue("test(Array.prototype.lastIndexOf)");