]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/Scope/scope-001.js
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
19 * Contributor(s): pschwartau@netscape.com
22 * The idea behind bug 53268 is as follows. The item 'five' below is defined
23 * as const, hence is a read-only property of the global object. So if we set
24 * obj.__proto__ = this, 'five' should become a read-only propery of obj.
26 * If we then change obj.__proto__ to null, obj.five should initially be
27 * undefined. We should be able to define obj.five to whatever we want,
28 * and be able to access this value as obj.five.
30 * Bug 53268 was filed because obj.five could not be set or accessed after
31 * obj.__proto__ had been set to the global object and then to null.
33 //-----------------------------------------------------------------------------
35 var status
= 'Testing scope after changing obj.__proto__';
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
54 status
= 'Step 1: setting obj.__proto__ = global object';
59 reportCompare (expect
, actual
, status
);
64 reportCompare (expect
, actual
, status
);
68 status
= 'Step 2: setting obj.__proto__ = null';
73 reportCompare (expect
, actual
, status
);
78 reportCompare (expect
, actual
, status
);
82 status
= 'Step 3: setting obj.__proto__ to global object again';
86 expect
=2; //<--- (FROM STEP 2 ABOVE)
87 reportCompare (expect
, actual
, status
);
92 reportCompare (expect
, actual
, status
);
96 status
= 'Step 4: setting obj.__proto__ to null again';
100 expect
=3; //<--- (FROM STEP 3 ABOVE)
101 reportCompare (expect
, actual
, status
);
106 reportCompare (expect
, actual
, status
);