regress-319980-01.js (2335B)
1 // |reftest| skip slow 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 //----------------------------------------------------------------------------- 8 var BUGNUMBER = 319980; 9 var summary = 'GC not called during non-fatal out of memory'; 10 var actual = ''; 11 var expect = 'Normal Exit'; 12 13 printBugNumber(BUGNUMBER); 14 printStatus (summary); 15 print ('This test should never fail explicitly. ' + 16 'You must view the memory usage during the test. ' + 17 'This test fails if memory usage for each subtest grows'); 18 19 var timeOut = 45 * 1000; 20 var interval = 0.01 * 1000; 21 var testFuncWatcherId; 22 var testFuncTimerId; 23 var maxTests = 5; 24 var currTest = 0; 25 26 // delay start until after js-test-driver-end runs. 27 // delay test driver end 28 gDelayTestDriverEnd = true; 29 30 setTimeout(testFuncWatcher, 1000); 31 32 function testFuncWatcher() 33 { 34 a = null; 35 36 gc(); 37 38 clearTimeout(testFuncTimerId); 39 testFuncWatcherId = testFuncTimerId = null; 40 if (currTest >= maxTests) 41 { 42 actual = 'Normal Exit'; 43 reportCompare(expect, actual, summary); 44 printStatus('Test Completed'); 45 gDelayTestDriverEnd = false; 46 jsTestDriverEnd(); 47 return; 48 } 49 ++currTest; 50 51 print('Executing test ' + currTest + '\n'); 52 53 testFuncWatcherId = setTimeout("testFuncWatcher()", timeOut); 54 testFuncTimerId = setTimeout(testFunc, interval); 55 } 56 57 58 var a; 59 function testFunc() 60 { 61 62 var i; 63 64 switch(currTest) 65 { 66 case 1: 67 a = new Array(100000); 68 for (i = 0; i < 100000; i++ ) 69 { 70 a[i] = i; 71 } 72 break; 73 74 case 2: 75 a = new Array(100000); 76 for (i = 0; i < 100000; i++) 77 { 78 a[i] = new Number(); 79 a[i] = i; 80 } 81 break; 82 83 case 3: 84 a = new String() ; 85 a = new Array(100000); 86 for ( i = 0; i < 100000; i++ ) 87 { 88 a[i] = i; 89 } 90 91 break; 92 93 case 4: 94 a = new Array(); 95 a[0] = new Array(100000); 96 for (i = 0; i < 100000; i++ ) 97 { 98 a[0][i] = i; 99 } 100 break; 101 102 case 5: 103 a = new Array(); 104 for (i = 0; i < 100000; i++ ) 105 { 106 a[i] = i; 107 } 108 break; 109 } 110 111 if (testFuncTimerId) 112 { 113 testFuncTimerId = setTimeout(testFunc, interval); 114 } 115 }