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 // https://bugs.chromium.org/p/chromium/issues/detail?id=595319 | |
6 // Ensure exceptions are checked for by Array.prototype.concat from adding | |
7 // an element, and that elements are added to array subclasses appropraitely | |
adamk
2016/03/17 19:22:21
Typo: s/appropraitely/appropriately/
Dan Ehrenberg
2016/03/17 20:26:33
Done
| |
8 | |
9 // If adding a property does throw, the exception is propagated | |
10 class MyException extends Error { } | |
11 class MyArray extends Array { | |
12 constructor(...args) { | |
13 super(...args); | |
14 return new Proxy(this, { | |
15 defineProperty() { throw new MyException(); } | |
16 }); | |
17 } | |
18 } | |
19 assertThrows(() => new MyArray().concat([1]), MyException); | |
20 | |
21 // Ensure elements are added to the instance, rather than calling [[Set]]. | |
22 Object.prototype.__defineGetter__(0, function(){}); | |
23 class MyArray2 extends Array { }; | |
24 Array.prototype.constructor = MyArray2; | |
25 assertArrayEquals([0.5], [].concat(0.5)); | |
OLD | NEW |