| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 // Flags: --expose-debug-as debug | 28 // Flags: --expose-debug-as debug |
| 29 | 29 |
| 30 // Get the Debug object exposed from the debug context global object. | 30 // Get the Debug object exposed from the debug context global object. |
| 31 Debug = debug.Debug | 31 Debug = debug.Debug; |
| 32 | 32 |
| 33 var exception = null; | 33 var exception = null; |
| 34 var state = 1; | 34 var state = 1; |
| 35 var expected_source_line_text = null; | 35 var expected_source_line_text = null; |
| 36 var expected_function_name = null; | 36 var expected_function_name = null; |
| 37 | 37 |
| 38 // Simple debug event handler which first time will cause 'step in' action | 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 | 39 // to get into g.call and than check that execution is stopped inside |
| 40 // function 'g'. | 40 // function 'g'. |
| 41 function listener(event, exec_state, event_data, data) { | 41 function listener(event, exec_state, event_data, data) { |
| 42 try { | 42 try { |
| 43 if (event == Debug.DebugEvent.Break) { | 43 if (event == Debug.DebugEvent.Break) { |
| 44 if (state == 1) { | 44 if (state == 1) { |
| 45 exec_state.prepareStep(Debug.StepAction.StepIn, 2); | 45 exec_state.prepareStep(Debug.StepAction.StepIn, 2); |
| 46 state = 2; | 46 state = 2; |
| 47 } else if (state == 2) { | 47 } else if (state == 2) { |
| 48 assertEquals(expected_source_line_text, | 48 assertEquals(expected_source_line_text, |
| 49 event_data.sourceLineText()); | 49 event_data.sourceLineText()); |
| 50 assertEquals(expected_function_name, event_data.func().name()); | 50 assertEquals(expected_function_name, event_data.func().name()); |
| 51 state = 3; | 51 state = 3; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 } catch(e) { | 54 } catch(e) { |
| 55 exception = e; | 55 exception = e; |
| 56 } | 56 } |
| 57 }; | 57 } |
| 58 | 58 |
| 59 // Add the debug event listener. | 59 // Add the debug event listener. |
| 60 Debug.setListener(listener); | 60 Debug.setListener(listener); |
| 61 | 61 |
| 62 | 62 |
| 63 var c = { | 63 var c = { |
| 64 name: 'name ', | 64 name: 'name ', |
| 65 get getter1() { | 65 get getter1() { |
| 66 return this.name; // getter 1 | 66 return this.name; // getter 1 |
| 67 }, | 67 }, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 function testGetter1_4() { | 121 function testGetter1_4() { |
| 122 expected_function_name = 'getter1'; | 122 expected_function_name = 'getter1'; |
| 123 expected_source_line_text = ' return this.name; // getter 1'; | 123 expected_source_line_text = ' return this.name; // getter 1'; |
| 124 debugger; | 124 debugger; |
| 125 var x = d.c.getter1; | 125 var x = d.c.getter1; |
| 126 } | 126 } |
| 127 | 127 |
| 128 function testGetter1_5() { | 128 function testGetter1_5() { |
| 129 expected_function_name = 'getter1'; | 129 expected_function_name = 'getter1'; |
| 130 expected_source_line_text = ' return this.name; // getter 1'; | 130 expected_source_line_text = ' return this.name; // getter 1'; |
| 131 for (var i = 2; i != 1; i--); | 131 for (var i = 2; i != 1; i--) { } |
| 132 debugger; | 132 debugger; |
| 133 var x = d.c['getter' + i]; | 133 var x = d.c['getter' + i]; |
| 134 } | 134 } |
| 135 | 135 |
| 136 function testGetter2_1() { | 136 function testGetter2_1() { |
| 137 expected_function_name = 'getter2'; | 137 expected_function_name = 'getter2'; |
| 138 expected_source_line_text = ' return { // getter 2'; | 138 expected_source_line_text = ' return { // getter 2'; |
| 139 for (var i = 2; i != 1; i--); | 139 for (var i = 2; i != 1; i--) { } |
| 140 debugger; | 140 debugger; |
| 141 var t = d.c.getter2.name; | 141 var t = d.c.getter2.name; |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 function testGetterY_1() { | 145 function testGetterY_1() { |
| 146 expected_function_name = 'getterY'; | 146 expected_function_name = 'getterY'; |
| 147 expected_source_line_text = ' return this.name; // getter y'; | 147 expected_source_line_text = ' return this.name; // getter y'; |
| 148 debugger; | 148 debugger; |
| 149 var t = d.c.y; | 149 var t = d.c.y; |
| 150 } | 150 } |
| 151 | 151 |
| 152 function testIndexedGetter3_1() { | 152 function testIndexedGetter3_1() { |
| 153 expected_function_name = 'getter3'; | 153 expected_function_name = 'getter3'; |
| 154 expected_source_line_text = ' return this.name; // getter 3'; | 154 expected_source_line_text = ' return this.name; // getter 3'; |
| 155 debugger; | 155 debugger; |
| 156 var r = d.c[3]; | 156 var r = d.c[3]; |
| 157 } | 157 } |
| 158 | 158 |
| 159 function testSetterY_1() { | 159 function testSetterY_1() { |
| 160 expected_function_name = 'setterY'; | 160 expected_function_name = 'setterY'; |
| 161 expected_source_line_text = ' this.name = n; // setter y'; | 161 expected_source_line_text = ' this.name = n; // setter y'; |
| 162 debugger; | 162 debugger; |
| 163 d.c.y = 'www'; | 163 d.c.y = 'www'; |
| 164 } | 164 } |
| 165 | 165 |
| 166 function testIndexedSetter3_1() { | 166 function testIndexedSetter3_1() { |
| 167 expected_function_name = 'setter3'; | 167 expected_function_name = 'setter3'; |
| 168 expected_source_line_text = ' this.name = n; // setter 3'; | 168 expected_source_line_text = ' this.name = n; // setter 3'; |
| 169 var i = 3 | 169 var i = 3; |
| 170 debugger; | 170 debugger; |
| 171 d.c[3] = 'www'; | 171 d.c[3] = 'www'; |
| 172 } | 172 } |
| 173 | 173 |
| 174 function testSetter1_1() { | 174 function testSetter1_1() { |
| 175 expected_function_name = 'setter1'; | 175 expected_function_name = 'setter1'; |
| 176 expected_source_line_text = ' this.name = n; // setter 1'; | 176 expected_source_line_text = ' this.name = n; // setter 1'; |
| 177 debugger; | 177 debugger; |
| 178 d.c.setter1 = 'aa'; | 178 d.c.setter1 = 'aa'; |
| 179 } | 179 } |
| 180 | 180 |
| 181 function testSetter1_2() { | 181 function testSetter1_2() { |
| 182 expected_function_name = 'setter1'; | 182 expected_function_name = 'setter1'; |
| 183 expected_source_line_text = ' this.name = n; // setter 1'; | 183 expected_source_line_text = ' this.name = n; // setter 1'; |
| 184 debugger; | 184 debugger; |
| 185 d.c['setter1'] = 'bb'; | 185 d.c['setter1'] = 'bb'; |
| 186 } | 186 } |
| 187 | 187 |
| 188 function testSetter1_3() { | 188 function testSetter1_3() { |
| 189 expected_function_name = 'setter1'; | 189 expected_function_name = 'setter1'; |
| 190 expected_source_line_text = ' this.name = n; // setter 1'; | 190 expected_source_line_text = ' this.name = n; // setter 1'; |
| 191 for (var i = 2; i != 1; i--); | 191 for (var i = 2; i != 1; i--) { } |
| 192 debugger; | 192 debugger; |
| 193 d.c['setter' + i] = i; | 193 d.c['setter' + i] = i; |
| 194 } | 194 } |
| 195 | 195 |
| 196 var e = { | 196 var e = { |
| 197 name: 'e' | 197 name: 'e' |
| 198 }; | 198 }; |
| 199 e.__proto__ = c; | 199 e.__proto__ = c; |
| 200 | 200 |
| 201 function testProtoGetter1_1() { | 201 function testProtoGetter1_1() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 222 function testProtoIndexedSetter3_1() { | 222 function testProtoIndexedSetter3_1() { |
| 223 expected_function_name = 'setter3'; | 223 expected_function_name = 'setter3'; |
| 224 expected_source_line_text = ' this.name = n; // setter 3'; | 224 expected_source_line_text = ' this.name = n; // setter 3'; |
| 225 debugger; | 225 debugger; |
| 226 e[3] = 'new val'; | 226 e[3] = 'new val'; |
| 227 } | 227 } |
| 228 | 228 |
| 229 function testProtoSetter1_2() { | 229 function testProtoSetter1_2() { |
| 230 expected_function_name = 'setter1'; | 230 expected_function_name = 'setter1'; |
| 231 expected_source_line_text = ' this.name = n; // setter 1'; | 231 expected_source_line_text = ' this.name = n; // setter 1'; |
| 232 for (var i = 2; i != 1; i--); | 232 for (var i = 2; i != 1; i--) { } |
| 233 debugger; | 233 debugger; |
| 234 e['setter' + i] = 'aa'; | 234 e['setter' + i] = 'aa'; |
| 235 } | 235 } |
| 236 | 236 |
| 237 for (var n in this) { | 237 for (var n in this) { |
| 238 if (n.substr(0, 4) != 'test') { | 238 if (n.substr(0, 4) != 'test') { |
| 239 continue; | 239 continue; |
| 240 } | 240 } |
| 241 state = 1; | 241 state = 1; |
| 242 this[n](); | 242 this[n](); |
| 243 assertNull(exception); | 243 assertNull(exception); |
| 244 assertEquals(3, state); | 244 assertEquals(3, state); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // Get rid of the debug event listener. | 247 // Get rid of the debug event listener. |
| 248 Debug.setListener(null); | 248 Debug.setListener(null); |
| OLD | NEW |