tor-browser

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

regress-617935.js (974B)


      1 // |reftest| skip-if(!xulRuntime.shell&&(Android||winWidget)) silentfail
      2 /*
      3 * Any copyright is dedicated to the Public Domain.
      4 * http://creativecommons.org/licenses/publicdomain/
      5 *
      6 * Author: Christian Holler <decoder@own-hero.net>
      7 */
      8 
      9 expectExitCode(0);
     10 expectExitCode(5);
     11 
     12 /* Length of 32 */
     13 var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
     14 
     15 /* Make len(foo) 32768 */
     16 for (i = 0; i < 10; ++i) {
     17    foo += foo;
     18 }
     19 
     20 /* Add one "a" to cause overflow later */
     21 foo += "a";
     22 
     23 var bar = "bbbbbbbbbbbbbbbb";
     24 
     25 /* Make len(bar) 8192 */
     26 for (i = 0; i < 9; ++i) {
     27    bar += bar;
     28 }
     29 
     30 /* 
     31 * Resulting string should be 
     32 * len(foo) * len(bar) = (2**10 * 32 + 1) * 8192 = 268443648
     33 * which will be larger than the max string length (2**28, or 268435456).
     34 */
     35 try {
     36    foo.replace(/[a]/g, bar);
     37 } catch (e) {
     38    reportCompare(e instanceof InternalError, true, "Internal error due to overallocation is ok.");
     39 }
     40 reportCompare(true, true, "No crash occurred.");
     41 
     42 print("Tests complete");