~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/e4x/extensions/regress-352846-03.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// |reftest| pref(javascript.options.xml.content,true)
 
2
/* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
3
 
 
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 = 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
var counter = 0;
 
18
 
 
19
function prepare_xml()
 
20
{
 
21
  delete XML.prototype.function::toString;
 
22
  Object.defineProperty(Object.prototype, "toString",
 
23
                        { get: toSource_getter, enumerable: true,
 
24
                          configurable: true });
 
25
  return new XML("<a>xml_text</a>");
 
26
}
 
27
 
 
28
function toSource_getter()
 
29
{
 
30
  // Make sure that lastInternalResult does not contain prepare_xml
 
31
  var tmp = { toSource: function() { return [1,2,3]; } };
 
32
  uneval(tmp);
 
33
 
 
34
  if (counter++ < 2) return undefined;
 
35
 
 
36
  // run GC onr overwrite the heap
 
37
  if (typeof gc == "function") gc();
 
38
  var x = 1e-100;
 
39
  for (var i = 0; i != 50000; ++i)
 
40
    var x2 = x / 4;
 
41
 
 
42
  // Return a function that would access this in non-trivial way to
 
43
  // check if prepare_xml() was rooted.
 
44
  return function() {
 
45
    print("xxx");
 
46
    return this.toXMLString();
 
47
  };
 
48
}
 
49
 
 
50
var obj = { };
 
51
Object.defineProperty(obj, "length",
 
52
{
 
53
  get: prepare_xml,
 
54
  enumerable: true,
 
55
  configurable: true
 
56
});
 
57
Array.reverse(obj);
 
58
 
 
59
TEST(1, expect, actual);
 
60
 
 
61
END();