Debian Codegraph @

js/src/tests/non262/extensions/regress-351973.js

raw
1 // |reftest| skip-if(!Object.prototype.toSource)
2
3 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 351973;
10 var summary = 'GC hazard with unrooted ids in Object.toSource';
11 var actual = 'No Crash';
12 var expect = 'No Crash';
13
14
15 //-----------------------------------------------------------------------------
16 test();
17 //-----------------------------------------------------------------------------
18
19 function test()
20 {
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 function removeAllProperties(o)
25 {
26 for (var prop in o)
27 delete o[prop];
28 for (var i = 0; i != 50*1000; ++i) {
29 var tmp = Math.sqrt(i+0.2);
30 tmp = 0;
31 }
32 if (typeof gc == "function")
33 gc();
34 }
35
36 function run_test()
37 {
38
39 var o = {};
40 o.first = { toSource: function() { removeAllProperties(o); } };
41 for (var i = 0; i != 10; ++i) {
42 o[Math.sqrt(i + 0.1)] = 1;
43 }
44 return o.toSource();
45 }
46
47 print(run_test());
48
49 reportCompare(expect, actual, summary);
50 }