tor-browser

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

clone-object-deep.js (773B)


      1 // |reftest| skip-if(!xulRuntime.shell)
      2 // -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
      3 // Any copyright is dedicated to the Public Domain.
      4 // http://creativecommons.org/licenses/publicdomain/
      5 
      6 function test() {
      7    var check = clone_object_check;
      8 
      9    // Invoke with the simple parameter to compile the function before doing
     10    // deep clone, on --ion-eager case, to avoid timeout.
     11    check({x: null, y: undefined});
     12 
     13    // Try cloning a deep object. Don't fail with "too much recursion".
     14    var b = {};
     15    var current = b;
     16    for (var i = 0; i < 10000; i++) {
     17        var next = {};
     18        current['x' + i] = next;
     19        current = next;
     20    }
     21    check(b, "deepObject");  // takes 2 seconds :-\
     22 }
     23 
     24 test();
     25 reportCompare(0, 0, 'ok');