Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // First test case | 5 // First test case |
| 6 | 6 |
| 7 function FirstBuffer () {} | 7 function FirstBuffer () {} |
| 8 FirstBuffer.prototype.__proto__ = Uint8Array.prototype | 8 FirstBuffer.prototype.__proto__ = Uint8Array.prototype |
| 9 FirstBuffer.__proto__ = Uint8Array | 9 FirstBuffer.__proto__ = Uint8Array |
| 10 | 10 |
| 11 var buf = new Uint8Array(10) | 11 var buf = new Uint8Array(10) |
| 12 buf.__proto__ = FirstBuffer.prototype | 12 buf.__proto__ = FirstBuffer.prototype |
| 13 | 13 |
| 14 var buf2 = buf.subarray(2) | 14 assertThrows(() => buf.subarray(2), TypeError); |
| 15 assertEquals(8, buf2.length); | |
| 16 | 15 |
| 17 // Second test case | 16 // Second test case |
| 18 | 17 |
|
Camillo Bruni
2017/04/03 08:18:14
Would you mind extending this test a bit to make i
Choongwoo Han
2017/04/03 08:42:29
Done.
| |
| 19 function SecondBuffer (arg) { | 18 function SecondBuffer (arg) { |
|
Camillo Bruni
2017/04/03 08:18:14
seen_args.push(arg);
Choongwoo Han
2017/04/03 08:42:29
Done.
| |
| 20 var arr = new Uint8Array(arg) | 19 var arr = new Uint8Array(arg) |
| 21 arr.__proto__ = SecondBuffer.prototype | 20 arr.__proto__ = SecondBuffer.prototype |
| 22 return arr | 21 return arr |
| 23 } | 22 } |
| 24 SecondBuffer.prototype.__proto__ = Uint8Array.prototype | 23 SecondBuffer.prototype.__proto__ = Uint8Array.prototype |
| 25 SecondBuffer.__proto__ = Uint8Array | 24 SecondBuffer.__proto__ = Uint8Array |
| 26 | 25 |
| 27 var buf3 = new SecondBuffer(10) | 26 var buf3 = new SecondBuffer(10) |
|
Camillo Bruni
2017/04/03 08:18:14
assertEquals([10], seen_args);
Choongwoo Han
2017/04/03 08:42:29
Done.
| |
| 28 | 27 |
| 29 var buf4 = buf3.subarray(2) | 28 var buf4 = buf3.subarray(2) |
| 30 | 29 |
| 31 assertEquals(8, buf4.length); | 30 assertEquals(10, buf4.length); |
|
Camillo Bruni
2017/04/03 08:18:14
assertEquals([10, buf3.buffer], seen_args);
Choongwoo Han
2017/04/03 08:42:29
Done.
| |
| OLD | NEW |