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 22 matching lines...) Expand all Loading... | |
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 %SetProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE); |
41 %SetProperty(object, "bar", func1, DONT_ENUM | READ_ONLY); | 41 %SetProperty(object, "bar", func1, DONT_ENUM | READ_ONLY); |
42 %SetProperty(object, "baz", func1, DONT_DELETE | READ_ONLY); | 42 %SetProperty(object, "baz", func1, DONT_DELETE | READ_ONLY); |
43 %SetProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE | READ_ONLY ); | 43 %SetProperty(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 print(i); | |
Michael Starzinger
2012/05/30 13:08:55
Can we remove this debugging code again.
Michael Starzinger
2012/06/01 08:34:04
I think you missed that one.
rossberg
2012/06/01 09:42:48
Indeed, thanks!
| |
50 } | 51 } |
51 res.sort(); | 52 res.sort(); |
52 return res; | 53 return res; |
53 } | 54 } |
54 | 55 |
55 // Sanity check: expected initial state. | 56 // Sanity check: expected initial state. |
56 assertArrayEquals(["baz", "bif"], enumerable(object), "enum0"); | 57 assertArrayEquals(["baz", "bif"], enumerable(object), "enum0"); |
57 assertFalse(delete object.foo, "delete foo"); | 58 assertFalse(delete object.foo, "delete foo"); |
58 assertFalse(delete object.baz, "delete baz"); | 59 assertFalse(delete object.baz, "delete baz"); |
59 assertEquals(func1, object.foo, "read foo"); | 60 assertEquals(func1, object.foo, "read foo"); |
(...skipping 21 matching lines...) Expand all Loading... | |
81 assertArrayEquals(["bar", "baz", "bif"], enumerable(object), "enum3"); | 82 assertArrayEquals(["bar", "baz", "bif"], enumerable(object), "enum3"); |
82 | 83 |
83 // Unshadowing a prototype property exposes its attributes. | 84 // Unshadowing a prototype property exposes its attributes. |
84 assertTrue(delete object.bif, "delete bif"); | 85 assertTrue(delete object.bif, "delete bif"); |
85 assertArrayEquals(["bar", "baz"], enumerable(object), "enum4"); | 86 assertArrayEquals(["bar", "baz"], enumerable(object), "enum4"); |
86 assertEquals(func1, object.bif, "read bif 2"); | 87 assertEquals(func1, object.bif, "read bif 2"); |
87 // Can't delete prototype property. | 88 // Can't delete prototype property. |
88 assertTrue(delete object.bif, "delete bif 2"); | 89 assertTrue(delete object.bif, "delete bif 2"); |
89 assertArrayEquals(["bar", "baz"], enumerable(object), "enum5"); | 90 assertArrayEquals(["bar", "baz"], enumerable(object), "enum5"); |
90 assertEquals(func1, object.bif, "read bif3"); | 91 assertEquals(func1, object.bif, "read bif3"); |
OLD | NEW |