1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Array/regress-108440.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android 1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* 1.11 + * 1.12 + * Date: 30 October 2001 1.13 + * SUMMARY: Regression test for bug 108440 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=108440 1.15 + * 1.16 + * We shouldn't crash trying to add an array as an element of itself (!) 1.17 + * 1.18 + * Brendan: "...it appears that Array.prototype.toString is unsafe, 1.19 + * and what's more, ECMA-262 Edition 3 has no helpful words about 1.20 + * avoiding recursive death on a cycle." 1.21 + */ 1.22 +//----------------------------------------------------------------------------- 1.23 +var BUGNUMBER = 108440; 1.24 +var summary = "Shouldn't crash trying to add an array as an element of itself"; 1.25 +var self = this; 1.26 +var temp = ''; 1.27 + 1.28 +printBugNumber(BUGNUMBER); 1.29 +printStatus(summary); 1.30 + 1.31 +/* 1.32 + * Explicit test: 1.33 + */ 1.34 +var a=[]; 1.35 +temp = (a[a.length]=a); 1.36 + 1.37 +/* 1.38 + * Implicit test (one of the properties of |self| is |a|) 1.39 + */ 1.40 +a=[]; 1.41 +for(var prop in self) 1.42 +{ 1.43 + temp = prop; 1.44 + temp = (a[a.length] = self[prop]); 1.45 +} 1.46 + 1.47 +/* 1.48 + * Stressful explicit test 1.49 + */ 1.50 +a=[]; 1.51 +for (var i=0; i<10; i++) 1.52 +{ 1.53 + a[a.length] = a; 1.54 +} 1.55 + 1.56 +/* 1.57 + * Test toString() 1.58 + */ 1.59 +a=[]; 1.60 +for (var i=0; i<10; i++) 1.61 +{ 1.62 + a[a.length] = a.toString(); 1.63 +} 1.64 + 1.65 +/* 1.66 + * Test toSource() - but Rhino doesn't have this, so try...catch it 1.67 + */ 1.68 +a=[]; 1.69 +try 1.70 +{ 1.71 + for (var i=0; i<10; i++) 1.72 + { 1.73 + a[a.length] = a.toSource(); 1.74 + } 1.75 +} 1.76 +catch(e) 1.77 +{ 1.78 +} 1.79 + 1.80 +reportCompare('No Crash', 'No Crash', '');