1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28 // Flags: --expose-debug-as debug
30 // Get the Debug object exposed from the debug context global object.
35 var expected_source_line_text = null;
36 var expected_function_name = null;
38 // Simple debug event handler which first time will cause 'step in' action
39 // to get into g.call and than check that execution is stopped inside
41 function listener(event, exec_state, event_data, data) {
43 if (event == Debug.DebugEvent.Break) {
45 exec_state.prepareStep(Debug.StepAction.StepIn, 2);
47 } else if (state == 2) {
48 assertEquals(expected_source_line_text,
49 event_data.sourceLineText());
50 assertEquals(expected_function_name, event_data.func().name());
59 // Add the debug event listener.
60 Debug.setListener(listener);
66 return this.name; // getter 1
74 this.name = n; // setter 1
78 c.__defineGetter__('y', function getterY() {
79 return this.name; // getter y
82 c.__defineGetter__(3, function getter3() {
83 return this.name; // getter 3
86 c.__defineSetter__('y', function setterY(n) {
87 this.name = n; // setter y
90 c.__defineSetter__(3, function setter3(n) {
91 this.name = n; // setter 3
98 function testGetter1_1() {
99 expected_function_name = 'getter1';
100 expected_source_line_text = ' return this.name; // getter 1';
105 function testGetter1_2() {
106 expected_function_name = 'getter1';
107 expected_source_line_text = ' return this.name; // getter 1';
109 var x = c['getter1'];
112 function testGetter1_3() {
113 expected_function_name = 'getter1';
114 expected_source_line_text = ' return this.name; // getter 1';
115 for (var i = 1; i < 2; i++) {
117 var x = c['getter' + i];
121 function testGetter1_4() {
122 expected_function_name = 'getter1';
123 expected_source_line_text = ' return this.name; // getter 1';
128 function testGetter1_5() {
129 expected_function_name = 'getter1';
130 expected_source_line_text = ' return this.name; // getter 1';
131 for (var i = 2; i != 1; i--);
133 var x = d.c['getter' + i];
136 function testGetter2_1() {
137 expected_function_name = 'getter2';
138 expected_source_line_text = ' return { // getter 2';
139 for (var i = 2; i != 1; i--);
141 var t = d.c.getter2.name;
145 function testGetterY_1() {
146 expected_function_name = 'getterY';
147 expected_source_line_text = ' return this.name; // getter y';
152 function testIndexedGetter3_1() {
153 expected_function_name = 'getter3';
154 expected_source_line_text = ' return this.name; // getter 3';
159 function testSetterY_1() {
160 expected_function_name = 'setterY';
161 expected_source_line_text = ' this.name = n; // setter y';
166 function testIndexedSetter3_1() {
167 expected_function_name = 'setter3';
168 expected_source_line_text = ' this.name = n; // setter 3';
174 function testSetter1_1() {
175 expected_function_name = 'setter1';
176 expected_source_line_text = ' this.name = n; // setter 1';
181 function testSetter1_2() {
182 expected_function_name = 'setter1';
183 expected_source_line_text = ' this.name = n; // setter 1';
185 d.c['setter1'] = 'bb';
188 function testSetter1_3() {
189 expected_function_name = 'setter1';
190 expected_source_line_text = ' this.name = n; // setter 1';
191 for (var i = 2; i != 1; i--);
193 d.c['setter' + i] = i;
201 function testProtoGetter1_1() {
202 expected_function_name = 'getter1';
203 expected_source_line_text = ' return this.name; // getter 1';
208 function testProtoSetter1_1() {
209 expected_function_name = 'setter1';
210 expected_source_line_text = ' this.name = n; // setter 1';
215 function testProtoIndexedGetter3_1() {
216 expected_function_name = 'getter3';
217 expected_source_line_text = ' return this.name; // getter 3';
222 function testProtoIndexedSetter3_1() {
223 expected_function_name = 'setter3';
224 expected_source_line_text = ' this.name = n; // setter 3';
229 function testProtoSetter1_2() {
230 expected_function_name = 'setter1';
231 expected_source_line_text = ' this.name = n; // setter 1';
232 for (var i = 2; i != 1; i--);
234 e['setter' + i] = 'aa';
237 for (var n in this) {
238 if (n.substr(0, 4) != 'test') {
243 assertNull(exception);
244 assertEquals(3, state);
247 // Get rid of the debug event listener.
248 Debug.setListener(null);