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: --expose-gc |
| 6 |
| 7 var proxy = new Proxy([], { |
| 8 defineProperty() { |
| 9 w.length = 1; // shorten the array so the backstore pointer is relocated |
| 10 gc(); // force gc to move the array's elements backstore |
| 11 return Object.defineProperty.apply(this, arguments); |
| 12 } |
| 13 }); |
| 14 |
| 15 class MyArray extends Array { |
| 16 // custom constructor which returns a proxy object |
| 17 static get[Symbol.species](){ |
| 18 return function() { |
| 19 return proxy; |
| 20 } |
| 21 }; |
| 22 } |
| 23 |
| 24 var w = new MyArray(100); |
| 25 w[1] = 0.1; |
| 26 w[2] = 0.1; |
| 27 |
| 28 var result = Array.prototype.concat.call(w); |
| 29 |
| 30 assertEquals(undefined, result[0]); |
| 31 assertEquals(0.1, result[1]); |
| 32 |
| 33 for (var i = 2; i < 200; i++) { |
| 34 assertEquals(undefined, result[i]); |
| 35 } |
OLD | NEW |