| 1 |
// Copyright (C) 2016 The V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
esid: sec-arraybuffer.isview |
| 6 |
description: > |
| 7 |
`isView` can be invoked as a function |
| 8 |
info: | |
| 9 |
24.1.3.1 ArrayBuffer.isView ( arg ) |
| 10 |
|
| 11 |
1. If Type(arg) is not Object, return false. |
| 12 |
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true. |
| 13 |
3. Return false. |
| 14 |
features: [TypedArray, DataView] |
| 15 |
includes: [testTypedArray.js] |
| 16 |
---*/ |
| 17 |
|
| 18 |
var isView = ArrayBuffer.isView; |
| 19 |
|
| 20 |
testWithTypedArrayConstructors(function(ctor) { |
| 21 |
var sample = new ctor(); |
| 22 |
assert.sameValue(isView(sample), true, "instance of TypedArray"); |
| 23 |
}); |
| 24 |
|
| 25 |
var dv = new DataView(new ArrayBuffer(1), 0, 0); |
| 26 |
assert.sameValue(isView(dv), true, "instance of DataView"); |
| 27 |
|
| 28 |
assert.sameValue(isView(), false, "undefined arg"); |
| 29 |
assert.sameValue(isView({}), false, "ordinary object"); |