OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Create a prototype object which has a lot of fast properties. |
| 6 var body = ""; |
| 7 for (var i = 0; i < 100; i++) { |
| 8 body += `this.a${i} = 0;\n`; |
| 9 } |
| 10 var Proto = new Function(body); |
| 11 |
| 12 function A() {} |
| 13 A.prototype = new Proto(); |
| 14 |
| 15 // Create a object and add properties that already exist in the prototype. |
| 16 // At some point the object will turn into a dictionary mode and one of |
| 17 // the fast details from the prototype will be reinterpreted as a details |
| 18 // for a new property ... |
| 19 var o = new A(); |
| 20 for (var i = 0; i < 100; i++) { |
| 21 o["a" + i] = i; |
| 22 } |
| 23 |
| 24 // ... which will break the enumeration order of the slow properties. |
| 25 var names = Object.getOwnPropertyNames(o); |
| 26 for (var i = 0; i < 100; i++) { |
| 27 assertEquals("a" + i, names[i]); |
| 28 } |
OLD | NEW |