Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: test/mjsunit/harmony/reflect-set-prototype-of.js

Issue 1423603002: Fix corner-case behavior of JSObject::SetPrototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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();
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | test/mjsunit/harmony/set-prototype-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698