tor-browser

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

resizable-dataview-bytelength-with-sab.js (775B)


      1 function testResizableArrayBuffer() {
      2  for (let i = 0; i < 4; ++i) {
      3    let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
      4    let ta = new DataView(sab, 0, i);
      5    for (let j = 0; j < 100; ++j) {
      6      assertEq(ta.byteLength, i);
      7 
      8      sab.grow(i + j + 1);
      9      assertEq(ta.byteLength, i);
     10    }
     11  }
     12 }
     13 for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
     14 
     15 function testResizableArrayBufferAutoLength() {
     16  for (let i = 0; i < 4; ++i) {
     17    let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
     18    let ta = new DataView(sab);
     19    for (let j = 0; j < 100; ++j) {
     20      assertEq(ta.byteLength, i + j);
     21 
     22      sab.grow(i + j + 1);
     23      assertEq(ta.byteLength, i + j + 1);
     24    }
     25  }
     26 }
     27 for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();