js/src/tests/ecma_3/Object/regress-72773.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_3/Object/regress-72773.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     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 + * Date: 09 May 2001
    1.11 + *
    1.12 + * SUMMARY: Regression test: we shouldn't crash on this code
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=72773
    1.14 + *
    1.15 + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
    1.16 + *
    1.17 + * Same as class-001.js - but testing user-defined types here, not
    1.18 + * native types.  Therefore we expect the [[Class]] property to equal
    1.19 + * 'Object' in each case -
    1.20 + *
    1.21 + * The getJSClass() function we use is in a utility file, e.g. "shell.js"
    1.22 + */
    1.23 +//-----------------------------------------------------------------------------
    1.24 +var BUGNUMBER = 72773;
    1.25 +var summary = "Regression test: we shouldn't crash on this code";
    1.26 +var status = '';
    1.27 +var actual = '';
    1.28 +var expect = '';
    1.29 +var sToEval = '';
    1.30 +
    1.31 +/*
    1.32 + * This code should produce an error, but not a crash.
    1.33 + *  'TypeError: Function.prototype.toString called on incompatible object'
    1.34 + */
    1.35 +sToEval += 'function Cow(name){this.name = name;}'
    1.36 +sToEval += 'function Calf(str){this.name = str;}'
    1.37 +sToEval += 'Calf.prototype = Cow;'
    1.38 +sToEval += 'new Calf().toString();'
    1.39 +
    1.40 +status = 'Trying to catch an expected error';
    1.41 +try
    1.42 +{
    1.43 +  eval(sToEval);
    1.44 +}
    1.45 +catch(e)
    1.46 +{
    1.47 +  actual = getJSClass(e);
    1.48 +  expect = 'Error';
    1.49 +}
    1.50 +
    1.51 +
    1.52 +//----------------------------------------------------------------------------------------------
    1.53 +test();
    1.54 +//----------------------------------------------------------------------------------------------
    1.55 +
    1.56 +
    1.57 +function test()
    1.58 +{
    1.59 +  enterFunc ('test');
    1.60 +  printBugNumber(BUGNUMBER);
    1.61 +  printStatus (summary);
    1.62 +
    1.63 +  reportCompare(expect, actual, status);
    1.64 +
    1.65 +  exitFunc ('test');
    1.66 +}

mercurial