tor-browser

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

stringbuffer-3.js (698B)


      1 // |jit-test| skip-if: !getBuildConfiguration("debug")
      2 // stringRepresentation and the bufferRefCount field aren't available in
      3 // all builds.
      4 
      5 // When a JS string with a StringBuffer is passed to a different zone, the buffer
      6 // should be shared instead of copied.
      7 
      8 gczeal(0);
      9 
     10 function test() {
     11  let g = newGlobal({newCompartment: true}); // Implies new-zone.
     12  let s1 = newString("abcdefghijklmnopqrstuvwxyz", {newStringBuffer: true, tenured: true});
     13  assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 1);
     14  g.s2 = s1;
     15  assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 2);
     16  let s3 = g.s2;
     17  assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 3);
     18 }
     19 test();