2016-01-14 19:22:46 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// First test case
|
|
|
|
|
|
|
|
function FirstBuffer () {}
|
|
|
|
FirstBuffer.prototype.__proto__ = Uint8Array.prototype
|
|
|
|
FirstBuffer.__proto__ = Uint8Array
|
|
|
|
|
|
|
|
var buf = new Uint8Array(10)
|
|
|
|
buf.__proto__ = FirstBuffer.prototype
|
|
|
|
|
2017-04-26 06:10:17 +00:00
|
|
|
assertThrows(() => buf.subarray(2), TypeError);
|
2016-01-14 19:22:46 +00:00
|
|
|
|
|
|
|
// Second test case
|
|
|
|
|
2017-04-26 06:10:17 +00:00
|
|
|
let seen_args = [];
|
|
|
|
|
2016-01-14 19:22:46 +00:00
|
|
|
function SecondBuffer (arg) {
|
2017-04-26 06:10:17 +00:00
|
|
|
seen_args.push(arg);
|
2016-01-14 19:22:46 +00:00
|
|
|
var arr = new Uint8Array(arg)
|
|
|
|
arr.__proto__ = SecondBuffer.prototype
|
|
|
|
return arr
|
|
|
|
}
|
|
|
|
SecondBuffer.prototype.__proto__ = Uint8Array.prototype
|
|
|
|
SecondBuffer.__proto__ = Uint8Array
|
|
|
|
|
|
|
|
var buf3 = new SecondBuffer(10)
|
2017-04-26 06:10:17 +00:00
|
|
|
assertEquals([10], seen_args);
|
2016-01-14 19:22:46 +00:00
|
|
|
|
|
|
|
var buf4 = buf3.subarray(2)
|
|
|
|
|
2017-04-26 06:10:17 +00:00
|
|
|
assertEquals(10, buf4.length);
|
|
|
|
assertEquals([10, buf3.buffer], seen_args);
|