tor-browser

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

set-length-sparse-1.js (891B)


      1 function testSuppressIteration1() {
      2  var arr = [];
      3  arr[10000000] = 1;
      4  arr[20000000] = 2;
      5  arr[90000000] = 9;
      6  var seen = [];
      7  for (var prop in arr) {
      8    seen.push(prop);
      9    arr.length = 0;
     10  }
     11  assertEq(JSON.stringify(seen), '["10000000"]');
     12 }
     13 testSuppressIteration1();
     14 
     15 function testSuppressIteration2() {
     16  var arr = [];
     17  arr[10000000] = 1;
     18  arr[20000000] = 2;
     19  arr[90000000] = 9;
     20  var seen = [];
     21  for (var prop in arr) {
     22    seen.push(prop);
     23    arr.length = 20000001;
     24  }
     25  assertEq(JSON.stringify(seen), '["10000000","20000000"]');
     26 }
     27 testSuppressIteration2();
     28 
     29 function testNonConfigurable() {
     30  var arr = [];
     31  arr[100000] = 1;
     32  Object.defineProperty(arr, 200000, {configurable: false, writable: true, value: 2});
     33  arr[200005] = 3;
     34  arr.length = 0;
     35  assertEq(arr.length, 200001);
     36  assertEq(JSON.stringify(Object.keys(arr)), '["100000"]');
     37 }
     38 testNonConfigurable();