OLD | NEW |
1 // Copyright 2014-2015 the V8 project authors. All rights reserved. | 1 // Copyright 2014-2015 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 TestSetPrototypeToNull(); | 130 TestSetPrototypeToNull(); |
131 | 131 |
132 | 132 |
133 function TestSetPrototypeOfNonExtensibleObject() { | 133 function TestSetPrototypeOfNonExtensibleObject() { |
134 var objects = getObjects(); | 134 var objects = getObjects(); |
135 var proto = {}; | 135 var proto = {}; |
136 for (var i = 0; i < objects.length; i++) { | 136 for (var i = 0; i < objects.length; i++) { |
137 var object = objects[i]; | 137 var object = objects[i]; |
138 Object.preventExtensions(object); | 138 Object.preventExtensions(object); |
| 139 // Setting the current prototype must succeed. |
| 140 assertTrue(Reflect.setPrototypeOf(object, Object.getPrototypeOf(object))); |
| 141 // Setting any other must fail. |
139 assertFalse(Reflect.setPrototypeOf(object, proto)); | 142 assertFalse(Reflect.setPrototypeOf(object, proto)); |
140 } | 143 } |
141 } | 144 } |
142 TestSetPrototypeOfNonExtensibleObject(); | 145 TestSetPrototypeOfNonExtensibleObject(); |
143 | 146 |
144 | 147 |
145 function TestSetPrototypeCyclic() { | 148 function TestSetPrototypeCyclic() { |
146 var objects = [ | 149 var objects = [ |
147 Object.prototype, {}, | 150 Object.prototype, {}, |
148 Array.prototype, [], | 151 Array.prototype, [], |
(...skipping 23 matching lines...) Expand all Loading... |
172 assertEquals(object.y, 'old y'); | 175 assertEquals(object.y, 'old y'); |
173 | 176 |
174 var newProto = { | 177 var newProto = { |
175 x: 'new x' | 178 x: 'new x' |
176 }; | 179 }; |
177 assertTrue(Reflect.setPrototypeOf(object, newProto)); | 180 assertTrue(Reflect.setPrototypeOf(object, newProto)); |
178 assertEquals(object.x, 'new x'); | 181 assertEquals(object.x, 'new x'); |
179 assertFalse('y' in object); | 182 assertFalse('y' in object); |
180 } | 183 } |
181 TestLookup(); | 184 TestLookup(); |
OLD | NEW |