tor-browser

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

globalArrayBuffer.js (894B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 tests.set(
      6  "globalArrayBuffer",
      7  (function() {
      8    var garbage = [];
      9    var garbageIndex = 0;
     10    return {
     11      description: "var foo = ArrayBuffer(N); # (large malloc data)",
     12 
     13      load: N => {
     14        garbage = new Array(N);
     15      },
     16      unload: () => {
     17        garbage = [];
     18        garbageIndex = 0;
     19      },
     20 
     21      defaultGarbagePerFrame: "4M",
     22      defaultGarbagePiles: "8K",
     23 
     24      makeGarbage: N => {
     25        var ab = new ArrayBuffer(N);
     26        var view = new Uint8Array(ab);
     27        view[0] = 1;
     28        view[N - 1] = 2;
     29        garbage[garbageIndex++] = ab;
     30        if (garbageIndex == garbage.length) {
     31          garbageIndex = 0;
     32        }
     33      },
     34    };
     35  })()
     36 );