tor-browser

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

defined-byteoffset-sab.js (2200B)


      1 // |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
      2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      3 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
      4 // This code is governed by the BSD license found in the LICENSE file.
      5 
      6 /*---
      7 esid: sec-dataview-buffer-byteoffset-bytelength
      8 description: >
      9  Return new instance from defined offset
     10 info: |
     11  24.2.2.1 DataView (buffer, byteOffset, byteLength )
     12 
     13  ...
     14  17. Return O.
     15 features: [SharedArrayBuffer]
     16 ---*/
     17 
     18 var sample;
     19 var buffer = new SharedArrayBuffer(4);
     20 
     21 sample = new DataView(buffer, 0);
     22 assert.sameValue(sample.byteLength, 4, "sample.byteLength");
     23 assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
     24 assert.sameValue(sample.buffer, buffer);
     25 assert.sameValue(sample.constructor, DataView);
     26 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
     27 
     28 sample = new DataView(buffer, 1);
     29 assert.sameValue(sample.byteLength, 3, "sample.byteLength");
     30 assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
     31 assert.sameValue(sample.buffer, buffer);
     32 assert.sameValue(sample.constructor, DataView);
     33 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
     34 
     35 sample = new DataView(buffer, 2);
     36 assert.sameValue(sample.byteLength, 2, "sample.byteLength");
     37 assert.sameValue(sample.byteOffset, 2, "sample.byteOffset");
     38 assert.sameValue(sample.buffer, buffer);
     39 assert.sameValue(sample.constructor, DataView);
     40 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
     41 
     42 sample = new DataView(buffer, 3);
     43 assert.sameValue(sample.byteLength, 1, "sample.byteLength");
     44 assert.sameValue(sample.byteOffset, 3, "sample.byteOffset");
     45 assert.sameValue(sample.buffer, buffer);
     46 assert.sameValue(sample.constructor, DataView);
     47 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
     48 
     49 sample = new DataView(buffer, 4);
     50 assert.sameValue(sample.byteLength, 0, "sample.byteLength");
     51 assert.sameValue(sample.byteOffset, 4, "sample.byteOffset");
     52 assert.sameValue(sample.buffer, buffer);
     53 assert.sameValue(sample.constructor, DataView);
     54 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
     55 
     56 reportCompare(0, 0);