| 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 13 matching lines...) Expand all Loading... |
| 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 // The functions used for testing backtraces. They are at the top to make the | 29 // The functions used for testing backtraces. They are at the top to make the |
| 30 // testing of source line/column easier. | 30 // testing of source line/column easier. |
| 31 | 31 |
| 32 | 32 |
| 33 // Get the Debug object exposed from the debug context global object. | 33 // Get the Debug object exposed from the debug context global object. |
| 34 Debug = debug.Debug | 34 Debug = debug.Debug; |
| 35 | 35 |
| 36 var name; | 36 var test_name; |
| 37 var listener_delegate; | 37 var listener_delegate; |
| 38 var listener_called; | 38 var listener_called; |
| 39 var exception; | 39 var exception; |
| 40 var begin_test_count = 0; | 40 var begin_test_count = 0; |
| 41 var end_test_count = 0; | 41 var end_test_count = 0; |
| 42 var break_count = 0; | 42 var break_count = 0; |
| 43 | 43 |
| 44 | 44 |
| 45 // Debug event listener which delegates. | 45 // Debug event listener which delegates. |
| 46 function listener(event, exec_state, event_data, data) { | 46 function listener(event, exec_state, event_data, data) { |
| 47 try { | 47 try { |
| 48 if (event == Debug.DebugEvent.Break) { | 48 if (event == Debug.DebugEvent.Break) { |
| 49 break_count++; | 49 break_count++; |
| 50 listener_called = true; | 50 listener_called = true; |
| 51 listener_delegate(exec_state) | 51 listener_delegate(exec_state); |
| 52 } | 52 } |
| 53 } catch (e) { | 53 } catch (e) { |
| 54 exception = e; | 54 exception = e; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Add the debug event listener. | 58 // Add the debug event listener. |
| 59 Debug.setListener(listener); | 59 Debug.setListener(listener); |
| 60 | 60 |
| 61 | 61 |
| 62 // Initialize for a noew test. | 62 // Initialize for a new test. |
| 63 function BeginTest(name) { | 63 function BeginTest(name) { |
| 64 test_name = name; | 64 test_name = name; |
| 65 listener_delegate = null; | 65 listener_delegate = null; |
| 66 listener_called = false; | 66 listener_called = false; |
| 67 exception = null; | 67 exception = null; |
| 68 begin_test_count++; | 68 begin_test_count++; |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 // Check result of a test. | 72 // Check result of a test. |
| 73 function EndTest() { | 73 function EndTest() { |
| 74 assertTrue(listener_called, "listerner not called for " + test_name); | 74 assertTrue(listener_called, "listerner not called for " + test_name); |
| 75 assertNull(exception, test_name) | 75 assertNull(exception, test_name); |
| 76 end_test_count++; | 76 end_test_count++; |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 // Check that the scope chain contains the expected types of scopes. | 80 // Check that the scope chain contains the expected types of scopes. |
| 81 function CheckScopeChain(scopes, exec_state) { | 81 function CheckScopeChain(scopes, exec_state) { |
| 82 assertEquals(scopes.length, exec_state.frame().scopeCount()); | 82 assertEquals(scopes.length, exec_state.frame().scopeCount()); |
| 83 for (var i = 0; i < scopes.length; i++) { | 83 for (var i = 0; i < scopes.length; i++) { |
| 84 var scope = exec_state.frame().scope(i); | 84 var scope = exec_state.frame().scope(i); |
| 85 assertTrue(scope.isScope()); | 85 assertTrue(scope.isScope()); |
| 86 assertEquals(scopes[i], scope.scopeType()); | 86 assertEquals(scopes[i], scope.scopeType()); |
| 87 | 87 |
| 88 // Check the global object when hitting the global scope. | 88 // Check the global object when hitting the global scope. |
| 89 if (scopes[i] == debug.ScopeType.Global) { | 89 if (scopes[i] == debug.ScopeType.Global) { |
| 90 assertEquals(this, scope.scopeObject().value()); | 90 // Objects don't have same class (one is "global", other is "Object", |
| 91 // so just check the properties directly. |
| 92 assertPropertiesEqual(this, scope.scopeObject().value()); |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 | 95 |
| 94 // Get the debug command processor. | 96 // Get the debug command processor. |
| 95 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | 97 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
| 96 | 98 |
| 97 // Send a scopes request and check the result. | 99 // Send a scopes request and check the result. |
| 98 var json; | 100 var json; |
| 99 request_json = '{"seq":0,"type":"request","command":"scopes"}' | 101 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; |
| 100 var response_json = dcp.processDebugJSONRequest(request_json); | 102 var response_json = dcp.processDebugJSONRequest(request_json); |
| 101 var response = JSON.parse(response_json); | 103 var response = JSON.parse(response_json); |
| 102 assertEquals(scopes.length, response.body.scopes.length); | 104 assertEquals(scopes.length, response.body.scopes.length); |
| 103 for (var i = 0; i < scopes.length; i++) { | 105 for (var i = 0; i < scopes.length; i++) { |
| 104 assertEquals(i, response.body.scopes[i].index); | 106 assertEquals(i, response.body.scopes[i].index); |
| 105 assertEquals(scopes[i], response.body.scopes[i].type); | 107 assertEquals(scopes[i], response.body.scopes[i].type); |
| 106 if (scopes[i] == debug.ScopeType.Local || | 108 if (scopes[i] == debug.ScopeType.Local || |
| 107 scopes[i] == debug.ScopeType.Closure) { | 109 scopes[i] == debug.ScopeType.Closure) { |
| 108 assertTrue(response.body.scopes[i].object.ref < 0); | 110 assertTrue(response.body.scopes[i].object.ref < 0); |
| 109 } else { | 111 } else { |
| 110 assertTrue(response.body.scopes[i].object.ref >= 0); | 112 assertTrue(response.body.scopes[i].object.ref >= 0); |
| 111 } | 113 } |
| 112 var found = false; | 114 var found = false; |
| 113 for (var j = 0; j < response.refs.length && !found; j++) { | 115 for (var j = 0; j < response.refs.length && !found; j++) { |
| 114 found = response.refs[j].handle == response.body.scopes[i].object.ref; | 116 found = response.refs[j].handle == response.body.scopes[i].object.ref; |
| 115 } | 117 } |
| 116 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); | 118 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 | 121 |
| 120 | 122 |
| 121 // Check that the content of the scope is as expected. For functions just check | 123 // Check that the content of the scope is as expected. For functions just check |
| 122 // that there is a function. | 124 // that there is a function. |
| 123 function CheckScopeContent(content, number, exec_state) { | 125 function CheckScopeContent(content, number, exec_state) { |
| 124 var scope = exec_state.frame().scope(number) | 126 var scope = exec_state.frame().scope(number); |
| 125 var count = 0; | 127 var count = 0; |
| 126 for (var p in content) { | 128 for (var p in content) { |
| 127 var property_mirror = scope.scopeObject().property(p); | 129 var property_mirror = scope.scopeObject().property(p); |
| 128 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in
scope'); | 130 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in
scope'); |
| 129 if (typeof(content[p]) === 'function') { | 131 if (typeof(content[p]) === 'function') { |
| 130 assertTrue(property_mirror.value().isFunction()); | 132 assertTrue(property_mirror.value().isFunction()); |
| 131 } else { | 133 } else { |
| 132 assertEquals(content[p], property_mirror.value().value(), 'property ' + p
+ ' has unexpected value'); | 134 assertEquals(content[p], property_mirror.value().value(), 'property ' + p
+ ' has unexpected value'); |
| 133 } | 135 } |
| 134 count++; | 136 count++; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 156 print(names[i]); | 158 print(names[i]); |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 assertEquals(count, scope_size); | 161 assertEquals(count, scope_size); |
| 160 | 162 |
| 161 // Get the debug command processor. | 163 // Get the debug command processor. |
| 162 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | 164 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
| 163 | 165 |
| 164 // Send a scope request for information on a single scope and check the | 166 // Send a scope request for information on a single scope and check the |
| 165 // result. | 167 // result. |
| 166 request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"numb
er":' | 168 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"
number":'; |
| 167 request_json += scope.scopeIndex(); | 169 request_json += scope.scopeIndex(); |
| 168 request_json += '}}' | 170 request_json += '}}'; |
| 169 var response_json = dcp.processDebugJSONRequest(request_json); | 171 var response_json = dcp.processDebugJSONRequest(request_json); |
| 170 var response = JSON.parse(response_json); | 172 var response = JSON.parse(response_json); |
| 171 assertEquals(scope.scopeType(), response.body.type); | 173 assertEquals(scope.scopeType(), response.body.type); |
| 172 assertEquals(number, response.body.index); | 174 assertEquals(number, response.body.index); |
| 173 if (scope.scopeType() == debug.ScopeType.Local || | 175 if (scope.scopeType() == debug.ScopeType.Local || |
| 174 scope.scopeType() == debug.ScopeType.Closure) { | 176 scope.scopeType() == debug.ScopeType.Closure) { |
| 175 assertTrue(response.body.object.ref < 0); | 177 assertTrue(response.body.object.ref < 0); |
| 176 } else { | 178 } else { |
| 177 assertTrue(response.body.object.ref >= 0); | 179 assertTrue(response.body.object.ref >= 0); |
| 178 } | 180 } |
| 179 var found = false; | 181 var found = false; |
| 180 for (var i = 0; i < response.refs.length && !found; i++) { | 182 for (var i = 0; i < response.refs.length && !found; i++) { |
| 181 found = response.refs[i].handle == response.body.object.ref; | 183 found = response.refs[i].handle == response.body.object.ref; |
| 182 } | 184 } |
| 183 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); | 185 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); |
| 184 } | 186 } |
| 185 | 187 |
| 186 | 188 |
| 187 // Simple empty local scope. | 189 // Simple empty local scope. |
| 188 BeginTest("Local 1"); | 190 BeginTest("Local 1"); |
| 189 | 191 |
| 190 function local_1() { | 192 function local_1() { |
| 191 debugger; | 193 debugger; |
| 192 } | 194 } |
| 193 | 195 |
| 194 listener_delegate = function(exec_state) { | 196 listener_delegate = function(exec_state) { |
| 195 CheckScopeChain([debug.ScopeType.Local, | 197 CheckScopeChain([debug.ScopeType.Local, |
| 196 debug.ScopeType.Global], exec_state); | 198 debug.ScopeType.Global], exec_state); |
| 197 CheckScopeContent({}, 0, exec_state); | 199 CheckScopeContent({}, 0, exec_state); |
| 198 } | 200 }; |
| 199 local_1() | 201 local_1(); |
| 200 EndTest(); | 202 EndTest(); |
| 201 | 203 |
| 202 | 204 |
| 203 // Local scope with a parameter. | 205 // Local scope with a parameter. |
| 204 BeginTest("Local 2"); | 206 BeginTest("Local 2"); |
| 205 | 207 |
| 206 function local_2(a) { | 208 function local_2(a) { |
| 207 debugger; | 209 debugger; |
| 208 } | 210 } |
| 209 | 211 |
| 210 listener_delegate = function(exec_state) { | 212 listener_delegate = function(exec_state) { |
| 211 CheckScopeChain([debug.ScopeType.Local, | 213 CheckScopeChain([debug.ScopeType.Local, |
| 212 debug.ScopeType.Global], exec_state); | 214 debug.ScopeType.Global], exec_state); |
| 213 CheckScopeContent({a:1}, 0, exec_state); | 215 CheckScopeContent({a:1}, 0, exec_state); |
| 214 } | 216 }; |
| 215 local_2(1) | 217 local_2(1); |
| 216 EndTest(); | 218 EndTest(); |
| 217 | 219 |
| 218 | 220 |
| 219 // Local scope with a parameter and a local variable. | 221 // Local scope with a parameter and a local variable. |
| 220 BeginTest("Local 3"); | 222 BeginTest("Local 3"); |
| 221 | 223 |
| 222 function local_3(a) { | 224 function local_3(a) { |
| 223 var x = 3; | 225 var x = 3; |
| 224 debugger; | 226 debugger; |
| 225 } | 227 } |
| 226 | 228 |
| 227 listener_delegate = function(exec_state) { | 229 listener_delegate = function(exec_state) { |
| 228 CheckScopeChain([debug.ScopeType.Local, | 230 CheckScopeChain([debug.ScopeType.Local, |
| 229 debug.ScopeType.Global], exec_state); | 231 debug.ScopeType.Global], exec_state); |
| 230 CheckScopeContent({a:1,x:3}, 0, exec_state); | 232 CheckScopeContent({a:1,x:3}, 0, exec_state); |
| 231 } | 233 }; |
| 232 local_3(1) | 234 local_3(1); |
| 233 EndTest(); | 235 EndTest(); |
| 234 | 236 |
| 235 | 237 |
| 236 // Local scope with parameters and local variables. | 238 // Local scope with parameters and local variables. |
| 237 BeginTest("Local 4"); | 239 BeginTest("Local 4"); |
| 238 | 240 |
| 239 function local_4(a, b) { | 241 function local_4(a, b) { |
| 240 var x = 3; | 242 var x = 3; |
| 241 var y = 4; | 243 var y = 4; |
| 242 debugger; | 244 debugger; |
| 243 } | 245 } |
| 244 | 246 |
| 245 listener_delegate = function(exec_state) { | 247 listener_delegate = function(exec_state) { |
| 246 CheckScopeChain([debug.ScopeType.Local, | 248 CheckScopeChain([debug.ScopeType.Local, |
| 247 debug.ScopeType.Global], exec_state); | 249 debug.ScopeType.Global], exec_state); |
| 248 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); | 250 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); |
| 249 } | 251 }; |
| 250 local_4(1, 2) | 252 local_4(1, 2); |
| 251 EndTest(); | 253 EndTest(); |
| 252 | 254 |
| 253 | 255 |
| 254 // Empty local scope with use of eval. | 256 // Empty local scope with use of eval. |
| 255 BeginTest("Local 5"); | 257 BeginTest("Local 5"); |
| 256 | 258 |
| 257 function local_5() { | 259 function local_5() { |
| 258 eval(''); | 260 eval(''); |
| 259 debugger; | 261 debugger; |
| 260 } | 262 } |
| 261 | 263 |
| 262 listener_delegate = function(exec_state) { | 264 listener_delegate = function(exec_state) { |
| 263 CheckScopeChain([debug.ScopeType.Local, | 265 CheckScopeChain([debug.ScopeType.Local, |
| 264 debug.ScopeType.Global], exec_state); | 266 debug.ScopeType.Global], exec_state); |
| 265 CheckScopeContent({}, 0, exec_state); | 267 CheckScopeContent({}, 0, exec_state); |
| 266 } | 268 }; |
| 267 local_5() | 269 local_5(); |
| 268 EndTest(); | 270 EndTest(); |
| 269 | 271 |
| 270 | 272 |
| 271 // Local introducing local variable using eval. | 273 // Local introducing local variable using eval. |
| 272 BeginTest("Local 6"); | 274 BeginTest("Local 6"); |
| 273 | 275 |
| 274 function local_6() { | 276 function local_6() { |
| 275 eval('var i = 5'); | 277 eval('var i = 5'); |
| 276 debugger; | 278 debugger; |
| 277 } | 279 } |
| 278 | 280 |
| 279 listener_delegate = function(exec_state) { | 281 listener_delegate = function(exec_state) { |
| 280 CheckScopeChain([debug.ScopeType.Local, | 282 CheckScopeChain([debug.ScopeType.Local, |
| 281 debug.ScopeType.Global], exec_state); | 283 debug.ScopeType.Global], exec_state); |
| 282 CheckScopeContent({i:5}, 0, exec_state); | 284 CheckScopeContent({i:5}, 0, exec_state); |
| 283 } | 285 }; |
| 284 local_6() | 286 local_6(); |
| 285 EndTest(); | 287 EndTest(); |
| 286 | 288 |
| 287 | 289 |
| 288 // Local scope with parameters, local variables and local variable introduced | 290 // Local scope with parameters, local variables and local variable introduced |
| 289 // using eval. | 291 // using eval. |
| 290 BeginTest("Local 7"); | 292 BeginTest("Local 7"); |
| 291 | 293 |
| 292 function local_7(a, b) { | 294 function local_7(a, b) { |
| 293 var x = 3; | 295 var x = 3; |
| 294 var y = 4; | 296 var y = 4; |
| 295 eval('var i = 5'); | 297 eval('var i = 5'); |
| 296 eval('var j = 6'); | 298 eval('var j = 6'); |
| 297 debugger; | 299 debugger; |
| 298 } | 300 } |
| 299 | 301 |
| 300 listener_delegate = function(exec_state) { | 302 listener_delegate = function(exec_state) { |
| 301 CheckScopeChain([debug.ScopeType.Local, | 303 CheckScopeChain([debug.ScopeType.Local, |
| 302 debug.ScopeType.Global], exec_state); | 304 debug.ScopeType.Global], exec_state); |
| 303 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state); | 305 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state); |
| 304 } | 306 }; |
| 305 local_7(1, 2) | 307 local_7(1, 2); |
| 306 EndTest(); | 308 EndTest(); |
| 307 | 309 |
| 308 | 310 |
| 309 // Single empty with block. | 311 // Single empty with block. |
| 310 BeginTest("With 1"); | 312 BeginTest("With 1"); |
| 311 | 313 |
| 312 function with_1() { | 314 function with_1() { |
| 313 with({}) { | 315 with({}) { |
| 314 debugger; | 316 debugger; |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 | 319 |
| 318 listener_delegate = function(exec_state) { | 320 listener_delegate = function(exec_state) { |
| 319 CheckScopeChain([debug.ScopeType.With, | 321 CheckScopeChain([debug.ScopeType.With, |
| 320 debug.ScopeType.Local, | 322 debug.ScopeType.Local, |
| 321 debug.ScopeType.Global], exec_state); | 323 debug.ScopeType.Global], exec_state); |
| 322 CheckScopeContent({}, 0, exec_state); | 324 CheckScopeContent({}, 0, exec_state); |
| 323 } | 325 }; |
| 324 with_1() | 326 with_1(); |
| 325 EndTest(); | 327 EndTest(); |
| 326 | 328 |
| 327 | 329 |
| 328 // Nested empty with blocks. | 330 // Nested empty with blocks. |
| 329 BeginTest("With 2"); | 331 BeginTest("With 2"); |
| 330 | 332 |
| 331 function with_2() { | 333 function with_2() { |
| 332 with({}) { | 334 with({}) { |
| 333 with({}) { | 335 with({}) { |
| 334 debugger; | 336 debugger; |
| 335 } | 337 } |
| 336 } | 338 } |
| 337 } | 339 } |
| 338 | 340 |
| 339 listener_delegate = function(exec_state) { | 341 listener_delegate = function(exec_state) { |
| 340 CheckScopeChain([debug.ScopeType.With, | 342 CheckScopeChain([debug.ScopeType.With, |
| 341 debug.ScopeType.With, | 343 debug.ScopeType.With, |
| 342 debug.ScopeType.Local, | 344 debug.ScopeType.Local, |
| 343 debug.ScopeType.Global], exec_state); | 345 debug.ScopeType.Global], exec_state); |
| 344 CheckScopeContent({}, 0, exec_state); | 346 CheckScopeContent({}, 0, exec_state); |
| 345 CheckScopeContent({}, 1, exec_state); | 347 CheckScopeContent({}, 1, exec_state); |
| 346 } | 348 }; |
| 347 with_2() | 349 with_2(); |
| 348 EndTest(); | 350 EndTest(); |
| 349 | 351 |
| 350 | 352 |
| 351 // With block using an in-place object literal. | 353 // With block using an in-place object literal. |
| 352 BeginTest("With 3"); | 354 BeginTest("With 3"); |
| 353 | 355 |
| 354 function with_3() { | 356 function with_3() { |
| 355 with({a:1,b:2}) { | 357 with({a:1,b:2}) { |
| 356 debugger; | 358 debugger; |
| 357 } | 359 } |
| 358 } | 360 } |
| 359 | 361 |
| 360 listener_delegate = function(exec_state) { | 362 listener_delegate = function(exec_state) { |
| 361 CheckScopeChain([debug.ScopeType.With, | 363 CheckScopeChain([debug.ScopeType.With, |
| 362 debug.ScopeType.Local, | 364 debug.ScopeType.Local, |
| 363 debug.ScopeType.Global], exec_state); | 365 debug.ScopeType.Global], exec_state); |
| 364 CheckScopeContent({a:1,b:2}, 0, exec_state); | 366 CheckScopeContent({a:1,b:2}, 0, exec_state); |
| 365 } | 367 }; |
| 366 with_3() | 368 with_3(); |
| 367 EndTest(); | 369 EndTest(); |
| 368 | 370 |
| 369 | 371 |
| 370 // Nested with blocks using in-place object literals. | 372 // Nested with blocks using in-place object literals. |
| 371 BeginTest("With 4"); | 373 BeginTest("With 4"); |
| 372 | 374 |
| 373 function with_4() { | 375 function with_4() { |
| 374 with({a:1,b:2}) { | 376 with({a:1,b:2}) { |
| 375 with({a:2,b:1}) { | 377 with({a:2,b:1}) { |
| 376 debugger; | 378 debugger; |
| 377 } | 379 } |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 | 382 |
| 381 listener_delegate = function(exec_state) { | 383 listener_delegate = function(exec_state) { |
| 382 CheckScopeChain([debug.ScopeType.With, | 384 CheckScopeChain([debug.ScopeType.With, |
| 383 debug.ScopeType.With, | 385 debug.ScopeType.With, |
| 384 debug.ScopeType.Local, | 386 debug.ScopeType.Local, |
| 385 debug.ScopeType.Global], exec_state); | 387 debug.ScopeType.Global], exec_state); |
| 386 CheckScopeContent({a:2,b:1}, 0, exec_state); | 388 CheckScopeContent({a:2,b:1}, 0, exec_state); |
| 387 CheckScopeContent({a:1,b:2}, 1, exec_state); | 389 CheckScopeContent({a:1,b:2}, 1, exec_state); |
| 388 } | 390 }; |
| 389 with_4() | 391 with_4(); |
| 390 EndTest(); | 392 EndTest(); |
| 391 | 393 |
| 392 | 394 |
| 393 // Nested with blocks using existing object. | 395 // Nested with blocks using existing object. |
| 394 BeginTest("With 5"); | 396 BeginTest("With 5"); |
| 395 | 397 |
| 396 var with_object = {c:3,d:4}; | 398 var with_object = {c:3,d:4}; |
| 397 function with_5() { | 399 function with_5() { |
| 398 with(with_object) { | 400 with(with_object) { |
| 399 with(with_object) { | 401 with(with_object) { |
| 400 debugger; | 402 debugger; |
| 401 } | 403 } |
| 402 } | 404 } |
| 403 } | 405 } |
| 404 | 406 |
| 405 listener_delegate = function(exec_state) { | 407 listener_delegate = function(exec_state) { |
| 406 CheckScopeChain([debug.ScopeType.With, | 408 CheckScopeChain([debug.ScopeType.With, |
| 407 debug.ScopeType.With, | 409 debug.ScopeType.With, |
| 408 debug.ScopeType.Local, | 410 debug.ScopeType.Local, |
| 409 debug.ScopeType.Global], exec_state); | 411 debug.ScopeType.Global], exec_state); |
| 410 CheckScopeContent(with_object, 0, exec_state); | 412 CheckScopeContent(with_object, 0, exec_state); |
| 411 CheckScopeContent(with_object, 1, exec_state); | 413 CheckScopeContent(with_object, 1, exec_state); |
| 412 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); | 414 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); |
| 413 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 415 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 414 } | 416 }; |
| 415 with_5() | 417 with_5(); |
| 416 EndTest(); | 418 EndTest(); |
| 417 | 419 |
| 418 | 420 |
| 419 // Simple closure formed by returning an inner function referering the outer | 421 // Simple closure formed by returning an inner function referering the outer |
| 420 // functions arguments. | 422 // functions arguments. |
| 421 BeginTest("Closure 1"); | 423 BeginTest("Closure 1"); |
| 422 | 424 |
| 423 function closure_1(a) { | 425 function closure_1(a) { |
| 424 function f() { | 426 function f() { |
| 425 debugger; | 427 debugger; |
| 426 return a; | 428 return a; |
| 427 }; | 429 }; |
| 428 return f; | 430 return f; |
| 429 } | 431 } |
| 430 | 432 |
| 431 listener_delegate = function(exec_state) { | 433 listener_delegate = function(exec_state) { |
| 432 CheckScopeChain([debug.ScopeType.Local, | 434 CheckScopeChain([debug.ScopeType.Local, |
| 433 debug.ScopeType.Closure, | 435 debug.ScopeType.Closure, |
| 434 debug.ScopeType.Global], exec_state); | 436 debug.ScopeType.Global], exec_state); |
| 435 CheckScopeContent({a:1}, 1, exec_state); | 437 CheckScopeContent({a:1}, 1, exec_state); |
| 436 } | 438 }; |
| 437 closure_1(1)() | 439 closure_1(1)(); |
| 438 EndTest(); | 440 EndTest(); |
| 439 | 441 |
| 440 | 442 |
| 441 // Simple closure formed by returning an inner function referering the outer | 443 // Simple closure formed by returning an inner function referering the outer |
| 442 // functions arguments. Due to VM optimizations parts of the actual closure is | 444 // functions arguments. Due to VM optimizations parts of the actual closure is |
| 443 // missing from the debugger information. | 445 // missing from the debugger information. |
| 444 BeginTest("Closure 2"); | 446 BeginTest("Closure 2"); |
| 445 | 447 |
| 446 function closure_2(a, b) { | 448 function closure_2(a, b) { |
| 447 var x = a + 2; | 449 var x = a + 2; |
| 448 var y = b + 2; | 450 var y = b + 2; |
| 449 function f() { | 451 function f() { |
| 450 debugger; | 452 debugger; |
| 451 return a + x; | 453 return a + x; |
| 452 }; | 454 }; |
| 453 return f; | 455 return f; |
| 454 } | 456 } |
| 455 | 457 |
| 456 listener_delegate = function(exec_state) { | 458 listener_delegate = function(exec_state) { |
| 457 CheckScopeChain([debug.ScopeType.Local, | 459 CheckScopeChain([debug.ScopeType.Local, |
| 458 debug.ScopeType.Closure, | 460 debug.ScopeType.Closure, |
| 459 debug.ScopeType.Global], exec_state); | 461 debug.ScopeType.Global], exec_state); |
| 460 CheckScopeContent({a:1,x:3}, 1, exec_state); | 462 CheckScopeContent({a:1,x:3}, 1, exec_state); |
| 461 } | 463 }; |
| 462 closure_2(1, 2)() | 464 closure_2(1, 2)(); |
| 463 EndTest(); | 465 EndTest(); |
| 464 | 466 |
| 465 | 467 |
| 466 // Simple closure formed by returning an inner function referering the outer | 468 // Simple closure formed by returning an inner function referering the outer |
| 467 // functions arguments. Using all arguments and locals from the outer function | 469 // functions arguments. Using all arguments and locals from the outer function |
| 468 // in the inner function makes these part of the debugger information on the | 470 // in the inner function makes these part of the debugger information on the |
| 469 // closure. | 471 // closure. |
| 470 BeginTest("Closure 3"); | 472 BeginTest("Closure 3"); |
| 471 | 473 |
| 472 function closure_3(a, b) { | 474 function closure_3(a, b) { |
| 473 var x = a + 2; | 475 var x = a + 2; |
| 474 var y = b + 2; | 476 var y = b + 2; |
| 475 function f() { | 477 function f() { |
| 476 debugger; | 478 debugger; |
| 477 return a + b + x + y; | 479 return a + b + x + y; |
| 478 }; | 480 }; |
| 479 return f; | 481 return f; |
| 480 } | 482 } |
| 481 | 483 |
| 482 listener_delegate = function(exec_state) { | 484 listener_delegate = function(exec_state) { |
| 483 CheckScopeChain([debug.ScopeType.Local, | 485 CheckScopeChain([debug.ScopeType.Local, |
| 484 debug.ScopeType.Closure, | 486 debug.ScopeType.Closure, |
| 485 debug.ScopeType.Global], exec_state); | 487 debug.ScopeType.Global], exec_state); |
| 486 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); | 488 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); |
| 487 } | 489 }; |
| 488 closure_3(1, 2)() | 490 closure_3(1, 2)(); |
| 489 EndTest(); | 491 EndTest(); |
| 490 | 492 |
| 491 | 493 |
| 492 | 494 |
| 493 // Simple closure formed by returning an inner function referering the outer | 495 // Simple closure formed by returning an inner function referering the outer |
| 494 // functions arguments. Using all arguments and locals from the outer function | 496 // functions arguments. Using all arguments and locals from the outer function |
| 495 // in the inner function makes these part of the debugger information on the | 497 // in the inner function makes these part of the debugger information on the |
| 496 // closure. Use the inner function as well... | 498 // closure. Use the inner function as well... |
| 497 BeginTest("Closure 4"); | 499 BeginTest("Closure 4"); |
| 498 | 500 |
| 499 function closure_4(a, b) { | 501 function closure_4(a, b) { |
| 500 var x = a + 2; | 502 var x = a + 2; |
| 501 var y = b + 2; | 503 var y = b + 2; |
| 502 function f() { | 504 function f() { |
| 503 debugger; | 505 debugger; |
| 504 if (f) { | 506 if (f) { |
| 505 return a + b + x + y; | 507 return a + b + x + y; |
| 506 } | 508 } |
| 507 }; | 509 }; |
| 508 return f; | 510 return f; |
| 509 } | 511 } |
| 510 | 512 |
| 511 listener_delegate = function(exec_state) { | 513 listener_delegate = function(exec_state) { |
| 512 CheckScopeChain([debug.ScopeType.Local, | 514 CheckScopeChain([debug.ScopeType.Local, |
| 513 debug.ScopeType.Closure, | 515 debug.ScopeType.Closure, |
| 514 debug.ScopeType.Global], exec_state); | 516 debug.ScopeType.Global], exec_state); |
| 515 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 517 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 516 } | 518 }; |
| 517 closure_4(1, 2)() | 519 closure_4(1, 2)(); |
| 518 EndTest(); | 520 EndTest(); |
| 519 | 521 |
| 520 | 522 |
| 521 | 523 |
| 522 // Simple closure formed by returning an inner function referering the outer | 524 // Simple closure formed by returning an inner function referering the outer |
| 523 // functions arguments. In the presence of eval all arguments and locals | 525 // functions arguments. In the presence of eval all arguments and locals |
| 524 // (including the inner function itself) from the outer function becomes part of | 526 // (including the inner function itself) from the outer function becomes part of |
| 525 // the debugger infformation on the closure. | 527 // the debugger infformation on the closure. |
| 526 BeginTest("Closure 5"); | 528 BeginTest("Closure 5"); |
| 527 | 529 |
| 528 function closure_5(a, b) { | 530 function closure_5(a, b) { |
| 529 var x = 3; | 531 var x = 3; |
| 530 var y = 4; | 532 var y = 4; |
| 531 function f() { | 533 function f() { |
| 532 eval(''); | 534 eval(''); |
| 533 debugger; | 535 debugger; |
| 534 return 1; | 536 return 1; |
| 535 }; | 537 }; |
| 536 return f; | 538 return f; |
| 537 } | 539 } |
| 538 | 540 |
| 539 listener_delegate = function(exec_state) { | 541 listener_delegate = function(exec_state) { |
| 540 CheckScopeChain([debug.ScopeType.Local, | 542 CheckScopeChain([debug.ScopeType.Local, |
| 541 debug.ScopeType.Closure, | 543 debug.ScopeType.Closure, |
| 542 debug.ScopeType.Global], exec_state); | 544 debug.ScopeType.Global], exec_state); |
| 543 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 545 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 544 } | 546 }; |
| 545 closure_5(1, 2)() | 547 closure_5(1, 2)(); |
| 546 EndTest(); | 548 EndTest(); |
| 547 | 549 |
| 548 | 550 |
| 549 // Two closures. Due to optimizations only the parts actually used are provided | 551 // Two closures. Due to optimizations only the parts actually used are provided |
| 550 // through the debugger information. | 552 // through the debugger information. |
| 551 BeginTest("Closure 6"); | 553 BeginTest("Closure 6"); |
| 552 function closure_6(a, b) { | 554 function closure_6(a, b) { |
| 553 function f(a, b) { | 555 function f(a, b) { |
| 554 var x = 3; | 556 var x = 3; |
| 555 var y = 4; | 557 var y = 4; |
| 556 return function() { | 558 return function() { |
| 557 var x = 3; | 559 var x = 3; |
| 558 var y = 4; | 560 var y = 4; |
| 559 debugger; | 561 debugger; |
| 560 some_global = a; | 562 some_global = a; |
| 561 return f; | 563 return f; |
| 562 } | 564 }; |
| 563 } | 565 } |
| 564 return f(a, b); | 566 return f(a, b); |
| 565 } | 567 } |
| 566 | 568 |
| 567 listener_delegate = function(exec_state) { | 569 listener_delegate = function(exec_state) { |
| 568 CheckScopeChain([debug.ScopeType.Local, | 570 CheckScopeChain([debug.ScopeType.Local, |
| 569 debug.ScopeType.Closure, | 571 debug.ScopeType.Closure, |
| 570 debug.ScopeType.Closure, | 572 debug.ScopeType.Closure, |
| 571 debug.ScopeType.Global], exec_state); | 573 debug.ScopeType.Global], exec_state); |
| 572 CheckScopeContent({a:1}, 1, exec_state); | 574 CheckScopeContent({a:1}, 1, exec_state); |
| 573 CheckScopeContent({f:function(){}}, 2, exec_state); | 575 CheckScopeContent({f:function(){}}, 2, exec_state); |
| 574 } | 576 }; |
| 575 closure_6(1, 2)() | 577 closure_6(1, 2)(); |
| 576 EndTest(); | 578 EndTest(); |
| 577 | 579 |
| 578 | 580 |
| 579 // Two closures. In the presence of eval all information is provided as the | 581 // Two closures. In the presence of eval all information is provided as the |
| 580 // compiler cannot determine which parts are used. | 582 // compiler cannot determine which parts are used. |
| 581 BeginTest("Closure 7"); | 583 BeginTest("Closure 7"); |
| 582 function closure_7(a, b) { | 584 function closure_7(a, b) { |
| 583 var x = 3; | 585 var x = 3; |
| 584 var y = 4; | 586 var y = 4; |
| 585 eval('var i = 5'); | 587 eval('var i = 5'); |
| 586 eval('var j = 6'); | 588 eval('var j = 6'); |
| 587 function f(a, b) { | 589 function f(a, b) { |
| 588 var x = 3; | 590 var x = 3; |
| 589 var y = 4; | 591 var y = 4; |
| 590 eval('var i = 5'); | 592 eval('var i = 5'); |
| 591 eval('var j = 6'); | 593 eval('var j = 6'); |
| 592 return function() { | 594 return function() { |
| 593 debugger; | 595 debugger; |
| 594 some_global = a; | 596 some_global = a; |
| 595 return f; | 597 return f; |
| 596 } | 598 }; |
| 597 } | 599 } |
| 598 return f(a, b); | 600 return f(a, b); |
| 599 } | 601 } |
| 600 | 602 |
| 601 listener_delegate = function(exec_state) { | 603 listener_delegate = function(exec_state) { |
| 602 CheckScopeChain([debug.ScopeType.Local, | 604 CheckScopeChain([debug.ScopeType.Local, |
| 603 debug.ScopeType.Closure, | 605 debug.ScopeType.Closure, |
| 604 debug.ScopeType.Closure, | 606 debug.ScopeType.Closure, |
| 605 debug.ScopeType.Global], exec_state); | 607 debug.ScopeType.Global], exec_state); |
| 606 CheckScopeContent({}, 0, exec_state); | 608 CheckScopeContent({}, 0, exec_state); |
| 607 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); | 609 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); |
| 608 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); | 610 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); |
| 609 } | 611 }; |
| 610 closure_7(1, 2)() | 612 closure_7(1, 2)(); |
| 611 EndTest(); | 613 EndTest(); |
| 612 | 614 |
| 613 | 615 |
| 614 // Closure that may be optimized out. | 616 // Closure that may be optimized out. |
| 615 BeginTest("Closure 8"); | 617 BeginTest("Closure 8"); |
| 616 function closure_8() { | 618 function closure_8() { |
| 617 (function inner(x) { | 619 (function inner(x) { |
| 618 debugger; | 620 debugger; |
| 619 })(2); | 621 })(2); |
| 620 } | 622 } |
| 621 | 623 |
| 622 listener_delegate = function(exec_state) { | 624 listener_delegate = function(exec_state) { |
| 623 CheckScopeChain([debug.ScopeType.Local, | 625 CheckScopeChain([debug.ScopeType.Local, |
| 624 debug.ScopeType.Global], exec_state); | 626 debug.ScopeType.Global], exec_state); |
| 625 CheckScopeContent({x: 2}, 0, exec_state); | 627 CheckScopeContent({x: 2}, 0, exec_state); |
| 626 } | 628 }; |
| 627 closure_8(); | 629 closure_8(); |
| 628 EndTest(); | 630 EndTest(); |
| 629 | 631 |
| 630 | 632 |
| 631 BeginTest("Closure 9"); | 633 BeginTest("Closure 9"); |
| 632 function closure_9() { | 634 function closure_9() { |
| 633 eval("var y = 1;"); | 635 eval("var y = 1;"); |
| 634 eval("var z = 1;"); | 636 eval("var z = 1;"); |
| 635 (function inner(x) { | 637 (function inner(x) { |
| 636 y++; | 638 y++; |
| 637 z++; | 639 z++; |
| 638 debugger; | 640 debugger; |
| 639 })(2); | 641 })(2); |
| 640 } | 642 } |
| 641 | 643 |
| 642 listener_delegate = function(exec_state) { | 644 listener_delegate = function(exec_state) { |
| 643 CheckScopeChain([debug.ScopeType.Local, | 645 CheckScopeChain([debug.ScopeType.Local, |
| 644 debug.ScopeType.Closure, | 646 debug.ScopeType.Closure, |
| 645 debug.ScopeType.Global], exec_state); | 647 debug.ScopeType.Global], exec_state); |
| 646 } | 648 }; |
| 647 closure_9(); | 649 closure_9(); |
| 648 EndTest(); | 650 EndTest(); |
| 649 | 651 |
| 650 | 652 |
| 651 // Test a mixture of scopes. | 653 // Test a mixture of scopes. |
| 652 BeginTest("The full monty"); | 654 BeginTest("The full monty"); |
| 653 function the_full_monty(a, b) { | 655 function the_full_monty(a, b) { |
| 654 var x = 3; | 656 var x = 3; |
| 655 var y = 4; | 657 var y = 4; |
| 656 eval('var i = 5'); | 658 eval('var i = 5'); |
| 657 eval('var j = 6'); | 659 eval('var j = 6'); |
| 658 function f(a, b) { | 660 function f(a, b) { |
| 659 var x = 9; | 661 var x = 9; |
| 660 var y = 10; | 662 var y = 10; |
| 661 eval('var i = 11'); | 663 eval('var i = 11'); |
| 662 eval('var j = 12'); | 664 eval('var j = 12'); |
| 663 with ({j:13}){ | 665 with ({j:13}){ |
| 664 return function() { | 666 return function() { |
| 665 var x = 14; | 667 var x = 14; |
| 666 with ({a:15}) { | 668 with ({a:15}) { |
| 667 with ({b:16}) { | 669 with ({b:16}) { |
| 668 debugger; | 670 debugger; |
| 669 some_global = a; | 671 some_global = a; |
| 670 return f; | 672 return f; |
| 671 } | 673 } |
| 672 } | 674 } |
| 673 } | 675 }; |
| 674 } | 676 } |
| 675 } | 677 } |
| 676 return f(a, b); | 678 return f(a, b); |
| 677 } | 679 } |
| 678 | 680 |
| 679 listener_delegate = function(exec_state) { | 681 listener_delegate = function(exec_state) { |
| 680 CheckScopeChain([debug.ScopeType.With, | 682 CheckScopeChain([debug.ScopeType.With, |
| 681 debug.ScopeType.With, | 683 debug.ScopeType.With, |
| 682 debug.ScopeType.Local, | 684 debug.ScopeType.Local, |
| 683 debug.ScopeType.With, | 685 debug.ScopeType.With, |
| 684 debug.ScopeType.Closure, | 686 debug.ScopeType.Closure, |
| 685 debug.ScopeType.Closure, | 687 debug.ScopeType.Closure, |
| 686 debug.ScopeType.Global], exec_state); | 688 debug.ScopeType.Global], exec_state); |
| 687 CheckScopeContent({b:16}, 0, exec_state); | 689 CheckScopeContent({b:16}, 0, exec_state); |
| 688 CheckScopeContent({a:15}, 1, exec_state); | 690 CheckScopeContent({a:15}, 1, exec_state); |
| 689 CheckScopeContent({x:14}, 2, exec_state); | 691 CheckScopeContent({x:14}, 2, exec_state); |
| 690 CheckScopeContent({j:13}, 3, exec_state); | 692 CheckScopeContent({j:13}, 3, exec_state); |
| 691 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); | 693 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); |
| 692 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); | 694 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); |
| 693 } | 695 }; |
| 694 the_full_monty(1, 2)() | 696 the_full_monty(1, 2)(); |
| 695 EndTest(); | 697 EndTest(); |
| 696 | 698 |
| 697 | 699 |
| 698 BeginTest("Closure inside With 1"); | 700 BeginTest("Closure inside With 1"); |
| 699 function closure_in_with_1() { | 701 function closure_in_with_1() { |
| 700 with({x:1}) { | 702 with({x:1}) { |
| 701 (function inner(x) { | 703 (function inner(x) { |
| 702 debugger; | 704 debugger; |
| 703 })(2); | 705 })(2); |
| 704 } | 706 } |
| 705 } | 707 } |
| 706 | 708 |
| 707 listener_delegate = function(exec_state) { | 709 listener_delegate = function(exec_state) { |
| 708 CheckScopeChain([debug.ScopeType.Local, | 710 CheckScopeChain([debug.ScopeType.Local, |
| 709 debug.ScopeType.With, | 711 debug.ScopeType.With, |
| 710 debug.ScopeType.Closure, | 712 debug.ScopeType.Closure, |
| 711 debug.ScopeType.Global], exec_state); | 713 debug.ScopeType.Global], exec_state); |
| 712 CheckScopeContent({x: 2}, 0, exec_state); | 714 CheckScopeContent({x: 2}, 0, exec_state); |
| 713 } | 715 }; |
| 714 closure_in_with_1(); | 716 closure_in_with_1(); |
| 715 EndTest(); | 717 EndTest(); |
| 716 | 718 |
| 717 | 719 |
| 718 BeginTest("Closure inside With 2"); | 720 BeginTest("Closure inside With 2"); |
| 719 function closure_in_with_2() { | 721 function closure_in_with_2() { |
| 720 with({x:1}) { | 722 with({x:1}) { |
| 721 (function inner(x) { | 723 (function inner(x) { |
| 722 with({x:3}) { | 724 with({x:3}) { |
| 723 debugger; | 725 debugger; |
| 724 } | 726 } |
| 725 })(2); | 727 })(2); |
| 726 } | 728 } |
| 727 } | 729 } |
| 728 | 730 |
| 729 listener_delegate = function(exec_state) { | 731 listener_delegate = function(exec_state) { |
| 730 CheckScopeChain([debug.ScopeType.With, | 732 CheckScopeChain([debug.ScopeType.With, |
| 731 debug.ScopeType.Local, | 733 debug.ScopeType.Local, |
| 732 debug.ScopeType.With, | 734 debug.ScopeType.With, |
| 733 debug.ScopeType.Closure, | 735 debug.ScopeType.Closure, |
| 734 debug.ScopeType.Global], exec_state); | 736 debug.ScopeType.Global], exec_state); |
| 735 CheckScopeContent({x: 3}, 0, exec_state); | 737 CheckScopeContent({x: 3}, 0, exec_state); |
| 736 CheckScopeContent({x: 2}, 1, exec_state); | 738 CheckScopeContent({x: 2}, 1, exec_state); |
| 737 CheckScopeContent({x: 1}, 2, exec_state); | 739 CheckScopeContent({x: 1}, 2, exec_state); |
| 738 } | 740 }; |
| 739 closure_in_with_2(); | 741 closure_in_with_2(); |
| 740 EndTest(); | 742 EndTest(); |
| 741 | 743 |
| 742 | 744 |
| 743 BeginTest("Closure inside With 3"); | 745 BeginTest("Closure inside With 3"); |
| 744 function createClosure(a) { | 746 function createClosure(a) { |
| 745 var b = a + 1; | 747 var b = a + 1; |
| 746 return function closure() { | 748 return function closure() { |
| 747 var c = b; | 749 var c = b; |
| 748 (function inner(x) { | 750 (function inner(x) { |
| 749 with({x:c}) { | 751 with({x:c}) { |
| 750 debugger; | 752 debugger; |
| 751 } | 753 } |
| 752 })(2); | 754 })(2); |
| 753 } | 755 }; |
| 754 } | 756 } |
| 755 | 757 |
| 756 function closure_in_with_3() { | 758 function closure_in_with_3() { |
| 757 var f = createClosure(0); | 759 var f = createClosure(0); |
| 758 f(); | 760 f(); |
| 759 } | 761 } |
| 760 | 762 |
| 761 listener_delegate = function(exec_state) { | 763 listener_delegate = function(exec_state) { |
| 762 CheckScopeChain([debug.ScopeType.With, | 764 CheckScopeChain([debug.ScopeType.With, |
| 763 debug.ScopeType.Local, | 765 debug.ScopeType.Local, |
| 764 debug.ScopeType.Closure, | 766 debug.ScopeType.Closure, |
| 765 debug.ScopeType.Closure, | 767 debug.ScopeType.Closure, |
| 766 debug.ScopeType.Global], exec_state); | 768 debug.ScopeType.Global], exec_state); |
| 767 } | 769 } |
| 768 closure_in_with_3(); | 770 closure_in_with_3(); |
| 769 EndTest(); | 771 EndTest(); |
| 770 | 772 |
| 771 | 773 |
| 772 // Test global scope. | 774 // Test global scope. |
| 773 BeginTest("Global"); | 775 BeginTest("Global"); |
| 774 listener_delegate = function(exec_state) { | 776 listener_delegate = function(exec_state) { |
| 775 CheckScopeChain([debug.ScopeType.Global], exec_state); | 777 CheckScopeChain([debug.ScopeType.Global], exec_state); |
| 776 } | 778 }; |
| 777 debugger; | 779 debugger; |
| 778 EndTest(); | 780 EndTest(); |
| 779 | 781 |
| 780 | 782 |
| 781 BeginTest("Catch block 1"); | 783 BeginTest("Catch block 1"); |
| 782 function catch_block_1() { | 784 function catch_block_1() { |
| 783 try { | 785 try { |
| 784 throw 'Exception'; | 786 throw 'Exception'; |
| 785 } catch (e) { | 787 } catch (e) { |
| 786 debugger; | 788 debugger; |
| 787 } | 789 } |
| 788 }; | 790 }; |
| 789 | 791 |
| 790 | 792 |
| 791 listener_delegate = function(exec_state) { | 793 listener_delegate = function(exec_state) { |
| 792 CheckScopeChain([debug.ScopeType.Catch, | 794 CheckScopeChain([debug.ScopeType.Catch, |
| 793 debug.ScopeType.Local, | 795 debug.ScopeType.Local, |
| 794 debug.ScopeType.Global], exec_state); | 796 debug.ScopeType.Global], exec_state); |
| 795 CheckScopeContent({e:'Exception'}, 0, exec_state); | 797 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 796 } | 798 }; |
| 797 catch_block_1() | 799 catch_block_1(); |
| 798 EndTest(); | 800 EndTest(); |
| 799 | 801 |
| 800 | 802 |
| 801 BeginTest("Catch block 2"); | 803 BeginTest("Catch block 2"); |
| 802 function catch_block_2() { | 804 function catch_block_2() { |
| 803 try { | 805 try { |
| 804 throw 'Exception'; | 806 throw 'Exception'; |
| 805 } catch (e) { | 807 } catch (e) { |
| 806 with({n:10}) { | 808 with({n:10}) { |
| 807 debugger; | 809 debugger; |
| 808 } | 810 } |
| 809 } | 811 } |
| 810 }; | 812 }; |
| 811 | 813 |
| 812 | 814 |
| 813 listener_delegate = function(exec_state) { | 815 listener_delegate = function(exec_state) { |
| 814 CheckScopeChain([debug.ScopeType.With, | 816 CheckScopeChain([debug.ScopeType.With, |
| 815 debug.ScopeType.Catch, | 817 debug.ScopeType.Catch, |
| 816 debug.ScopeType.Local, | 818 debug.ScopeType.Local, |
| 817 debug.ScopeType.Global], exec_state); | 819 debug.ScopeType.Global], exec_state); |
| 818 CheckScopeContent({n:10}, 0, exec_state); | 820 CheckScopeContent({n:10}, 0, exec_state); |
| 819 CheckScopeContent({e:'Exception'}, 1, exec_state); | 821 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 820 } | 822 }; |
| 821 catch_block_2() | 823 catch_block_2(); |
| 822 EndTest(); | 824 EndTest(); |
| 823 | 825 |
| 824 | 826 |
| 825 BeginTest("Catch block 3"); | 827 BeginTest("Catch block 3"); |
| 826 function catch_block_3() { | 828 function catch_block_3() { |
| 827 // Do eval to dynamically declare a local variable so that the context's | 829 // Do eval to dynamically declare a local variable so that the context's |
| 828 // extension slot is initialized with JSContextExtensionObject. | 830 // extension slot is initialized with JSContextExtensionObject. |
| 829 eval("var y = 78;"); | 831 eval("var y = 78;"); |
| 830 try { | 832 try { |
| 831 throw 'Exception'; | 833 throw 'Exception'; |
| 832 } catch (e) { | 834 } catch (e) { |
| 833 debugger; | 835 debugger; |
| 834 } | 836 } |
| 835 }; | 837 }; |
| 836 | 838 |
| 837 | 839 |
| 838 listener_delegate = function(exec_state) { | 840 listener_delegate = function(exec_state) { |
| 839 CheckScopeChain([debug.ScopeType.Catch, | 841 CheckScopeChain([debug.ScopeType.Catch, |
| 840 debug.ScopeType.Local, | 842 debug.ScopeType.Local, |
| 841 debug.ScopeType.Global], exec_state); | 843 debug.ScopeType.Global], exec_state); |
| 842 CheckScopeContent({e:'Exception'}, 0, exec_state); | 844 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 843 CheckScopeContent({y:78}, 1, exec_state); | 845 CheckScopeContent({y:78}, 1, exec_state); |
| 844 } | 846 }; |
| 845 catch_block_3() | 847 catch_block_3(); |
| 846 EndTest(); | 848 EndTest(); |
| 847 | 849 |
| 848 | 850 |
| 849 BeginTest("Catch block 4"); | 851 BeginTest("Catch block 4"); |
| 850 function catch_block_4() { | 852 function catch_block_4() { |
| 851 // Do eval to dynamically declare a local variable so that the context's | 853 // Do eval to dynamically declare a local variable so that the context's |
| 852 // extension slot is initialized with JSContextExtensionObject. | 854 // extension slot is initialized with JSContextExtensionObject. |
| 853 eval("var y = 98;"); | 855 eval("var y = 98;"); |
| 854 try { | 856 try { |
| 855 throw 'Exception'; | 857 throw 'Exception'; |
| 856 } catch (e) { | 858 } catch (e) { |
| 857 with({n:10}) { | 859 with({n:10}) { |
| 858 debugger; | 860 debugger; |
| 859 } | 861 } |
| 860 } | 862 } |
| 861 }; | 863 }; |
| 862 | 864 |
| 863 listener_delegate = function(exec_state) { | 865 listener_delegate = function(exec_state) { |
| 864 CheckScopeChain([debug.ScopeType.With, | 866 CheckScopeChain([debug.ScopeType.With, |
| 865 debug.ScopeType.Catch, | 867 debug.ScopeType.Catch, |
| 866 debug.ScopeType.Local, | 868 debug.ScopeType.Local, |
| 867 debug.ScopeType.Global], exec_state); | 869 debug.ScopeType.Global], exec_state); |
| 868 CheckScopeContent({n:10}, 0, exec_state); | 870 CheckScopeContent({n:10}, 0, exec_state); |
| 869 CheckScopeContent({e:'Exception'}, 1, exec_state); | 871 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 870 CheckScopeContent({y:98}, 2, exec_state); | 872 CheckScopeContent({y:98}, 2, exec_state); |
| 871 } | 873 }; |
| 872 catch_block_4() | 874 catch_block_4(); |
| 873 EndTest(); | 875 EndTest(); |
| 874 | 876 |
| 875 | 877 |
| 876 assertEquals(begin_test_count, break_count, 'one or more tests did not enter the
debugger'); | 878 assertEquals(begin_test_count, break_count, |
| 877 assertEquals(begin_test_count, end_test_count, 'one or more tests did not have i
ts result checked'); | 879 'one or more tests did not enter the debugger'); |
| 880 assertEquals(begin_test_count, end_test_count, |
| 881 'one or more tests did not have its result checked'); |
| OLD | NEW |