Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 es6id: 24.2.2.1
7 esid: sec-dataview-buffer-byteoffset-bytelength
8 description: >
9 Throws a TypeError if buffer does not have [[ArrayBufferData]]
10 info: |
11 24.2.2.1 DataView (buffer, byteOffset, byteLength )
12
13 ...
14 2. If Type(buffer) is not Object, throw a TypeError exception.
15 3. If buffer does not have an [[ArrayBufferData]] internal slot, throw a
16 TypeError exception.
17 ...
18 features: [SharedArrayBuffer]
19 ---*/
20
21 var obj = {
22 valueOf: function() {
23 throw new Test262Error("buffer should be verified before byteOffset");
24 }
25 };
26
27 assert.throws(TypeError, function() {
28 new DataView({}, obj);
29 }, "{}");
30
31 assert.throws(TypeError, function() {
32 new DataView([], obj);
33 }, "[]");
34
35 var ta = new Int8Array();
36 assert.throws(TypeError, function() {
37 new DataView(ta, obj);
38 }, "typedArray instance");
39
40 var other = new DataView(new SharedArrayBuffer(1), 0);
41 assert.throws(TypeError, function() {
42 new DataView(other, obj);
43 }, "dataView instance");