1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_8/extensions/regress-353116.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 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 = 353116; 1.11 +var summary = 'Improve errors messages for null, undefined properties'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 + 1.16 +//----------------------------------------------------------------------------- 1.17 +test(); 1.18 +//----------------------------------------------------------------------------- 1.19 + 1.20 +function test() 1.21 +{ 1.22 + enterFunc ('test'); 1.23 + printBugNumber(BUGNUMBER); 1.24 + printStatus (summary); 1.25 + 1.26 + expect = 'TypeError: undefined has no properties'; 1.27 + actual = 'No Error'; 1.28 + 1.29 + try 1.30 + { 1.31 + undefined.y; 1.32 + } 1.33 + catch(ex) 1.34 + { 1.35 + actual = ex + ''; 1.36 + } 1.37 + reportCompare(expect, actual, summary); 1.38 + 1.39 + expect = 'TypeError: null has no properties'; 1.40 + actual = 'No Error'; 1.41 + 1.42 + try 1.43 + { 1.44 + null.y; 1.45 + } 1.46 + catch(ex) 1.47 + { 1.48 + actual = ex + ''; 1.49 + } 1.50 + reportCompare(expect, actual, summary); 1.51 + 1.52 + expect = 'TypeError: x is undefined'; 1.53 + actual = 'No Error'; 1.54 + 1.55 + try 1.56 + { 1.57 + x = undefined; 1.58 + x.y; 1.59 + } 1.60 + catch(ex) 1.61 + { 1.62 + actual = ex + ''; 1.63 + } 1.64 + reportCompare(expect, actual, summary); 1.65 + 1.66 + expect = 'TypeError: x is null'; 1.67 + actual = 'No Error'; 1.68 + 1.69 + try 1.70 + { 1.71 + x = null; 1.72 + x.y; 1.73 + } 1.74 + catch(ex) 1.75 + { 1.76 + actual = ex + ''; 1.77 + } 1.78 + reportCompare(expect, actual, summary); 1.79 + 1.80 + exitFunc ('test'); 1.81 +}