js/src/tests/js1_5/extensions/regress-434837-01.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:3eaac6ad4a94
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 = 434837;
8 var summary = '|this| in accessors in prototype chain of array';
9 var actual = '';
10 var expect = '';
11
12
13 //-----------------------------------------------------------------------------
14 test();
15 //-----------------------------------------------------------------------------
16
17 function test()
18 {
19 enterFunc ('test');
20 printBugNumber(BUGNUMBER);
21 printStatus (summary);
22
23 try
24 {
25 expect = true;
26 actual = null;
27 x = [ "one", "two" ];
28 Array.prototype.__defineGetter__('test1', function() { actual = (this === x); });
29 x.test1;
30 }
31 catch(ex)
32 {
33 actual = ex + '';
34 }
35 reportCompare(expect, actual, summary + ': x.test1');
36
37 try
38 {
39 expect = false;
40 actual = null;
41 Array.prototype.__defineGetter__('test2', function() { actual = (this === Array.prototype) });
42 x.test2;
43 }
44 catch(ex)
45 {
46 actual = ex + '';
47 }
48 reportCompare(expect, actual, summary + ': x.test2');
49
50 Array.prototype.__defineGetter__('test3', function() { actual = (this === x) });
51 Array.prototype.__defineSetter__('test3', function() { actual = (this === x) });
52
53 try
54 {
55 expect = true;
56 actual = null;
57 x.test3;
58 }
59 catch(ex)
60 {
61 actual = ex + '';
62 }
63 reportCompare(expect, actual, summary + ': x.test3 (1)');
64
65 try
66 {
67 expect = true;
68 actual = null;
69 x.test3 = 5;
70 }
71 catch(ex)
72 {
73 actual = ex + '';
74 }
75 reportCompare(expect, actual, summary + ': x.test3 = 5');
76
77 try
78 {
79 expect = true;
80 actual = null;
81 x.test3;
82 }
83 catch(ex)
84 {
85 actual = ex + '';
86 }
87 reportCompare(expect, actual, summary + ': x.test3 (2)');
88
89 exitFunc ('test');
90 }

mercurial