js/src/tests/js1_5/extensions/regress-327608.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/extensions/regress-327608.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +//-----------------------------------------------------------------------------
    1.10 +var BUGNUMBER = 327608;
    1.11 +var summary = 'Do not assume we will find the prototype property';
    1.12 +var actual = 'No Crash';
    1.13 +var expect = 'No Crash';
    1.14 +
    1.15 +printBugNumber(BUGNUMBER);
    1.16 +printStatus (summary);
    1.17 +print('This test runs only in the browser');
    1.18 + 
    1.19 +function countProps(obj)
    1.20 +{
    1.21 +  var c;
    1.22 +  for (var prop in obj)
    1.23 +    ++c;
    1.24 +  return c;
    1.25 +}
    1.26 +
    1.27 +function init()
    1.28 +{
    1.29 +  var inp = document.getElementsByTagName("input")[0];
    1.30 +  countProps(inp);
    1.31 +  gc();
    1.32 +  var blurfun = inp.blur;
    1.33 +  blurfun.__proto__ = null;
    1.34 +  countProps(blurfun);
    1.35 +  reportCompare(expect, actual, summary);
    1.36 +  gDelayTestDriverEnd = false;
    1.37 +  jsTestDriverEnd();
    1.38 +}
    1.39 +
    1.40 +if (typeof window != 'undefined')
    1.41 +{
    1.42 +  // delay test driver end
    1.43 +  gDelayTestDriverEnd = true;
    1.44 +
    1.45 +  document.write('<input>');
    1.46 +  window.addEventListener("load", init, false);
    1.47 +}
    1.48 +else
    1.49 +{
    1.50 +  reportCompare(expect, actual, summary);
    1.51 +}

mercurial