tor-browser

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

deepWeakMap.js (986B)


      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  "deepWeakMap",
      7  (function() {
      8    var garbage = [];
      9    var garbageIndex = 0;
     10    return {
     11      description: "o={wm,k}; w.mk[k]=o2={wm2,k2}; wm2[k2]=....",
     12 
     13      defaultGarbagePerFrame: "1K",
     14      defaultGarbagePiles: "1K",
     15 
     16      load: N => {
     17        garbage = new Array(N);
     18      },
     19 
     20      unload: () => {
     21        garbage = [];
     22        garbageIndex = 0;
     23      },
     24 
     25      makeGarbage: M => {
     26        var initial = {};
     27        var prev = initial;
     28        for (var i = 0; i < M; i++) {
     29          var obj = [new WeakMap(), Object.create(null)];
     30          obj[0].set(obj[1], prev);
     31          prev = obj;
     32        }
     33        garbage[garbageIndex++] = initial;
     34        if (garbageIndex == garbage.length) {
     35          garbageIndex = 0;
     36        }
     37      },
     38    };
     39  })()
     40 );