tor-browser

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

array-isArray-proxy-recursion.js (1121B)


      1 /*
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/licenses/publicdomain/
      4 */
      5 
      6 //-----------------------------------------------------------------------------
      7 var BUGNUMBER = 1282047;
      8 var summary = 'Infinite recursion via Array.isArray on a proxy';
      9 
     10 print(BUGNUMBER + ": " + summary);
     11 
     12 /**************
     13 * BEGIN TEST *
     14 **************/
     15 
     16 var proxy = Proxy.revocable([], {}).proxy;
     17 
     18 // A depth of 100000 ought to be enough for any platform to consume its entire
     19 // stack, hopefully without making any recalcitrant platforms time out.  If no
     20 // timeout happens, the assertEq checks for the proper expected value.
     21 for (var i = 0; i < 1e5; i++)
     22  proxy = new Proxy(proxy, {});
     23 
     24 try
     25 {
     26  assertEq(Array.isArray(proxy), true);
     27 
     28  // If we reach here, it's cool, we just didn't consume the entire stack.
     29 }
     30 catch (e)
     31 {
     32  assertEq(e instanceof InternalError, true,
     33           "should have thrown for over-recursion");
     34 }
     35 
     36 /******************************************************************************/
     37 
     38 if (typeof reportCompare === "function")
     39  reportCompare(true, true);
     40 
     41 print("Tests complete");