tor-browser

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

getPropertyCacheOverflow.js (943B)


      1 // This test was made to be effective with --no-jm.
      2 
      3 var list = [
      4  { entry00: 0, length: 1 },
      5  { entry01: 0, length: 1 },
      6  { entry02: 0, length: 1 },
      7  { entry03: 0, length: 1 },
      8  { entry04: 0, length: 1 },
      9  { entry05: 0, length: 1 },
     10  { entry06: 0, length: 1 },
     11  { entry07: 0, length: 1 },
     12  { entry08: 0, length: 1 },
     13  { entry09: 0, length: 1 },
     14  { entry10: 0, length: 1 },
     15  { entry11: 0, length: 1 },
     16  { entry12: 0, length: 1 },
     17  { entry13: 0, length: 1 },
     18  { entry14: 0, length: 1 },
     19  { entry15: 0, length: 1 },
     20  { entry16: 0, length: 1 }, // cause an overflow.
     21  { entry17: 0, length: 1 },
     22  [0],
     23  (new Uint8Array(new ArrayBuffer(1)))
     24 ];
     25 
     26 function f(obj) {
     27    return obj.length;
     28 }
     29 
     30 // Cook the f function on the top of the list to make sure we do not register
     31 // our test cases.
     32 for (var i = 0; i < 100; i++)
     33    f(list[i % 10]);
     34 
     35 // Register & check stubs.
     36 for (var i = 0; i < 40; i++)
     37    assertEq(f(list[i % 20]), 1);