OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 assertEquals("foo", propertyNames[0]); | 70 assertEquals("foo", propertyNames[0]); |
71 | 71 |
72 // Check that getter properties are returned. | 72 // Check that getter properties are returned. |
73 var obj = {}; | 73 var obj = {}; |
74 obj.__defineGetter__("getter", function() {}); | 74 obj.__defineGetter__("getter", function() {}); |
75 propertyNames = Object.getOwnPropertyNames(obj); | 75 propertyNames = Object.getOwnPropertyNames(obj); |
76 propertyNames.sort(); | 76 propertyNames.sort(); |
77 assertEquals(1, propertyNames.length); | 77 assertEquals(1, propertyNames.length); |
78 assertEquals("getter", propertyNames[0]); | 78 assertEquals("getter", propertyNames[0]); |
79 | 79 |
| 80 // Check that implementation does not access Array.prototype. |
| 81 var savedConcat = Array.prototype.concat; |
| 82 Array.prototype.concat = function() { return ['foo', 'bar']; } |
| 83 propertyNames = Object.getOwnPropertyNames({}); |
| 84 assertEquals(0, propertyNames.length); |
| 85 Array.prototype.concat = savedConcat; |
| 86 |
80 try { | 87 try { |
81 Object.getOwnPropertyNames(4); | 88 Object.getOwnPropertyNames(4); |
82 assertTrue(false); | 89 assertTrue(false); |
83 } catch (e) { | 90 } catch (e) { |
84 assertTrue(/on non-object/.test(e)); | 91 assertTrue(/on non-object/.test(e)); |
85 } | 92 } |
86 | 93 |
87 try { | 94 try { |
88 Object.getOwnPropertyNames("foo"); | 95 Object.getOwnPropertyNames("foo"); |
89 assertTrue(false); | 96 assertTrue(false); |
90 } catch (e) { | 97 } catch (e) { |
91 assertTrue(/on non-object/.test(e)); | 98 assertTrue(/on non-object/.test(e)); |
92 } | 99 } |
93 | 100 |
94 try { | 101 try { |
95 Object.getOwnPropertyNames(undefined); | 102 Object.getOwnPropertyNames(undefined); |
96 assertTrue(false); | 103 assertTrue(false); |
97 } catch (e) { | 104 } catch (e) { |
98 assertTrue(/on non-object/.test(e)); | 105 assertTrue(/on non-object/.test(e)); |
99 } | 106 } |
100 | 107 |
101 try { | 108 try { |
102 Object.getOwnPropertyNames(null); | 109 Object.getOwnPropertyNames(null); |
103 assertTrue(false); | 110 assertTrue(false); |
104 } catch (e) { | 111 } catch (e) { |
105 assertTrue(/on non-object/.test(e)); | 112 assertTrue(/on non-object/.test(e)); |
106 } | 113 } |
OLD | NEW |