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

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

Issue 1198523002: [es6] throw TypeError when setting cyclic prototype value (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix webkit failure Created 5 years, 6 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
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/proto-accessor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 var object = objects[i]; 132 var object = objects[i];
133 Object.preventExtensions(object); 133 Object.preventExtensions(object);
134 assertThrows(function() { 134 assertThrows(function() {
135 Object.setPrototypeOf(object, proto); 135 Object.setPrototypeOf(object, proto);
136 }, TypeError); 136 }, TypeError);
137 } 137 }
138 } 138 }
139 TestSetPrototypeOfNonExtensibleObject(); 139 TestSetPrototypeOfNonExtensibleObject();
140 140
141 141
142 function TestSetPrototypeCyclic() {
143 var objects = [
144 Object.prototype, {},
145 Array.prototype, [],
146 Error.prototype, new TypeError,
147 // etc ...
148 ];
149 for (var i = 0; i < objects.length; i += 2) {
150 var object = objects[i];
151 var value = objects[i + 1];
152 assertThrows(function() {
153 Object.setPrototypeOf(object, value);
154 }, TypeError);
155 }
156 }
157 TestSetPrototypeCyclic();
158
159
142 function TestLookup() { 160 function TestLookup() {
143 var object = {}; 161 var object = {};
144 assertFalse('x' in object); 162 assertFalse('x' in object);
145 assertFalse('y' in object); 163 assertFalse('y' in object);
146 164
147 var oldProto = { 165 var oldProto = {
148 x: 'old x', 166 x: 'old x',
149 y: 'old y' 167 y: 'old y'
150 }; 168 };
151 Object.setPrototypeOf(object, oldProto); 169 Object.setPrototypeOf(object, oldProto);
152 assertEquals(object.x, 'old x'); 170 assertEquals(object.x, 'old x');
153 assertEquals(object.y, 'old y'); 171 assertEquals(object.y, 'old y');
154 172
155 var newProto = { 173 var newProto = {
156 x: 'new x' 174 x: 'new x'
157 }; 175 };
158 Object.setPrototypeOf(object, newProto); 176 Object.setPrototypeOf(object, newProto);
159 assertEquals(object.x, 'new x'); 177 assertEquals(object.x, 'new x');
160 assertFalse('y' in object); 178 assertFalse('y' in object);
161 } 179 }
162 TestLookup(); 180 TestLookup();
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/proto-accessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698