js/src/tests/js1_5/GC/regress-319980-01.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:155dbf6f551a
1 // |reftest| skip-if(!xulRuntime.shell) 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 if (typeof setTimeout == 'undefined')
27 {
28 setTimeout = function() {};
29 clearTimeout = function() {};
30 actual = 'Normal Exit';
31 reportCompare(expect, actual, summary);
32 }
33 else
34 {
35 // delay start until after js-test-driver-end runs.
36 // delay test driver end
37 gDelayTestDriverEnd = true;
38
39 setTimeout(testFuncWatcher, 1000);
40 }
41
42 function testFuncWatcher()
43 {
44 a = null;
45
46 gc();
47
48 clearTimeout(testFuncTimerId);
49 testFuncWatcherId = testFuncTimerId = null;
50 if (currTest >= maxTests)
51 {
52 actual = 'Normal Exit';
53 reportCompare(expect, actual, summary);
54 printStatus('Test Completed');
55 gDelayTestDriverEnd = false;
56 jsTestDriverEnd();
57 return;
58 }
59 ++currTest;
60
61 print('Executing test ' + currTest + '\n');
62
63 testFuncWatcherId = setTimeout("testFuncWatcher()", timeOut);
64 testFuncTimerId = setTimeout(testFunc, interval);
65 }
66
67
68 var a;
69 function testFunc()
70 {
71
72 var i;
73
74 switch(currTest)
75 {
76 case 1:
77 a = new Array(100000);
78 for (i = 0; i < 100000; i++ )
79 {
80 a[i] = i;
81 }
82 break;
83
84 case 2:
85 a = new Array(100000);
86 for (i = 0; i < 100000; i++)
87 {
88 a[i] = new Number();
89 a[i] = i;
90 }
91 break;
92
93 case 3:
94 a = new String() ;
95 a = new Array(100000);
96 for ( i = 0; i < 100000; i++ )
97 {
98 a[i] = i;
99 }
100
101 break;
102
103 case 4:
104 a = new Array();
105 a[0] = new Array(100000);
106 for (i = 0; i < 100000; i++ )
107 {
108 a[0][i] = i;
109 }
110 break;
111
112 case 5:
113 a = new Array();
114 for (i = 0; i < 100000; i++ )
115 {
116 a[i] = i;
117 }
118 break;
119 }
120
121 if (testFuncTimerId)
122 {
123 testFuncTimerId = setTimeout(testFunc, interval);
124 }
125 }
126
127

mercurial