Debian Codegraph @

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

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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 printBugNumber(BUGNUMBER);
20 printStatus (summary);
21
22 try
23 {
24 expect = true;
25 actual = null;
26 x = [ "one", "two" ];
27 Array.prototype.__defineGetter__('test1', function() { actual = (this === x); });
28 x.test1;
29 }
30 catch(ex)
31 {
32 actual = ex + '';
33 }
34 reportCompare(expect, actual, summary + ': x.test1');
35
36 try
37 {
38 expect = false;
39 actual = null;
40 Array.prototype.__defineGetter__('test2', function() { actual = (this === Array.prototype) });
41 x.test2;
42 }
43 catch(ex)
44 {
45 actual = ex + '';
46 }
47 reportCompare(expect, actual, summary + ': x.test2');
48
49 Array.prototype.__defineGetter__('test3', function() { actual = (this === x) });
50 Array.prototype.__defineSetter__('test3', function() { actual = (this === x) });
51
52 try
53 {
54 expect = true;
55 actual = null;
56 x.test3;
57 }
58 catch(ex)
59 {
60 actual = ex + '';
61 }
62 reportCompare(expect, actual, summary + ': x.test3 (1)');
63
64 try
65 {
66 expect = true;
67 actual = null;
68 x.test3 = 5;
69 }
70 catch(ex)
71 {
72 actual = ex + '';
73 }
74 reportCompare(expect, actual, summary + ': x.test3 = 5');
75
76 try
77 {
78 expect = true;
79 actual = null;
80 x.test3;
81 }
82 catch(ex)
83 {
84 actual = ex + '';
85 }
86 reportCompare(expect, actual, summary + ': x.test3 (2)');
87 }