OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 // Flags: --allow-natives-syntax |
| 6 |
| 7 // Ensure that mutation of the Object.keys result doesn't affect the |
| 8 // enumeration cache for fast-mode objects. |
| 9 (function() { |
| 10 const a = {x:1, y:2}; |
| 11 let k = Object.keys(a); |
| 12 %HeapObjectVerify(k); |
| 13 assertEquals(2, k.length); |
| 14 assertEquals("x", k[0]); |
| 15 assertEquals("y", k[1]); |
| 16 k[0] = "y"; |
| 17 k[1] = "x"; |
| 18 k = Object.keys(a); |
| 19 assertEquals(2, k.length); |
| 20 assertEquals("x", k[0]); |
| 21 assertEquals("y", k[1]); |
| 22 })(); |
| 23 |
| 24 // Ensure that the copy-on-write keys are handled properly, even in |
| 25 // the presence of Symbols. |
| 26 (function() { |
| 27 const s = Symbol(); |
| 28 const a = {[s]: 1}; |
| 29 let k = Object.keys(a); |
| 30 %HeapObjectVerify(k); |
| 31 assertEquals(0, k.length); |
| 32 k.shift(); |
| 33 assertEquals(0, k.length); |
| 34 })(); |
OLD | NEW |