Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / js / tests / js1_5 / Regress / regress-68498-004.js
blob214895e59e0e11e02dfb17eeba03a3b9ad11b813
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * brendan@mozilla.org, pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * Date: 15 Feb 2001
42 * SUMMARY: self.eval(str) inside a function
43 * NOTE: 'self' is just a variable used to capture the global JS object.
45 * See http://bugzilla.mozilla.org/show_bug.cgi?id=68498
46 * See http://bugzilla.mozilla.org/showattachment.cgi?attach_id=25251
47 * See http://bugzilla.mozilla.org/show_bug.cgi?id=69441 (!!!)
49 * Brendan:
51 * "ECMA-262 Edition 3, 10.1.3 requires a FunctionDeclaration parsed as part
52 * of a Program by eval to create a property of eval's caller's variable object.
53 * This test evals in the body of a with statement, whose scope chain *is*
54 * relevant to the effect of parsing the FunctionDeclaration."
56 //-----------------------------------------------------------------------------
57 var gTestfile = 'regress-68498-004.js';
58 var BUGNUMBER = 68498;
59 var summary = 'Testing self.eval(str) inside a function';
60 var statprefix = '; currently at expect[';
61 var statsuffix = '] within test -';
62 var sToEval='';
63 var actual=[ ];
64 var expect=[ ];
67 // Capture a reference to the global object -
68 var self = this;
70 // You shouldn't see this global variable's value in any printout -
71 var x = 'outer';
73 // This function is the heart of the test -
74 function f(o,s,x) {with(o) eval(s); return z;};
76 // Run-time statements to pass to the eval inside f
77 sToEval += 'actual[0] = typeof g;'
78 sToEval += 'function g(){actual[1]=(typeof w == "undefined" || w); return x};'
79 sToEval += 'actual[2] = w;'
80 sToEval += 'actual[3] = typeof g;'
81 sToEval += 'var z=g();'
83 // Set the actual-results array. The next line will set actual[0] - actual[4] in one shot
84 actual[4] = f({w:44}, sToEval, 'inner');
85 actual[5] = 'z' in self && z;
88 /* Set the expected-results array.
90 * Sample issue: why do we set expect[4] = 'inner'? Look at actual[4]...
91 * 1. The return value of f equals z, which is not defined at compile-time
92 * 2. At run-time (via with(o) eval(s) inside f), z is defined as the return value of g
93 * 3. At run-time (via with(o) eval(s) inside f), g is defined to return x
94 * 4. In the scope of with(o), x is undefined
95 * 5. Farther up the scope chain, x can be located as an argument of f
96 * 6. The value of this argument at run-time is 'inner'
97 * 7. Even farther up the scope chain, the name x can be found as a global variable
98 * 8. The value of this global variable is 'outer', but we should NOT have gone
99 * this far up the scope chain to find x...therefore we expect 'inner'
101 expect[0] = 'function';
102 expect[1] = 44;
103 expect[2] = 44;
104 expect[3] = 'function';
105 expect[4] = 'inner';
106 expect[5] = false;
110 //------------------------------------------------------------------------------------------------
111 test();
112 //-------------------------------------------------------------------------------------------------
115 function test()
117 enterFunc ('test');
118 printBugNumber(BUGNUMBER);
119 printStatus (summary);
121 for (var i in expect)
123 reportCompare(expect[i], actual[i], getStatus(i));
126 exitFunc ('test');
130 function getStatus(i)
132 return (summary + statprefix + i + statsuffix);