1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Exceptions/15.11.7.6-002.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 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: 14 April 2003 1.12 + * SUMMARY: Prototype of predefined error objects should be DontDelete 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 1.14 + * 1.15 + */ 1.16 +//----------------------------------------------------------------------------- 1.17 +var UBound = 0; 1.18 +var BUGNUMBER = 201989; 1.19 +var summary = 'Prototype of predefined error objects should be DontDelete'; 1.20 +var status = ''; 1.21 +var statusitems = []; 1.22 +var actual = ''; 1.23 +var actualvalues = []; 1.24 +var expect= ''; 1.25 +var expectedvalues = []; 1.26 + 1.27 + 1.28 +/* 1.29 + * Tests that |F.prototype| is DontDelete 1.30 + */ 1.31 +function testDontDelete(F) 1.32 +{ 1.33 + var e; 1.34 + var orig = F.prototype; 1.35 + try 1.36 + { 1.37 + delete F.prototype; 1.38 + } 1.39 + catch (e) 1.40 + { 1.41 + } 1.42 + return F.prototype === orig; 1.43 +} 1.44 + 1.45 + 1.46 +var list = [ 1.47 + "Error", 1.48 + "ConversionError", 1.49 + "EvalError", 1.50 + "RangeError", 1.51 + "ReferenceError", 1.52 + "SyntaxError", 1.53 + "TypeError", 1.54 + "URIError" 1.55 + ]; 1.56 + 1.57 + 1.58 +for (i in list) 1.59 +{ 1.60 + var F = this[list[i]]; 1.61 + 1.62 + // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. 1.63 + if (F) 1.64 + { 1.65 + status = 'Testing DontDelete attribute of |' + list[i] + '.prototype|'; 1.66 + actual = testDontDelete(F); 1.67 + expect = true; 1.68 + addThis(); 1.69 + } 1.70 +} 1.71 + 1.72 + 1.73 + 1.74 +//----------------------------------------------------------------------------- 1.75 +test(); 1.76 +//----------------------------------------------------------------------------- 1.77 + 1.78 + 1.79 + 1.80 +function addThis() 1.81 +{ 1.82 + statusitems[UBound] = status; 1.83 + actualvalues[UBound] = actual; 1.84 + expectedvalues[UBound] = expect; 1.85 + UBound++; 1.86 +} 1.87 + 1.88 + 1.89 +function test() 1.90 +{ 1.91 + enterFunc('test'); 1.92 + printBugNumber(BUGNUMBER); 1.93 + printStatus(summary); 1.94 + 1.95 + for (var i=0; i<UBound; i++) 1.96 + { 1.97 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.98 + } 1.99 + 1.100 + exitFunc ('test'); 1.101 +}