Debian Codegraph @

rhino/testsrc/tests/e4x/extensions/regress-352846-01.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 gTestfile = 'regress-352846-01.js';
8
9 var BUGNUMBER = 352846;
10 var summary = 'Passing unrooted value to OBJ_DEFAULT_VALUE is GC hazard';
11 var actual = 'No Crash';
12 var expect = 'No Crash';
13
14 printBugNumber(BUGNUMBER);
15 START(summary);
16
17 function prepare_xml()
18 {
19 delete XML.prototype.function::toString;
20 Object.prototype.toString getter = toSource_getter;
21 return new XML("<a>xml_text</a>");
22 }
23
24 var counter = 0;
25
26 function toSource_getter()
27 {
28 // Make sure that lastInternalResult does not contain prepare_xml
29 var tmp = { toSource: function() { return [1,2,3]; } };
30 uneval(tmp);
31
32 if (counter++ < 2) return undefined;
33
34 // run GC onr overwrite the heap
35 if (typeof gc == "function") gc();
36 var x = 1e-100;
37 for (var i = 0; i != 50000; ++i)
38 var x2 = x / 4;
39
40 // Return a function that would access this in non-trivial way to
41 // check if prepare_xml() was rooted.
42 return function() { return this.toXMLString(); };
43 }
44
45 uneval({ toSource: prepare_xml });
46
47 TEST(1, expect, actual);
48
49 END();