OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Test for http://code.google.com/p/v8/issues/detail?id=334 | 30 // Test for http://code.google.com/p/v8/issues/detail?id=334 |
31 | 31 |
32 var READ_ONLY = 1; | 32 var READ_ONLY = 1; |
33 var DONT_ENUM = 2; | 33 var DONT_ENUM = 2; |
34 var DONT_DELETE = 4; | 34 var DONT_DELETE = 4; |
35 | 35 |
36 function func1(){} | 36 function func1(){} |
37 function func2(){} | 37 function func2(){} |
38 | 38 |
39 var object = {__proto__:{}}; | 39 var object = {__proto__:{}}; |
40 %SetProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE); | 40 %AddProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE); |
41 %SetProperty(object, "bar", func1, DONT_ENUM | READ_ONLY); | 41 %AddProperty(object, "bar", func1, DONT_ENUM | READ_ONLY); |
42 %SetProperty(object, "baz", func1, DONT_DELETE | READ_ONLY); | 42 %AddProperty(object, "baz", func1, DONT_DELETE | READ_ONLY); |
43 %SetProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE); | 43 %AddProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE); |
44 object.bif = func2; | 44 object.bif = func2; |
45 | 45 |
46 function enumerable(obj) { | 46 function enumerable(obj) { |
47 var res = []; | 47 var res = []; |
48 for (var i in obj) { | 48 for (var i in obj) { |
49 res.push(i); | 49 res.push(i); |
50 } | 50 } |
51 res.sort(); | 51 res.sort(); |
52 return res; | 52 return res; |
53 } | 53 } |
(...skipping 27 matching lines...) Expand all Loading... |
81 assertArrayEquals(["bar", "baz", "bif"], enumerable(object), "enum3"); | 81 assertArrayEquals(["bar", "baz", "bif"], enumerable(object), "enum3"); |
82 | 82 |
83 // Unshadowing a prototype property exposes its attributes. | 83 // Unshadowing a prototype property exposes its attributes. |
84 assertTrue(delete object.bif, "delete bif"); | 84 assertTrue(delete object.bif, "delete bif"); |
85 assertArrayEquals(["bar", "baz"], enumerable(object), "enum4"); | 85 assertArrayEquals(["bar", "baz"], enumerable(object), "enum4"); |
86 assertEquals(func1, object.bif, "read bif 2"); | 86 assertEquals(func1, object.bif, "read bif 2"); |
87 // Can't delete prototype property. | 87 // Can't delete prototype property. |
88 assertTrue(delete object.bif, "delete bif 2"); | 88 assertTrue(delete object.bif, "delete bif 2"); |
89 assertArrayEquals(["bar", "baz"], enumerable(object), "enum5"); | 89 assertArrayEquals(["bar", "baz"], enumerable(object), "enum5"); |
90 assertEquals(func1, object.bif, "read bif3"); | 90 assertEquals(func1, object.bif, "read bif3"); |
OLD | NEW |