js/src/tests/js1_5/extensions/scope-001.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:8b37e7067c32
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = '53268';
8 var status = 'Testing scope after changing obj.__proto__';
9 var expect= '';
10 var actual = '';
11 var obj = {};
12 const five = 5;
13
14
15 //-----------------------------------------------------------------------------
16 test();
17 //-----------------------------------------------------------------------------
18
19
20 function test()
21 {
22 enterFunc ("test");
23 printBugNumber(BUGNUMBER);
24 printStatus (status);
25
26
27 status= 'Step 1: setting obj.__proto__ = global object';
28 obj.__proto__ = this;
29
30 actual = obj.five;
31 expect=5;
32 reportCompare (expect, actual, status);
33
34 obj.five=1;
35 actual = obj.five;
36 expect=5;
37 reportCompare (expect, actual, status);
38
39
40
41 status= 'Step 2: setting obj.__proto__ = null';
42 obj.__proto__ = null;
43
44 actual = obj.five;
45 expect=undefined;
46 reportCompare (expect, actual, status);
47
48 obj.five=2;
49 actual = obj.five;
50 expect=2;
51 reportCompare (expect, actual, status);
52
53
54
55 status= 'Step 3: setting obj.__proto__ to global object again';
56 obj.__proto__ = this;
57
58 actual = obj.five;
59 expect=2; //<--- (FROM STEP 2 ABOVE)
60 reportCompare (expect, actual, status);
61
62 obj.five=3;
63 actual = obj.five;
64 expect=3;
65 reportCompare (expect, actual, status);
66
67
68
69 status= 'Step 4: setting obj.__proto__ to null again';
70 obj.__proto__ = null;
71
72 actual = obj.five;
73 expect=3; //<--- (FROM STEP 3 ABOVE)
74 reportCompare (expect, actual, status);
75
76 obj.five=4;
77 actual = obj.five;
78 expect=4;
79 reportCompare (expect, actual, status);
80
81
82 exitFunc ("test");
83 }

mercurial