tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

buffer-does-not-have-arraybuffer-data-throws.js (1086B)


      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-dataview-buffer-byteoffset-bytelength
      6 description: >
      7  Throws a TypeError if buffer does not have [[ArrayBufferData]]
      8 info: |
      9  24.2.2.1 DataView (buffer, byteOffset, byteLength )
     10 
     11  ...
     12  2. If Type(buffer) is not Object, throw a TypeError exception.
     13  3. If buffer does not have an [[ArrayBufferData]] internal slot, throw a
     14  TypeError exception.
     15  ...
     16 features: [Int8Array]
     17 ---*/
     18 
     19 var obj = {
     20  valueOf: function() {
     21    throw new Test262Error("buffer should be verified before byteOffset");
     22  }
     23 };
     24 
     25 assert.throws(TypeError, function() {
     26  new DataView({}, obj);
     27 }, "{}");
     28 
     29 assert.throws(TypeError, function() {
     30  new DataView([], obj);
     31 }, "[]");
     32 
     33 var ta = new Int8Array();
     34 assert.throws(TypeError, function() {
     35  new DataView(ta, obj);
     36 }, "typedArray instance");
     37 
     38 var other = new DataView(new ArrayBuffer(1), 0);
     39 assert.throws(TypeError, function() {
     40  new DataView(other, obj);
     41 }, "dataView instance");
     42 
     43 reportCompare(0, 0);