OLD | NEW |
(Empty) | |
| 1 // Copyright 2008 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 |
| 4 // met: |
| 5 // |
| 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. |
| 15 // |
| 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. |
| 27 |
| 28 // Flags: --expose-debug-as debug |
| 29 |
| 30 // Get the Debug object exposed from the debug context global object. |
| 31 Debug = debug.Debug |
| 32 |
| 33 var exception = null; |
| 34 var state = 1; |
| 35 var expected_source_line_text = null; |
| 36 var expected_function_name = null; |
| 37 |
| 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 pauesed inside |
| 40 // function 'g'. |
| 41 function listener(event, exec_state, event_data, data) { |
| 42 try { |
| 43 if (event == Debug.DebugEvent.Break) { |
| 44 if (state == 1) { |
| 45 exec_state.prepareStep(Debug.StepAction.StepIn, 2); |
| 46 state = 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()); |
| 51 state = 3; |
| 52 } |
| 53 } |
| 54 } catch(e) { |
| 55 exception = e; |
| 56 } |
| 57 }; |
| 58 |
| 59 // Add the debug event listener. |
| 60 Debug.setListener(listener); |
| 61 |
| 62 |
| 63 var c = { |
| 64 name: 'name ', |
| 65 get getter1() { |
| 66 return this.name; // getter 1 |
| 67 }, |
| 68 get getter2() { |
| 69 return { // getter 2 |
| 70 'a': c.name |
| 71 }; |
| 72 }, |
| 73 set setter1(n) { |
| 74 this.name = n; // setter 1 |
| 75 } |
| 76 }; |
| 77 |
| 78 c.__defineGetter__('y', function getterY() { |
| 79 return this.name; // getter y |
| 80 }); |
| 81 |
| 82 c.__defineGetter__(3, function getter3() { |
| 83 return this.name; // getter 3 |
| 84 }); |
| 85 |
| 86 c.__defineSetter__('y', function setterY(n) { |
| 87 this.name = n; // setter y |
| 88 }); |
| 89 |
| 90 c.__defineSetter__(3, function setter3(n) { |
| 91 this.name = n; // setter 3 |
| 92 }); |
| 93 |
| 94 var d = { |
| 95 'c': c, |
| 96 }; |
| 97 |
| 98 function testGetter1_1() { |
| 99 expected_function_name = 'getter1'; |
| 100 expected_source_line_text = ' return this.name; // getter 1'; |
| 101 debugger; |
| 102 var x = c.getter1; |
| 103 } |
| 104 |
| 105 function testGetter1_2() { |
| 106 expected_function_name = 'getter1'; |
| 107 expected_source_line_text = ' return this.name; // getter 1'; |
| 108 debugger; |
| 109 var x = c['getter1']; |
| 110 } |
| 111 |
| 112 function testGetter1_3() { |
| 113 expected_function_name = 'getter1'; |
| 114 expected_source_line_text = ' return this.name; // getter 1'; |
| 115 debugger; |
| 116 for (var i = 1; i < 2; i++) { |
| 117 var x = c['getter' + i]; |
| 118 } |
| 119 } |
| 120 |
| 121 function testGetter1_4() { |
| 122 expected_function_name = 'getter1'; |
| 123 expected_source_line_text = ' return this.name; // getter 1'; |
| 124 debugger; |
| 125 var x = d.c.getter1; |
| 126 } |
| 127 |
| 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--); |
| 132 debugger; |
| 133 var x = d.c['getter' + i]; |
| 134 } |
| 135 |
| 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--); |
| 140 debugger; |
| 141 var t = d.c.getter2.name; |
| 142 } |
| 143 |
| 144 |
| 145 function testGetterY_1() { |
| 146 expected_function_name = 'getterY'; |
| 147 expected_source_line_text = ' return this.name; // getter y'; |
| 148 debugger; |
| 149 var t = d.c.y; |
| 150 } |
| 151 |
| 152 function testIndexedGetter3_1() { |
| 153 expected_function_name = 'getter3'; |
| 154 expected_source_line_text = ' return this.name; // getter 3'; |
| 155 debugger; |
| 156 var r = d.c[3]; |
| 157 } |
| 158 |
| 159 function testSetterY_1() { |
| 160 expected_function_name = 'setterY'; |
| 161 expected_source_line_text = ' this.name = n; // setter y'; |
| 162 debugger; |
| 163 d.c.y = 'www'; |
| 164 } |
| 165 |
| 166 function testIndexedSetter3_1() { |
| 167 expected_function_name = 'setter3'; |
| 168 expected_source_line_text = ' this.name = n; // setter 3'; |
| 169 var i = 3 |
| 170 debugger; |
| 171 d.c[3] = 'www'; |
| 172 } |
| 173 |
| 174 function testSetter1_1() { |
| 175 expected_function_name = 'setter1'; |
| 176 expected_source_line_text = ' this.name = n; // setter 1'; |
| 177 debugger; |
| 178 d.c.setter1 = 'aa'; |
| 179 } |
| 180 |
| 181 function testSetter1_2() { |
| 182 expected_function_name = 'setter1'; |
| 183 expected_source_line_text = ' this.name = n; // setter 1'; |
| 184 debugger; |
| 185 d.c['setter1'] = 'bb'; |
| 186 } |
| 187 |
| 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--); |
| 192 debugger; |
| 193 d.c['setter' + i] = i; |
| 194 } |
| 195 |
| 196 var e = { |
| 197 name: 'e' |
| 198 }; |
| 199 e.__proto__ = c; |
| 200 |
| 201 function testProtoGetter1_1() { |
| 202 expected_function_name = 'getter1'; |
| 203 expected_source_line_text = ' return this.name; // getter 1'; |
| 204 debugger; |
| 205 var x = e.getter1; |
| 206 } |
| 207 |
| 208 function testProtoSetter1_1() { |
| 209 expected_function_name = 'setter1'; |
| 210 expected_source_line_text = ' this.name = n; // setter 1'; |
| 211 debugger; |
| 212 e.setter1 = 'aa'; |
| 213 } |
| 214 |
| 215 function testProtoIndexedGetter3_1() { |
| 216 expected_function_name = 'getter3'; |
| 217 expected_source_line_text = ' return this.name; // getter 3'; |
| 218 debugger; |
| 219 var x = e[3]; |
| 220 } |
| 221 |
| 222 function testProtoIndexedSetter3_1() { |
| 223 expected_function_name = 'setter3'; |
| 224 expected_source_line_text = ' this.name = n; // setter 3'; |
| 225 debugger; |
| 226 e[3] = 'new val'; |
| 227 } |
| 228 |
| 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--); |
| 233 debugger; |
| 234 e['setter' + i] = 'aa'; |
| 235 } |
| 236 |
| 237 for (var n in this) { |
| 238 if (n.substr(0, 4) != 'test') { |
| 239 continue; |
| 240 } |
| 241 state = 1; |
| 242 this[n](); |
| 243 assertNull(exception); |
| 244 assertEquals(3, state); |
| 245 } |
| 246 |
| 247 // Get rid of the debug event listener. |
| 248 Debug.setListener(null); |
OLD | NEW |