1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Communicator client code, released
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
25 * Rob Ginda rginda@netscape.com
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 var gTestfile
= 'regress-50447-1.js';
44 * SUMMARY: New properties fileName, lineNumber have been added to Error objects
45 * in SpiderMonkey. These are non-ECMA extensions and do not exist in Rhino.
47 * See http://bugzilla.mozilla.org/show_bug.cgi?id=50447
49 * 2005-04-05 Modified by bclary to support changes to error reporting
50 * which set default values for the error's fileName and
51 * lineNumber properties.
54 //-----------------------------------------------------------------------------
55 var BUGNUMBER
= 50447;
56 var summary
= 'Test (non-ECMA) Error object properties fileName, lineNumber';
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
67 printBugNumber(BUGNUMBER
);
68 printStatus (summary
);
80 function testRealError()
82 /* throw a real error, and see what it looks like */
83 enterFunc ("testRealError");
91 if (e
.fileName
.search (/-50447-1\.js$/i) == -1)
92 reportCompare('PASS', 'FAIL', "expected fileName to end with '-50447-1.js'");
94 reportCompare(87, e
.lineNumber
,
95 "lineNumber property returned unexpected value.");
98 exitFunc ("testRealError");
104 /* generate an error with msg, file, and lineno properties */
107 var e
= new InternalError ("msg", "file", 2);
108 reportCompare ("(new InternalError(\"msg\", \"file\", 2))",
110 "toSource() returned unexpected result.");
111 reportCompare ("file", e
.fileName
,
112 "fileName property returned unexpected value.");
113 reportCompare (2, e
.lineNumber
,
114 "lineNumber property returned unexpected value.");
122 /* generate an error with only msg property */
125 /* note this test incorporates the path to the
126 test file and assumes the path to the test case
127 is a subdirectory of the directory containing jsDriver.pl
129 var expectedLine
= 141;
130 var expectedFileName
= 'js1_5/extensions/regress-50447-1.js';
131 if (typeof document
== "undefined")
133 expectedFileName
= './' + expectedFileName
;
137 expectedFileName
= document
.location
.href
.
138 replace(/[^\/]*(\?.*)$/, '') +
141 var e
= new InternalError ("msg");
142 reportCompare ("(new InternalError(\"msg\", \"" +
143 expectedFileName
+ "\", " + expectedLine
+ "))",
145 "toSource() returned unexpected result.");
146 reportCompare (expectedFileName
, e
.fileName
,
147 "fileName property returned unexpected value.");
148 reportCompare (expectedLine
, e
.lineNumber
,
149 "lineNumber property returned unexpected value.");
157 /* generate an error with only msg and lineNo properties */
159 /* note this test incorporates the path to the
160 test file and assumes the path to the test case
161 is a subdirectory of the directory containing jsDriver.pl
166 var expectedFileName
= 'js1_5/extensions/regress-50447-1.js';
167 if (typeof document
== "undefined")
169 expectedFileName
= './' + expectedFileName
;
173 expectedFileName
= document
.location
.href
.
174 replace(/[^\/]*(\?.*)$/, '') +
178 var e
= new InternalError ("msg");
180 reportCompare ("(new InternalError(\"msg\", \"" +
181 expectedFileName
+ "\", 10))",
183 "toSource() returned unexpected result.");
184 reportCompare (expectedFileName
, e
.fileName
,
185 "fileName property returned unexpected value.");
186 reportCompare (10, e
.lineNumber
,
187 "lineNumber property returned unexpected value.");
195 /* generate an error with only msg and filename properties */
198 var expectedLine
= 200;
200 var e
= new InternalError ("msg", "file");
201 reportCompare ("(new InternalError(\"msg\", \"file\", " + expectedLine
+ "))",
203 "toSource() returned unexpected result.");
204 reportCompare ("file", e
.fileName
,
205 "fileName property returned unexpected value.");
206 reportCompare (expectedLine
, e
.lineNumber
,
207 "lineNumber property returned unexpected value.");