js/src/tests/js1_5/Regress/regress-204210.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Regress/regress-204210.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     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 + *
    1.11 + * Date:    29 April 2003
    1.12 + * SUMMARY: eval() is not a constructor, but don't crash on |new eval();|
    1.13 + *
    1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=204210
    1.15 + *
    1.16 + */
    1.17 +//-----------------------------------------------------------------------------
    1.18 +var UBound = 0;
    1.19 +var BUGNUMBER = 204210;
    1.20 +var summary = "eval() is not a constructor, but don't crash on |new eval();|";
    1.21 +var status = '';
    1.22 +var statusitems = [];
    1.23 +var actual = '';
    1.24 +var actualvalues = [];
    1.25 +var expect= '';
    1.26 +var expectedvalues = [];
    1.27 +
    1.28 +printBugNumber(BUGNUMBER);
    1.29 +printStatus(summary);
    1.30 +
    1.31 +/*
    1.32 + * Just testing that we don't crash on any of these constructs -
    1.33 + */
    1.34 +
    1.35 +
    1.36 +/*
    1.37 + * global scope -
    1.38 + */
    1.39 +try
    1.40 +{
    1.41 +  var x = new eval();
    1.42 +  new eval();
    1.43 +}
    1.44 +catch(e)
    1.45 +{
    1.46 +}
    1.47 +
    1.48 +
    1.49 +/*
    1.50 + * function scope -
    1.51 + */
    1.52 +f();
    1.53 +function f()
    1.54 +{
    1.55 +  try
    1.56 +  {
    1.57 +    var x = new eval();
    1.58 +    new eval();
    1.59 +  }
    1.60 +  catch(e)
    1.61 +  {
    1.62 +  }
    1.63 +}
    1.64 +
    1.65 +
    1.66 +/*
    1.67 + * eval scope -
    1.68 + */
    1.69 +var s = '';
    1.70 +s += 'try';
    1.71 +s += '{';
    1.72 +s += '  var x = new eval();';
    1.73 +s += '  new eval();';
    1.74 +s += '}';
    1.75 +s += 'catch(e)';
    1.76 +s += '{';
    1.77 +s += '}';
    1.78 +eval(s);
    1.79 +
    1.80 +
    1.81 +/*
    1.82 + * some combinations of scope -
    1.83 + */
    1.84 +s = '';
    1.85 +s += 'function g()';
    1.86 +s += '{';
    1.87 +s += '  try';
    1.88 +s += '  {';
    1.89 +s += '    var x = new eval();';
    1.90 +s += '    new eval();';
    1.91 +s += '  }';
    1.92 +s += '  catch(e)';
    1.93 +s += '  {';
    1.94 +s += '  }';
    1.95 +s += '}';
    1.96 +s += 'g();';
    1.97 +eval(s);
    1.98 +
    1.99 +
   1.100 +function h()
   1.101 +{
   1.102 +  var s = '';
   1.103 +  s += 'function f()';
   1.104 +  s += '{';
   1.105 +  s += '  try';
   1.106 +  s += '  {';
   1.107 +  s += '    var x = new eval();';
   1.108 +  s += '    new eval();';
   1.109 +  s += '  }';
   1.110 +  s += '  catch(e)';
   1.111 +  s += '  {';
   1.112 +  s += '  }';
   1.113 +  s += '}';
   1.114 +  s += 'f();';
   1.115 +  eval(s);
   1.116 +}
   1.117 +h();
   1.118 +
   1.119 +reportCompare('No Crash', 'No Crash', '');

mercurial