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