Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / js / tests / js1_5 / extensions / regress-50447-1.js
blob9b6806fe2df5c8c8d2c6300cde1be1e1baeb53f8
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
14 * License.
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
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.
24 * Contributor(s):
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 //-----------------------------------------------------------------------------
60 test();
61 //-----------------------------------------------------------------------------
64 function test()
66 enterFunc ('test');
67 printBugNumber(BUGNUMBER);
68 printStatus (summary);
70 testRealError();
71 test1();
72 test2();
73 test3();
74 test4();
76 exitFunc('test');
80 function testRealError()
82 /* throw a real error, and see what it looks like */
83 enterFunc ("testRealError");
85 try
87 blabla;
89 catch (e)
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");
102 function test1()
104 /* generate an error with msg, file, and lineno properties */
105 enterFunc ("test1");
107 var e = new InternalError ("msg", "file", 2);
108 reportCompare ("(new InternalError(\"msg\", \"file\", 2))",
109 e.toSource(),
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.");
116 exitFunc ("test1");
120 function test2()
122 /* generate an error with only msg property */
123 enterFunc ("test2");
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;
135 else
137 expectedFileName = document.location.href.
138 replace(/[^\/]*(\?.*)$/, '') +
139 expectedFileName;
141 var e = new InternalError ("msg");
142 reportCompare ("(new InternalError(\"msg\", \"" +
143 expectedFileName + "\", " + expectedLine + "))",
144 e.toSource(),
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.");
151 exitFunc ("test2");
155 function test3()
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
164 enterFunc ("test3");
166 var expectedFileName = 'js1_5/extensions/regress-50447-1.js';
167 if (typeof document == "undefined")
169 expectedFileName = './' + expectedFileName;
171 else
173 expectedFileName = document.location.href.
174 replace(/[^\/]*(\?.*)$/, '') +
175 expectedFileName;
178 var e = new InternalError ("msg");
179 e.lineNumber = 10;
180 reportCompare ("(new InternalError(\"msg\", \"" +
181 expectedFileName + "\", 10))",
182 e.toSource(),
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.");
189 exitFunc ("test3");
193 function test4()
195 /* generate an error with only msg and filename properties */
196 enterFunc ("test4");
198 var expectedLine = 200;
200 var e = new InternalError ("msg", "file");
201 reportCompare ("(new InternalError(\"msg\", \"file\", " + expectedLine + "))",
202 e.toSource(),
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.");
209 exitFunc ("test4");