1 /* ***** BEGIN LICENSE BLOCK *****
\r
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
4 * The contents of this file are subject to the Mozilla Public License Version
\r
5 * 1.1 (the "License"); you may not use this file except in compliance with
\r
6 * the License. You may obtain a copy of the License at
\r
7 * http://www.mozilla.org/MPL/
\r
9 * Software distributed under the License is distributed on an "AS IS" basis,
\r
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
11 * for the specific language governing rights and limitations under the
\r
14 * The Original Code is mozilla.org code.
\r
16 * The Initial Developer of the Original Code is
\r
17 * Netscape Communications Corporation.
\r
18 * Portions created by the Initial Developer are Copyright (C) 1998
\r
19 * the Initial Developer. All Rights Reserved.
\r
22 * pschwartau@netscape.com
\r
24 * Alternatively, the contents of this file may be used under the terms of
\r
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
\r
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
\r
27 * in which case the provisions of the GPL or the LGPL are applicable instead
\r
28 * of those above. If you wish to allow use of your version of this file only
\r
29 * under the terms of either the GPL or the LGPL, and not to allow others to
\r
30 * use your version of this file under the terms of the MPL, indicate your
\r
31 * decision by deleting the provisions above and replace them with the notice
\r
32 * and other provisions required by the GPL or the LGPL. If you do not delete
\r
33 * the provisions above, a recipient may use your version of this file under
\r
34 * the terms of any one of the MPL, the GPL or the LGPL.
\r
36 * ***** END LICENSE BLOCK *****
\r
40 * SUMMARY: Testing visiblity of variables from within a with block.
\r
41 * See http://bugzilla.mozilla.org/show_bug.cgi?id=90325
\r
43 //-------------------------------------------------------------------------------------------------
\r
46 var summary = 'Testing visiblity of variables from within a with block';
\r
48 var statusitems = [];
\r
50 var actualvalues = [];
\r
52 var expectedvalues = [];
\r
54 // (compare local definitions which follow) -
\r
60 // an object with 'C' and 'D' properties -
\r
61 var objTEST = new Object();
\r
66 status = 'Section 1 of test';
\r
70 expect = 'global A';
\r
75 status = 'Section 2 of test';
\r
79 expect = 'global B';
\r
84 status = 'Section 3 of test';
\r
88 expect = 'global C';
\r
93 status = 'Section 4 of test';
\r
97 status = 'Section 5 of test';
\r
101 status = 'Section 6 of test';
\r
105 status = 'Section 7 of test';
\r
106 localC(new Object());
\r
109 status = 'Section 8 of test';
\r
110 localC.apply(new Object());
\r
113 status = 'Section 9 of test';
\r
114 localC.apply(new Object(), [objTEST]);
\r
117 status = 'Section 10 of test';
\r
118 localC.apply(objTEST, [objTEST]);
\r
121 status = 'Section 11 of test';
\r
122 localD(new Object());
\r
125 status = 'Section 12 of test';
\r
126 localD.apply(new Object(), [objTEST]);
\r
129 status = 'Section 13 of test';
\r
130 localD.apply(objTEST, [objTEST]);
\r
135 //-------------------------------------------------------------------------------------------------
\r
137 //-------------------------------------------------------------------------------------------------
\r
141 // contains a with(new Object()) block -
\r
149 expect = 'local A';
\r
154 // contains a with(Number) block -
\r
162 expect = 'local B';
\r
167 // contains a with(this) block -
\r
168 function localC(obj)
\r
180 expect = 'local C';
\r
184 // contains a with(obj) block -
\r
185 function localD(obj)
\r
197 expect = 'local D';
\r
203 statusitems[UBound] = status;
\r
204 actualvalues[UBound] = actual;
\r
205 expectedvalues[UBound] = expect;
\r
212 enterFunc ('test');
\r
213 printBugNumber (bug);
\r
214 printStatus (summary);
\r
216 for (var i = 0; i < UBound; i++)
\r
218 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
\r