OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 var x = {}; | 28 var x = {}; |
29 | 29 |
30 // Add property a with getter/setter. | 30 // Add property a with getter/setter. |
31 x.__defineGetter__("a", function() { | 31 x.__defineGetter__("a", function() { |
32 try { | 32 try { |
33 y.x = 40; | 33 y.x = 40; |
34 } catch (e) { | 34 } catch (e) { |
35 assertEquals(3, e.stack.split('\n').length); | 35 assertEquals(3, e.stack.split('\n').length); |
36 } | 36 } |
37 return 40; | 37 return 40; |
38 }); | 38 }); |
39 | 39 |
40 x.__defineSetter__("a", function(val) { | 40 x.__defineSetter__("a", function(val) { |
41 try { | 41 try { |
42 y.x = 40; | 42 y.x = 40; |
43 } catch(e) { | 43 } catch(e) { |
44 assertEquals(3, e.stack.split('\n').length); | 44 assertEquals(3, e.stack.split('\n').length); |
45 } | 45 } |
46 }); | 46 }); |
47 | 47 |
48 // Add property b with getter/setter. | 48 // Add property b with getter/setter. |
49 function getB() { | 49 function getB() { |
50 try { | 50 try { |
51 y.x = 30; | 51 y.x = 30; |
52 } catch (e) { | 52 } catch (e) { |
53 assertEquals(3, e.stack.split('\n').length); | 53 assertEquals(3, e.stack.split('\n').length); |
54 } | 54 } |
55 return 30; | 55 return 30; |
56 } | 56 } |
57 | 57 |
58 function setB(val) { | 58 function setB(val) { |
59 try { | 59 try { |
60 y.x = 30; | 60 y.x = 30; |
61 } catch(e) { | 61 } catch(e) { |
62 assertEquals(3, e.stack.split('\n').length); | 62 assertEquals(3, e.stack.split('\n').length); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 x.__defineGetter__("b", getB); | 66 x.__defineGetter__("b", getB); |
67 x.__defineSetter__("b", setB); | 67 x.__defineSetter__("b", setB); |
68 | 68 |
69 // Add property c with getter/setter. | 69 // Add property c with getter/setter. |
70 var descriptor = { | 70 var descriptor = { |
71 get: function() { | 71 get: function() { |
72 try { | 72 try { |
73 y.x = 40; | 73 y.x = 40; |
74 } catch (e) { | 74 } catch (e) { |
75 assertEquals(3, e.stack.split('\n').length); | 75 assertEquals(3, e.stack.split('\n').length); |
76 } | 76 } |
77 return 40; | 77 return 40; |
78 }, | 78 }, |
79 set: function(val) { | 79 set: function(val) { |
80 try { | 80 try { |
81 y.x = 40; | 81 y.x = 40; |
82 } catch(e) { | 82 } catch(e) { |
83 assertEquals(3, e.stack.split('\n').length); | 83 assertEquals(3, e.stack.split('\n').length); |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 Object.defineProperty(x, 'c', descriptor) | 88 Object.defineProperty(x, 'c', descriptor) |
89 | 89 |
90 // Check that the stack for an exception in a getter and setter produce the | 90 // Check that the stack for an exception in a getter and setter produce the |
91 // expected stack height. | 91 // expected stack height. |
92 x.a; | 92 x.a; |
93 x.b; | 93 x.b; |
94 x.c; | 94 x.c; |
95 x.a = 1; | 95 x.a = 1; |
96 x.b = 1; | 96 x.b = 1; |
97 x.c = 1; | 97 x.c = 1; |
98 | 98 |
99 // Do the same with the getters/setters on the a prototype object. | 99 // Do the same with the getters/setters on the a prototype object. |
100 xx = {} | 100 xx = {} |
101 xx.__proto__ = x | 101 xx.__proto__ = x |
102 | 102 |
103 xx.a; | 103 xx.a; |
104 xx.b; | 104 xx.b; |
105 xx.c; | 105 xx.c; |
106 xx.a = 1; | 106 xx.a = 1; |
107 xx.b = 1; | 107 xx.b = 1; |
108 xx.c = 1; | 108 xx.c = 1; |
OLD | NEW |