tor-browser

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

Memory-allocationsLogOverflowed-01.js (839B)


      1 // Test basic usage of `Debugger.Memory.prototype.allocationsLogOverflowed`.
      2 
      3 const root = newGlobal({newCompartment: true});
      4 const dbg = new Debugger(root);
      5 dbg.memory.trackingAllocationSites = true;
      6 dbg.memory.maxAllocationsLogLength = 1;
      7 
      8 root.eval("(" + function immediate() {
      9  // Allocate more than the max log length.
     10  this.objs = [{}, {}, {}, {}];
     11 } + "());");
     12 
     13 // The log should have overflowed.
     14 assertEq(dbg.memory.allocationsLogOverflowed, true);
     15 
     16 // Once drained, the flag should be reset.
     17 const allocs = dbg.memory.drainAllocationsLog();
     18 assertEq(dbg.memory.allocationsLogOverflowed, false);
     19 
     20 // If we keep allocations under the max log length, then we shouldn't have
     21 // overflowed.
     22 dbg.memory.maxAllocationsLogLength = 10000;
     23 root.eval("this.objs = [{}, {}, {}, {}];");
     24 assertEq(dbg.memory.allocationsLogOverflowed, false);