tor-browser

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

Memory-drainAllocationsLog-03.js (725B)


      1 // Test when there are more allocations than the maximum log length.
      2 
      3 const root = newGlobal({newCompartment: true});
      4 const dbg = new Debugger();
      5 dbg.addDebuggee(root)
      6 
      7 dbg.memory.maxAllocationsLogLength = 3;
      8 dbg.memory.trackingAllocationSites = true;
      9 
     10 root.eval([
     11  "this.alloc1 = {};", // line 1
     12  "this.alloc2 = {};", // line 2
     13  "this.alloc3 = {};", // line 3
     14  "this.alloc4 = {};", // line 4
     15 ].join("\n"));
     16 
     17 const allocs = dbg.memory.drainAllocationsLog();
     18 
     19 // Should have stayed at the maximum length.
     20 assertEq(allocs.length, 3);
     21 // Should have kept the most recent allocation.
     22 assertEq(allocs[2].frame.line, 4);
     23 // Should have thrown away the oldest allocation.
     24 assertEq(allocs.map(x => x.frame.line).indexOf(1), -1);