| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Send a scopes request and check the result. | 123 // Send a scopes request and check the result. |
| 124 var json; | 124 var json; |
| 125 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; | 125 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; |
| 126 var response_json = dcp.processDebugJSONRequest(request_json); | 126 var response_json = dcp.processDebugJSONRequest(request_json); |
| 127 var response = JSON.parse(response_json); | 127 var response = JSON.parse(response_json); |
| 128 assertEquals(scopes.length, response.body.scopes.length); | 128 assertEquals(scopes.length, response.body.scopes.length); |
| 129 for (var i = 0; i < scopes.length; i++) { | 129 for (var i = 0; i < scopes.length; i++) { |
| 130 assertEquals(i, response.body.scopes[i].index); | 130 assertEquals(i, response.body.scopes[i].index); |
| 131 assertEquals(scopes[i], response.body.scopes[i].type); | 131 assertEquals(scopes[i], response.body.scopes[i].type); |
| 132 if (scopes[i] == debug.ScopeType.Local || | 132 if (scopes[i] == debug.ScopeType.Local || |
| 133 scopes[i] == debug.ScopeType.Script || |
| 133 scopes[i] == debug.ScopeType.Closure) { | 134 scopes[i] == debug.ScopeType.Closure) { |
| 134 assertTrue(response.body.scopes[i].object.ref < 0); | 135 assertTrue(response.body.scopes[i].object.ref < 0); |
| 135 } else { | 136 } else { |
| 136 assertTrue(response.body.scopes[i].object.ref >= 0); | 137 assertTrue(response.body.scopes[i].object.ref >= 0); |
| 137 } | 138 } |
| 138 var found = false; | 139 var found = false; |
| 139 for (var j = 0; j < response.refs.length && !found; j++) { | 140 for (var j = 0; j < response.refs.length && !found; j++) { |
| 140 found = response.refs[j].handle == response.body.scopes[i].object.ref; | 141 found = response.refs[j].handle == response.body.scopes[i].object.ref; |
| 141 } | 142 } |
| 142 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); | 143 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Send a scope request for information on a single scope and check the | 187 // Send a scope request for information on a single scope and check the |
| 187 // result. | 188 // result. |
| 188 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"
number":'; | 189 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"
number":'; |
| 189 request_json += scope.scopeIndex(); | 190 request_json += scope.scopeIndex(); |
| 190 request_json += '}}'; | 191 request_json += '}}'; |
| 191 var response_json = dcp.processDebugJSONRequest(request_json); | 192 var response_json = dcp.processDebugJSONRequest(request_json); |
| 192 var response = JSON.parse(response_json); | 193 var response = JSON.parse(response_json); |
| 193 assertEquals(scope.scopeType(), response.body.type); | 194 assertEquals(scope.scopeType(), response.body.type); |
| 194 assertEquals(number, response.body.index); | 195 assertEquals(number, response.body.index); |
| 195 if (scope.scopeType() == debug.ScopeType.Local || | 196 if (scope.scopeType() == debug.ScopeType.Local || |
| 197 scope.scopeType() == debug.ScopeType.Script || |
| 196 scope.scopeType() == debug.ScopeType.Closure) { | 198 scope.scopeType() == debug.ScopeType.Closure) { |
| 197 assertTrue(response.body.object.ref < 0); | 199 assertTrue(response.body.object.ref < 0); |
| 198 } else { | 200 } else { |
| 199 assertTrue(response.body.object.ref >= 0); | 201 assertTrue(response.body.object.ref >= 0); |
| 200 } | 202 } |
| 201 var found = false; | 203 var found = false; |
| 202 for (var i = 0; i < response.refs.length && !found; i++) { | 204 for (var i = 0; i < response.refs.length && !found; i++) { |
| 203 found = response.refs[i].handle == response.body.object.ref; | 205 found = response.refs[i].handle == response.body.object.ref; |
| 204 } | 206 } |
| 205 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); | 207 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); |
| 206 } | 208 } |
| 207 | 209 |
| 208 | 210 |
| 209 // Simple empty local scope. | 211 // Simple empty local scope. |
| 210 BeginTest("Local 1"); | 212 BeginTest("Local 1"); |
| 211 | 213 |
| 212 function local_1() { | 214 function local_1() { |
| 213 debugger; | 215 debugger; |
| 214 } | 216 } |
| 215 | 217 |
| 216 listener_delegate = function(exec_state) { | 218 listener_delegate = function(exec_state) { |
| 217 CheckScopeChain([debug.ScopeType.Local, | 219 CheckScopeChain([debug.ScopeType.Local, |
| 220 debug.ScopeType.Script, |
| 218 debug.ScopeType.Global], exec_state); | 221 debug.ScopeType.Global], exec_state); |
| 219 CheckScopeContent({}, 0, exec_state); | 222 CheckScopeContent({}, 0, exec_state); |
| 220 }; | 223 }; |
| 221 local_1(); | 224 local_1(); |
| 222 EndTest(); | 225 EndTest(); |
| 223 | 226 |
| 224 | 227 |
| 225 // Local scope with a parameter. | 228 // Local scope with a parameter. |
| 226 BeginTest("Local 2"); | 229 BeginTest("Local 2"); |
| 227 | 230 |
| 228 function local_2(a) { | 231 function local_2(a) { |
| 229 debugger; | 232 debugger; |
| 230 } | 233 } |
| 231 | 234 |
| 232 listener_delegate = function(exec_state) { | 235 listener_delegate = function(exec_state) { |
| 233 CheckScopeChain([debug.ScopeType.Local, | 236 CheckScopeChain([debug.ScopeType.Local, |
| 237 debug.ScopeType.Script, |
| 234 debug.ScopeType.Global], exec_state); | 238 debug.ScopeType.Global], exec_state); |
| 235 CheckScopeContent({a:1}, 0, exec_state); | 239 CheckScopeContent({a:1}, 0, exec_state); |
| 236 }; | 240 }; |
| 237 local_2(1); | 241 local_2(1); |
| 238 EndTest(); | 242 EndTest(); |
| 239 | 243 |
| 240 | 244 |
| 241 // Local scope with a parameter and a local variable. | 245 // Local scope with a parameter and a local variable. |
| 242 BeginTest("Local 3"); | 246 BeginTest("Local 3"); |
| 243 | 247 |
| 244 function local_3(a) { | 248 function local_3(a) { |
| 245 var x = 3; | 249 var x = 3; |
| 246 debugger; | 250 debugger; |
| 247 } | 251 } |
| 248 | 252 |
| 249 listener_delegate = function(exec_state) { | 253 listener_delegate = function(exec_state) { |
| 250 CheckScopeChain([debug.ScopeType.Local, | 254 CheckScopeChain([debug.ScopeType.Local, |
| 255 debug.ScopeType.Script, |
| 251 debug.ScopeType.Global], exec_state); | 256 debug.ScopeType.Global], exec_state); |
| 252 CheckScopeContent({a:1,x:3}, 0, exec_state); | 257 CheckScopeContent({a:1,x:3}, 0, exec_state); |
| 253 }; | 258 }; |
| 254 local_3(1); | 259 local_3(1); |
| 255 EndTest(); | 260 EndTest(); |
| 256 | 261 |
| 257 | 262 |
| 258 // Local scope with parameters and local variables. | 263 // Local scope with parameters and local variables. |
| 259 BeginTest("Local 4"); | 264 BeginTest("Local 4"); |
| 260 | 265 |
| 261 function local_4(a, b) { | 266 function local_4(a, b) { |
| 262 var x = 3; | 267 var x = 3; |
| 263 var y = 4; | 268 var y = 4; |
| 264 debugger; | 269 debugger; |
| 265 } | 270 } |
| 266 | 271 |
| 267 listener_delegate = function(exec_state) { | 272 listener_delegate = function(exec_state) { |
| 268 CheckScopeChain([debug.ScopeType.Local, | 273 CheckScopeChain([debug.ScopeType.Local, |
| 274 debug.ScopeType.Script, |
| 269 debug.ScopeType.Global], exec_state); | 275 debug.ScopeType.Global], exec_state); |
| 270 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); | 276 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); |
| 271 }; | 277 }; |
| 272 local_4(1, 2); | 278 local_4(1, 2); |
| 273 EndTest(); | 279 EndTest(); |
| 274 | 280 |
| 275 | 281 |
| 276 // Empty local scope with use of eval. | 282 // Empty local scope with use of eval. |
| 277 BeginTest("Local 5"); | 283 BeginTest("Local 5"); |
| 278 | 284 |
| 279 function local_5() { | 285 function local_5() { |
| 280 eval(''); | 286 eval(''); |
| 281 debugger; | 287 debugger; |
| 282 } | 288 } |
| 283 | 289 |
| 284 listener_delegate = function(exec_state) { | 290 listener_delegate = function(exec_state) { |
| 285 CheckScopeChain([debug.ScopeType.Local, | 291 CheckScopeChain([debug.ScopeType.Local, |
| 292 debug.ScopeType.Script, |
| 286 debug.ScopeType.Global], exec_state); | 293 debug.ScopeType.Global], exec_state); |
| 287 CheckScopeContent({}, 0, exec_state); | 294 CheckScopeContent({}, 0, exec_state); |
| 288 }; | 295 }; |
| 289 local_5(); | 296 local_5(); |
| 290 EndTest(); | 297 EndTest(); |
| 291 | 298 |
| 292 | 299 |
| 293 // Local introducing local variable using eval. | 300 // Local introducing local variable using eval. |
| 294 BeginTest("Local 6"); | 301 BeginTest("Local 6"); |
| 295 | 302 |
| 296 function local_6() { | 303 function local_6() { |
| 297 eval('var i = 5'); | 304 eval('var i = 5'); |
| 298 debugger; | 305 debugger; |
| 299 } | 306 } |
| 300 | 307 |
| 301 listener_delegate = function(exec_state) { | 308 listener_delegate = function(exec_state) { |
| 302 CheckScopeChain([debug.ScopeType.Local, | 309 CheckScopeChain([debug.ScopeType.Local, |
| 310 debug.ScopeType.Script, |
| 303 debug.ScopeType.Global], exec_state); | 311 debug.ScopeType.Global], exec_state); |
| 304 CheckScopeContent({i:5}, 0, exec_state); | 312 CheckScopeContent({i:5}, 0, exec_state); |
| 305 }; | 313 }; |
| 306 local_6(); | 314 local_6(); |
| 307 EndTest(); | 315 EndTest(); |
| 308 | 316 |
| 309 | 317 |
| 310 // Local scope with parameters, local variables and local variable introduced | 318 // Local scope with parameters, local variables and local variable introduced |
| 311 // using eval. | 319 // using eval. |
| 312 BeginTest("Local 7"); | 320 BeginTest("Local 7"); |
| 313 | 321 |
| 314 function local_7(a, b) { | 322 function local_7(a, b) { |
| 315 var x = 3; | 323 var x = 3; |
| 316 var y = 4; | 324 var y = 4; |
| 317 eval('var i = 5'); | 325 eval('var i = 5'); |
| 318 eval('var j = 6'); | 326 eval('var j = 6'); |
| 319 debugger; | 327 debugger; |
| 320 } | 328 } |
| 321 | 329 |
| 322 listener_delegate = function(exec_state) { | 330 listener_delegate = function(exec_state) { |
| 323 CheckScopeChain([debug.ScopeType.Local, | 331 CheckScopeChain([debug.ScopeType.Local, |
| 332 debug.ScopeType.Script, |
| 324 debug.ScopeType.Global], exec_state); | 333 debug.ScopeType.Global], exec_state); |
| 325 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state); | 334 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state); |
| 326 }; | 335 }; |
| 327 local_7(1, 2); | 336 local_7(1, 2); |
| 328 EndTest(); | 337 EndTest(); |
| 329 | 338 |
| 330 | 339 |
| 331 // Single empty with block. | 340 // Single empty with block. |
| 332 BeginTest("With 1"); | 341 BeginTest("With 1"); |
| 333 | 342 |
| 334 function with_1() { | 343 function with_1() { |
| 335 with({}) { | 344 with({}) { |
| 336 debugger; | 345 debugger; |
| 337 } | 346 } |
| 338 } | 347 } |
| 339 | 348 |
| 340 listener_delegate = function(exec_state) { | 349 listener_delegate = function(exec_state) { |
| 341 CheckScopeChain([debug.ScopeType.With, | 350 CheckScopeChain([debug.ScopeType.With, |
| 342 debug.ScopeType.Local, | 351 debug.ScopeType.Local, |
| 352 debug.ScopeType.Script, |
| 343 debug.ScopeType.Global], exec_state); | 353 debug.ScopeType.Global], exec_state); |
| 344 CheckScopeContent({}, 0, exec_state); | 354 CheckScopeContent({}, 0, exec_state); |
| 345 }; | 355 }; |
| 346 with_1(); | 356 with_1(); |
| 347 EndTest(); | 357 EndTest(); |
| 348 | 358 |
| 349 | 359 |
| 350 // Nested empty with blocks. | 360 // Nested empty with blocks. |
| 351 BeginTest("With 2"); | 361 BeginTest("With 2"); |
| 352 | 362 |
| 353 function with_2() { | 363 function with_2() { |
| 354 with({}) { | 364 with({}) { |
| 355 with({}) { | 365 with({}) { |
| 356 debugger; | 366 debugger; |
| 357 } | 367 } |
| 358 } | 368 } |
| 359 } | 369 } |
| 360 | 370 |
| 361 listener_delegate = function(exec_state) { | 371 listener_delegate = function(exec_state) { |
| 362 CheckScopeChain([debug.ScopeType.With, | 372 CheckScopeChain([debug.ScopeType.With, |
| 363 debug.ScopeType.With, | 373 debug.ScopeType.With, |
| 364 debug.ScopeType.Local, | 374 debug.ScopeType.Local, |
| 375 debug.ScopeType.Script, |
| 365 debug.ScopeType.Global], exec_state); | 376 debug.ScopeType.Global], exec_state); |
| 366 CheckScopeContent({}, 0, exec_state); | 377 CheckScopeContent({}, 0, exec_state); |
| 367 CheckScopeContent({}, 1, exec_state); | 378 CheckScopeContent({}, 1, exec_state); |
| 368 }; | 379 }; |
| 369 with_2(); | 380 with_2(); |
| 370 EndTest(); | 381 EndTest(); |
| 371 | 382 |
| 372 | 383 |
| 373 // With block using an in-place object literal. | 384 // With block using an in-place object literal. |
| 374 BeginTest("With 3"); | 385 BeginTest("With 3"); |
| 375 | 386 |
| 376 function with_3() { | 387 function with_3() { |
| 377 with({a:1,b:2}) { | 388 with({a:1,b:2}) { |
| 378 debugger; | 389 debugger; |
| 379 } | 390 } |
| 380 } | 391 } |
| 381 | 392 |
| 382 listener_delegate = function(exec_state) { | 393 listener_delegate = function(exec_state) { |
| 383 CheckScopeChain([debug.ScopeType.With, | 394 CheckScopeChain([debug.ScopeType.With, |
| 384 debug.ScopeType.Local, | 395 debug.ScopeType.Local, |
| 396 debug.ScopeType.Script, |
| 385 debug.ScopeType.Global], exec_state); | 397 debug.ScopeType.Global], exec_state); |
| 386 CheckScopeContent({a:1,b:2}, 0, exec_state); | 398 CheckScopeContent({a:1,b:2}, 0, exec_state); |
| 387 }; | 399 }; |
| 388 with_3(); | 400 with_3(); |
| 389 EndTest(); | 401 EndTest(); |
| 390 | 402 |
| 391 | 403 |
| 392 // Nested with blocks using in-place object literals. | 404 // Nested with blocks using in-place object literals. |
| 393 BeginTest("With 4"); | 405 BeginTest("With 4"); |
| 394 | 406 |
| 395 function with_4() { | 407 function with_4() { |
| 396 with({a:1,b:2}) { | 408 with({a:1,b:2}) { |
| 397 with({a:2,b:1}) { | 409 with({a:2,b:1}) { |
| 398 debugger; | 410 debugger; |
| 399 } | 411 } |
| 400 } | 412 } |
| 401 } | 413 } |
| 402 | 414 |
| 403 listener_delegate = function(exec_state) { | 415 listener_delegate = function(exec_state) { |
| 404 CheckScopeChain([debug.ScopeType.With, | 416 CheckScopeChain([debug.ScopeType.With, |
| 405 debug.ScopeType.With, | 417 debug.ScopeType.With, |
| 406 debug.ScopeType.Local, | 418 debug.ScopeType.Local, |
| 419 debug.ScopeType.Script, |
| 407 debug.ScopeType.Global], exec_state); | 420 debug.ScopeType.Global], exec_state); |
| 408 CheckScopeContent({a:2,b:1}, 0, exec_state); | 421 CheckScopeContent({a:2,b:1}, 0, exec_state); |
| 409 CheckScopeContent({a:1,b:2}, 1, exec_state); | 422 CheckScopeContent({a:1,b:2}, 1, exec_state); |
| 410 }; | 423 }; |
| 411 with_4(); | 424 with_4(); |
| 412 EndTest(); | 425 EndTest(); |
| 413 | 426 |
| 414 | 427 |
| 415 // Nested with blocks using existing object. | 428 // Nested with blocks using existing object. |
| 416 BeginTest("With 5"); | 429 BeginTest("With 5"); |
| 417 | 430 |
| 418 var with_object = {c:3,d:4}; | 431 var with_object = {c:3,d:4}; |
| 419 function with_5() { | 432 function with_5() { |
| 420 with(with_object) { | 433 with(with_object) { |
| 421 with(with_object) { | 434 with(with_object) { |
| 422 debugger; | 435 debugger; |
| 423 } | 436 } |
| 424 } | 437 } |
| 425 } | 438 } |
| 426 | 439 |
| 427 listener_delegate = function(exec_state) { | 440 listener_delegate = function(exec_state) { |
| 428 CheckScopeChain([debug.ScopeType.With, | 441 CheckScopeChain([debug.ScopeType.With, |
| 429 debug.ScopeType.With, | 442 debug.ScopeType.With, |
| 430 debug.ScopeType.Local, | 443 debug.ScopeType.Local, |
| 444 debug.ScopeType.Script, |
| 431 debug.ScopeType.Global], exec_state); | 445 debug.ScopeType.Global], exec_state); |
| 432 CheckScopeContent(with_object, 0, exec_state); | 446 CheckScopeContent(with_object, 0, exec_state); |
| 433 CheckScopeContent(with_object, 1, exec_state); | 447 CheckScopeContent(with_object, 1, exec_state); |
| 434 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); | 448 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); |
| 435 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 449 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 436 }; | 450 }; |
| 437 with_5(); | 451 with_5(); |
| 438 EndTest(); | 452 EndTest(); |
| 439 | 453 |
| 440 | 454 |
| 441 // Nested with blocks using existing object in global code. | 455 // Nested with blocks using existing object in global code. |
| 442 BeginTest("With 6"); | 456 BeginTest("With 6"); |
| 443 listener_delegate = function(exec_state) { | 457 listener_delegate = function(exec_state) { |
| 444 CheckScopeChain([debug.ScopeType.With, | 458 CheckScopeChain([debug.ScopeType.With, |
| 445 debug.ScopeType.With, | 459 debug.ScopeType.With, |
| 460 debug.ScopeType.Script, |
| 446 debug.ScopeType.Global], exec_state); | 461 debug.ScopeType.Global], exec_state); |
| 447 CheckScopeContent(with_object, 0, exec_state); | 462 CheckScopeContent(with_object, 0, exec_state); |
| 448 CheckScopeContent(with_object, 1, exec_state); | 463 CheckScopeContent(with_object, 1, exec_state); |
| 449 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); | 464 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); |
| 450 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 465 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 451 }; | 466 }; |
| 452 | 467 |
| 453 var with_object = {c:3,d:4}; | 468 var with_object = {c:3,d:4}; |
| 454 with(with_object) { | 469 with(with_object) { |
| 455 with(with_object) { | 470 with(with_object) { |
| 456 debugger; | 471 debugger; |
| 457 } | 472 } |
| 458 } | 473 } |
| 459 EndTest(); | 474 EndTest(); |
| 460 | 475 |
| 461 | 476 |
| 462 // With block in function that is marked for optimization while being executed. | 477 // With block in function that is marked for optimization while being executed. |
| 463 BeginTest("With 7"); | 478 BeginTest("With 7"); |
| 464 | 479 |
| 465 function with_7() { | 480 function with_7() { |
| 466 with({}) { | 481 with({}) { |
| 467 %OptimizeFunctionOnNextCall(with_7); | 482 %OptimizeFunctionOnNextCall(with_7); |
| 468 debugger; | 483 debugger; |
| 469 } | 484 } |
| 470 } | 485 } |
| 471 | 486 |
| 472 listener_delegate = function(exec_state) { | 487 listener_delegate = function(exec_state) { |
| 473 CheckScopeChain([debug.ScopeType.With, | 488 CheckScopeChain([debug.ScopeType.With, |
| 474 debug.ScopeType.Local, | 489 debug.ScopeType.Local, |
| 490 debug.ScopeType.Script, |
| 475 debug.ScopeType.Global], exec_state); | 491 debug.ScopeType.Global], exec_state); |
| 476 CheckScopeContent({}, 0, exec_state); | 492 CheckScopeContent({}, 0, exec_state); |
| 477 }; | 493 }; |
| 478 with_7(); | 494 with_7(); |
| 479 EndTest(); | 495 EndTest(); |
| 480 | 496 |
| 481 | 497 |
| 482 // Simple closure formed by returning an inner function referering the outer | 498 // Simple closure formed by returning an inner function referering the outer |
| 483 // functions arguments. | 499 // functions arguments. |
| 484 BeginTest("Closure 1"); | 500 BeginTest("Closure 1"); |
| 485 | 501 |
| 486 function closure_1(a) { | 502 function closure_1(a) { |
| 487 function f() { | 503 function f() { |
| 488 debugger; | 504 debugger; |
| 489 return a; | 505 return a; |
| 490 }; | 506 }; |
| 491 return f; | 507 return f; |
| 492 } | 508 } |
| 493 | 509 |
| 494 listener_delegate = function(exec_state) { | 510 listener_delegate = function(exec_state) { |
| 495 CheckScopeChain([debug.ScopeType.Local, | 511 CheckScopeChain([debug.ScopeType.Local, |
| 496 debug.ScopeType.Closure, | 512 debug.ScopeType.Closure, |
| 513 debug.ScopeType.Script, |
| 497 debug.ScopeType.Global], exec_state); | 514 debug.ScopeType.Global], exec_state); |
| 498 CheckScopeContent({a:1}, 1, exec_state); | 515 CheckScopeContent({a:1}, 1, exec_state); |
| 499 }; | 516 }; |
| 500 closure_1(1)(); | 517 closure_1(1)(); |
| 501 EndTest(); | 518 EndTest(); |
| 502 | 519 |
| 503 | 520 |
| 504 // Simple closure formed by returning an inner function referering the outer | 521 // Simple closure formed by returning an inner function referering the outer |
| 505 // functions arguments. Due to VM optimizations parts of the actual closure is | 522 // functions arguments. Due to VM optimizations parts of the actual closure is |
| 506 // missing from the debugger information. | 523 // missing from the debugger information. |
| 507 BeginTest("Closure 2"); | 524 BeginTest("Closure 2"); |
| 508 | 525 |
| 509 function closure_2(a, b) { | 526 function closure_2(a, b) { |
| 510 var x = a + 2; | 527 var x = a + 2; |
| 511 var y = b + 2; | 528 var y = b + 2; |
| 512 function f() { | 529 function f() { |
| 513 debugger; | 530 debugger; |
| 514 return a + x; | 531 return a + x; |
| 515 }; | 532 }; |
| 516 return f; | 533 return f; |
| 517 } | 534 } |
| 518 | 535 |
| 519 listener_delegate = function(exec_state) { | 536 listener_delegate = function(exec_state) { |
| 520 CheckScopeChain([debug.ScopeType.Local, | 537 CheckScopeChain([debug.ScopeType.Local, |
| 521 debug.ScopeType.Closure, | 538 debug.ScopeType.Closure, |
| 539 debug.ScopeType.Script, |
| 522 debug.ScopeType.Global], exec_state); | 540 debug.ScopeType.Global], exec_state); |
| 523 CheckScopeContent({a:1,x:3}, 1, exec_state); | 541 CheckScopeContent({a:1,x:3}, 1, exec_state); |
| 524 }; | 542 }; |
| 525 closure_2(1, 2)(); | 543 closure_2(1, 2)(); |
| 526 EndTest(); | 544 EndTest(); |
| 527 | 545 |
| 528 | 546 |
| 529 // Simple closure formed by returning an inner function referering the outer | 547 // Simple closure formed by returning an inner function referering the outer |
| 530 // functions arguments. Using all arguments and locals from the outer function | 548 // functions arguments. Using all arguments and locals from the outer function |
| 531 // in the inner function makes these part of the debugger information on the | 549 // in the inner function makes these part of the debugger information on the |
| 532 // closure. | 550 // closure. |
| 533 BeginTest("Closure 3"); | 551 BeginTest("Closure 3"); |
| 534 | 552 |
| 535 function closure_3(a, b) { | 553 function closure_3(a, b) { |
| 536 var x = a + 2; | 554 var x = a + 2; |
| 537 var y = b + 2; | 555 var y = b + 2; |
| 538 function f() { | 556 function f() { |
| 539 debugger; | 557 debugger; |
| 540 return a + b + x + y; | 558 return a + b + x + y; |
| 541 }; | 559 }; |
| 542 return f; | 560 return f; |
| 543 } | 561 } |
| 544 | 562 |
| 545 listener_delegate = function(exec_state) { | 563 listener_delegate = function(exec_state) { |
| 546 CheckScopeChain([debug.ScopeType.Local, | 564 CheckScopeChain([debug.ScopeType.Local, |
| 547 debug.ScopeType.Closure, | 565 debug.ScopeType.Closure, |
| 566 debug.ScopeType.Script, |
| 548 debug.ScopeType.Global], exec_state); | 567 debug.ScopeType.Global], exec_state); |
| 549 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); | 568 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); |
| 550 }; | 569 }; |
| 551 closure_3(1, 2)(); | 570 closure_3(1, 2)(); |
| 552 EndTest(); | 571 EndTest(); |
| 553 | 572 |
| 554 | 573 |
| 555 | 574 |
| 556 // Simple closure formed by returning an inner function referering the outer | 575 // Simple closure formed by returning an inner function referering the outer |
| 557 // functions arguments. Using all arguments and locals from the outer function | 576 // functions arguments. Using all arguments and locals from the outer function |
| 558 // in the inner function makes these part of the debugger information on the | 577 // in the inner function makes these part of the debugger information on the |
| 559 // closure. Use the inner function as well... | 578 // closure. Use the inner function as well... |
| 560 BeginTest("Closure 4"); | 579 BeginTest("Closure 4"); |
| 561 | 580 |
| 562 function closure_4(a, b) { | 581 function closure_4(a, b) { |
| 563 var x = a + 2; | 582 var x = a + 2; |
| 564 var y = b + 2; | 583 var y = b + 2; |
| 565 function f() { | 584 function f() { |
| 566 debugger; | 585 debugger; |
| 567 if (f) { | 586 if (f) { |
| 568 return a + b + x + y; | 587 return a + b + x + y; |
| 569 } | 588 } |
| 570 }; | 589 }; |
| 571 return f; | 590 return f; |
| 572 } | 591 } |
| 573 | 592 |
| 574 listener_delegate = function(exec_state) { | 593 listener_delegate = function(exec_state) { |
| 575 CheckScopeChain([debug.ScopeType.Local, | 594 CheckScopeChain([debug.ScopeType.Local, |
| 576 debug.ScopeType.Closure, | 595 debug.ScopeType.Closure, |
| 596 debug.ScopeType.Script, |
| 577 debug.ScopeType.Global], exec_state); | 597 debug.ScopeType.Global], exec_state); |
| 578 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 598 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 579 }; | 599 }; |
| 580 closure_4(1, 2)(); | 600 closure_4(1, 2)(); |
| 581 EndTest(); | 601 EndTest(); |
| 582 | 602 |
| 583 | 603 |
| 584 | 604 |
| 585 // Simple closure formed by returning an inner function referering the outer | 605 // Simple closure formed by returning an inner function referering the outer |
| 586 // functions arguments. In the presence of eval all arguments and locals | 606 // functions arguments. In the presence of eval all arguments and locals |
| 587 // (including the inner function itself) from the outer function becomes part of | 607 // (including the inner function itself) from the outer function becomes part of |
| 588 // the debugger infformation on the closure. | 608 // the debugger infformation on the closure. |
| 589 BeginTest("Closure 5"); | 609 BeginTest("Closure 5"); |
| 590 | 610 |
| 591 function closure_5(a, b) { | 611 function closure_5(a, b) { |
| 592 var x = 3; | 612 var x = 3; |
| 593 var y = 4; | 613 var y = 4; |
| 594 function f() { | 614 function f() { |
| 595 eval(''); | 615 eval(''); |
| 596 debugger; | 616 debugger; |
| 597 return 1; | 617 return 1; |
| 598 }; | 618 }; |
| 599 return f; | 619 return f; |
| 600 } | 620 } |
| 601 | 621 |
| 602 listener_delegate = function(exec_state) { | 622 listener_delegate = function(exec_state) { |
| 603 CheckScopeChain([debug.ScopeType.Local, | 623 CheckScopeChain([debug.ScopeType.Local, |
| 604 debug.ScopeType.Closure, | 624 debug.ScopeType.Closure, |
| 625 debug.ScopeType.Script, |
| 605 debug.ScopeType.Global], exec_state); | 626 debug.ScopeType.Global], exec_state); |
| 606 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 627 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 607 }; | 628 }; |
| 608 closure_5(1, 2)(); | 629 closure_5(1, 2)(); |
| 609 EndTest(); | 630 EndTest(); |
| 610 | 631 |
| 611 | 632 |
| 612 // Two closures. Due to optimizations only the parts actually used are provided | 633 // Two closures. Due to optimizations only the parts actually used are provided |
| 613 // through the debugger information. | 634 // through the debugger information. |
| 614 BeginTest("Closure 6"); | 635 BeginTest("Closure 6"); |
| 615 function closure_6(a, b) { | 636 function closure_6(a, b) { |
| 616 function f(a, b) { | 637 function f(a, b) { |
| 617 var x = 3; | 638 var x = 3; |
| 618 var y = 4; | 639 var y = 4; |
| 619 return function() { | 640 return function() { |
| 620 var x = 3; | 641 var x = 3; |
| 621 var y = 4; | 642 var y = 4; |
| 622 debugger; | 643 debugger; |
| 623 some_global = a; | 644 some_global = a; |
| 624 return f; | 645 return f; |
| 625 }; | 646 }; |
| 626 } | 647 } |
| 627 return f(a, b); | 648 return f(a, b); |
| 628 } | 649 } |
| 629 | 650 |
| 630 listener_delegate = function(exec_state) { | 651 listener_delegate = function(exec_state) { |
| 631 CheckScopeChain([debug.ScopeType.Local, | 652 CheckScopeChain([debug.ScopeType.Local, |
| 632 debug.ScopeType.Closure, | 653 debug.ScopeType.Closure, |
| 633 debug.ScopeType.Closure, | 654 debug.ScopeType.Closure, |
| 655 debug.ScopeType.Script, |
| 634 debug.ScopeType.Global], exec_state); | 656 debug.ScopeType.Global], exec_state); |
| 635 CheckScopeContent({a:1}, 1, exec_state); | 657 CheckScopeContent({a:1}, 1, exec_state); |
| 636 CheckScopeContent({f:function(){}}, 2, exec_state); | 658 CheckScopeContent({f:function(){}}, 2, exec_state); |
| 637 }; | 659 }; |
| 638 closure_6(1, 2)(); | 660 closure_6(1, 2)(); |
| 639 EndTest(); | 661 EndTest(); |
| 640 | 662 |
| 641 | 663 |
| 642 // Two closures. In the presence of eval all information is provided as the | 664 // Two closures. In the presence of eval all information is provided as the |
| 643 // compiler cannot determine which parts are used. | 665 // compiler cannot determine which parts are used. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 658 return f; | 680 return f; |
| 659 }; | 681 }; |
| 660 } | 682 } |
| 661 return f(a, b); | 683 return f(a, b); |
| 662 } | 684 } |
| 663 | 685 |
| 664 listener_delegate = function(exec_state) { | 686 listener_delegate = function(exec_state) { |
| 665 CheckScopeChain([debug.ScopeType.Local, | 687 CheckScopeChain([debug.ScopeType.Local, |
| 666 debug.ScopeType.Closure, | 688 debug.ScopeType.Closure, |
| 667 debug.ScopeType.Closure, | 689 debug.ScopeType.Closure, |
| 690 debug.ScopeType.Script, |
| 668 debug.ScopeType.Global], exec_state); | 691 debug.ScopeType.Global], exec_state); |
| 669 CheckScopeContent({}, 0, exec_state); | 692 CheckScopeContent({}, 0, exec_state); |
| 670 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); | 693 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); |
| 671 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); | 694 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); |
| 672 }; | 695 }; |
| 673 closure_7(1, 2)(); | 696 closure_7(1, 2)(); |
| 674 EndTest(); | 697 EndTest(); |
| 675 | 698 |
| 676 | 699 |
| 677 // Closure that may be optimized out. | 700 // Closure that may be optimized out. |
| 678 BeginTest("Closure 8"); | 701 BeginTest("Closure 8"); |
| 679 function closure_8() { | 702 function closure_8() { |
| 680 (function inner(x) { | 703 (function inner(x) { |
| 681 debugger; | 704 debugger; |
| 682 })(2); | 705 })(2); |
| 683 } | 706 } |
| 684 | 707 |
| 685 listener_delegate = function(exec_state) { | 708 listener_delegate = function(exec_state) { |
| 686 CheckScopeChain([debug.ScopeType.Local, | 709 CheckScopeChain([debug.ScopeType.Local, |
| 710 debug.ScopeType.Script, |
| 687 debug.ScopeType.Global], exec_state); | 711 debug.ScopeType.Global], exec_state); |
| 688 CheckScopeContent({x: 2}, 0, exec_state); | 712 CheckScopeContent({x: 2}, 0, exec_state); |
| 689 }; | 713 }; |
| 690 closure_8(); | 714 closure_8(); |
| 691 EndTest(); | 715 EndTest(); |
| 692 | 716 |
| 693 | 717 |
| 694 BeginTest("Closure 9"); | 718 BeginTest("Closure 9"); |
| 695 function closure_9() { | 719 function closure_9() { |
| 696 eval("var y = 1;"); | 720 eval("var y = 1;"); |
| 697 eval("var z = 1;"); | 721 eval("var z = 1;"); |
| 698 (function inner(x) { | 722 (function inner(x) { |
| 699 y++; | 723 y++; |
| 700 z++; | 724 z++; |
| 701 debugger; | 725 debugger; |
| 702 })(2); | 726 })(2); |
| 703 } | 727 } |
| 704 | 728 |
| 705 listener_delegate = function(exec_state) { | 729 listener_delegate = function(exec_state) { |
| 706 CheckScopeChain([debug.ScopeType.Local, | 730 CheckScopeChain([debug.ScopeType.Local, |
| 707 debug.ScopeType.Closure, | 731 debug.ScopeType.Closure, |
| 732 debug.ScopeType.Script, |
| 708 debug.ScopeType.Global], exec_state); | 733 debug.ScopeType.Global], exec_state); |
| 709 }; | 734 }; |
| 710 closure_9(); | 735 closure_9(); |
| 711 EndTest(); | 736 EndTest(); |
| 712 | 737 |
| 713 | 738 |
| 714 // Test a mixture of scopes. | 739 // Test a mixture of scopes. |
| 715 BeginTest("The full monty"); | 740 BeginTest("The full monty"); |
| 716 function the_full_monty(a, b) { | 741 function the_full_monty(a, b) { |
| 717 var x = 3; | 742 var x = 3; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 739 return f(a, b); | 764 return f(a, b); |
| 740 } | 765 } |
| 741 | 766 |
| 742 listener_delegate = function(exec_state) { | 767 listener_delegate = function(exec_state) { |
| 743 CheckScopeChain([debug.ScopeType.With, | 768 CheckScopeChain([debug.ScopeType.With, |
| 744 debug.ScopeType.With, | 769 debug.ScopeType.With, |
| 745 debug.ScopeType.Local, | 770 debug.ScopeType.Local, |
| 746 debug.ScopeType.With, | 771 debug.ScopeType.With, |
| 747 debug.ScopeType.Closure, | 772 debug.ScopeType.Closure, |
| 748 debug.ScopeType.Closure, | 773 debug.ScopeType.Closure, |
| 774 debug.ScopeType.Script, |
| 749 debug.ScopeType.Global], exec_state); | 775 debug.ScopeType.Global], exec_state); |
| 750 CheckScopeContent({b:16}, 0, exec_state); | 776 CheckScopeContent({b:16}, 0, exec_state); |
| 751 CheckScopeContent({a:15}, 1, exec_state); | 777 CheckScopeContent({a:15}, 1, exec_state); |
| 752 CheckScopeContent({x:14}, 2, exec_state); | 778 CheckScopeContent({x:14}, 2, exec_state); |
| 753 CheckScopeContent({j:13}, 3, exec_state); | 779 CheckScopeContent({j:13}, 3, exec_state); |
| 754 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); | 780 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); |
| 755 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); | 781 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); |
| 756 }; | 782 }; |
| 757 the_full_monty(1, 2)(); | 783 the_full_monty(1, 2)(); |
| 758 EndTest(); | 784 EndTest(); |
| 759 | 785 |
| 760 | 786 |
| 761 BeginTest("Closure inside With 1"); | 787 BeginTest("Closure inside With 1"); |
| 762 function closure_in_with_1() { | 788 function closure_in_with_1() { |
| 763 with({x:1}) { | 789 with({x:1}) { |
| 764 (function inner(x) { | 790 (function inner(x) { |
| 765 debugger; | 791 debugger; |
| 766 })(2); | 792 })(2); |
| 767 } | 793 } |
| 768 } | 794 } |
| 769 | 795 |
| 770 listener_delegate = function(exec_state) { | 796 listener_delegate = function(exec_state) { |
| 771 CheckScopeChain([debug.ScopeType.Local, | 797 CheckScopeChain([debug.ScopeType.Local, |
| 772 debug.ScopeType.With, | 798 debug.ScopeType.With, |
| 773 debug.ScopeType.Closure, | 799 debug.ScopeType.Closure, |
| 800 debug.ScopeType.Script, |
| 774 debug.ScopeType.Global], exec_state); | 801 debug.ScopeType.Global], exec_state); |
| 775 CheckScopeContent({x: 2}, 0, exec_state); | 802 CheckScopeContent({x: 2}, 0, exec_state); |
| 776 }; | 803 }; |
| 777 closure_in_with_1(); | 804 closure_in_with_1(); |
| 778 EndTest(); | 805 EndTest(); |
| 779 | 806 |
| 780 | 807 |
| 781 BeginTest("Closure inside With 2"); | 808 BeginTest("Closure inside With 2"); |
| 782 function closure_in_with_2() { | 809 function closure_in_with_2() { |
| 783 with({x:1}) { | 810 with({x:1}) { |
| 784 (function inner(x) { | 811 (function inner(x) { |
| 785 with({x:3}) { | 812 with({x:3}) { |
| 786 debugger; | 813 debugger; |
| 787 } | 814 } |
| 788 })(2); | 815 })(2); |
| 789 } | 816 } |
| 790 } | 817 } |
| 791 | 818 |
| 792 listener_delegate = function(exec_state) { | 819 listener_delegate = function(exec_state) { |
| 793 CheckScopeChain([debug.ScopeType.With, | 820 CheckScopeChain([debug.ScopeType.With, |
| 794 debug.ScopeType.Local, | 821 debug.ScopeType.Local, |
| 795 debug.ScopeType.With, | 822 debug.ScopeType.With, |
| 796 debug.ScopeType.Closure, | 823 debug.ScopeType.Closure, |
| 824 debug.ScopeType.Script, |
| 797 debug.ScopeType.Global], exec_state); | 825 debug.ScopeType.Global], exec_state); |
| 798 CheckScopeContent({x: 3}, 0, exec_state); | 826 CheckScopeContent({x: 3}, 0, exec_state); |
| 799 CheckScopeContent({x: 2}, 1, exec_state); | 827 CheckScopeContent({x: 2}, 1, exec_state); |
| 800 CheckScopeContent({x: 1}, 2, exec_state); | 828 CheckScopeContent({x: 1}, 2, exec_state); |
| 801 }; | 829 }; |
| 802 closure_in_with_2(); | 830 closure_in_with_2(); |
| 803 EndTest(); | 831 EndTest(); |
| 804 | 832 |
| 805 | 833 |
| 806 BeginTest("Closure inside With 3"); | 834 BeginTest("Closure inside With 3"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 819 function closure_in_with_3() { | 847 function closure_in_with_3() { |
| 820 var f = createClosure(0); | 848 var f = createClosure(0); |
| 821 f(); | 849 f(); |
| 822 } | 850 } |
| 823 | 851 |
| 824 listener_delegate = function(exec_state) { | 852 listener_delegate = function(exec_state) { |
| 825 CheckScopeChain([debug.ScopeType.With, | 853 CheckScopeChain([debug.ScopeType.With, |
| 826 debug.ScopeType.Local, | 854 debug.ScopeType.Local, |
| 827 debug.ScopeType.Closure, | 855 debug.ScopeType.Closure, |
| 828 debug.ScopeType.Closure, | 856 debug.ScopeType.Closure, |
| 857 debug.ScopeType.Script, |
| 829 debug.ScopeType.Global], exec_state); | 858 debug.ScopeType.Global], exec_state); |
| 830 } | 859 } |
| 831 closure_in_with_3(); | 860 closure_in_with_3(); |
| 832 EndTest(); | 861 EndTest(); |
| 833 | 862 |
| 834 | 863 |
| 835 BeginTest("Closure inside With 4"); | 864 BeginTest("Closure inside With 4"); |
| 836 listener_delegate = function(exec_state) { | 865 listener_delegate = function(exec_state) { |
| 837 CheckScopeChain([debug.ScopeType.Local, | 866 CheckScopeChain([debug.ScopeType.Local, |
| 838 debug.ScopeType.With, | 867 debug.ScopeType.With, |
| 868 debug.ScopeType.Script, |
| 839 debug.ScopeType.Global], exec_state); | 869 debug.ScopeType.Global], exec_state); |
| 840 CheckScopeContent({x: 2}, 0, exec_state); | 870 CheckScopeContent({x: 2}, 0, exec_state); |
| 841 CheckScopeContent({x: 1}, 1, exec_state); | 871 CheckScopeContent({x: 1}, 1, exec_state); |
| 842 }; | 872 }; |
| 843 | 873 |
| 844 with({x:1}) { | 874 with({x:1}) { |
| 845 (function(x) { | 875 (function(x) { |
| 846 debugger; | 876 debugger; |
| 847 })(2); | 877 })(2); |
| 848 } | 878 } |
| 849 EndTest(); | 879 EndTest(); |
| 850 | 880 |
| 851 | 881 |
| 852 // Test global scope. | 882 // Test global scope. |
| 853 BeginTest("Global"); | 883 BeginTest("Global"); |
| 854 listener_delegate = function(exec_state) { | 884 listener_delegate = function(exec_state) { |
| 855 CheckScopeChain([debug.ScopeType.Global], exec_state); | 885 CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global], exec_state); |
| 856 }; | 886 }; |
| 857 debugger; | 887 debugger; |
| 858 EndTest(); | 888 EndTest(); |
| 859 | 889 |
| 860 | 890 |
| 861 BeginTest("Catch block 1"); | 891 BeginTest("Catch block 1"); |
| 862 function catch_block_1() { | 892 function catch_block_1() { |
| 863 try { | 893 try { |
| 864 throw 'Exception'; | 894 throw 'Exception'; |
| 865 } catch (e) { | 895 } catch (e) { |
| 866 debugger; | 896 debugger; |
| 867 } | 897 } |
| 868 }; | 898 }; |
| 869 | 899 |
| 870 | 900 |
| 871 listener_delegate = function(exec_state) { | 901 listener_delegate = function(exec_state) { |
| 872 CheckScopeChain([debug.ScopeType.Catch, | 902 CheckScopeChain([debug.ScopeType.Catch, |
| 873 debug.ScopeType.Local, | 903 debug.ScopeType.Local, |
| 904 debug.ScopeType.Script, |
| 874 debug.ScopeType.Global], exec_state); | 905 debug.ScopeType.Global], exec_state); |
| 875 CheckScopeContent({e:'Exception'}, 0, exec_state); | 906 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 876 }; | 907 }; |
| 877 catch_block_1(); | 908 catch_block_1(); |
| 878 EndTest(); | 909 EndTest(); |
| 879 | 910 |
| 880 | 911 |
| 881 BeginTest("Catch block 2"); | 912 BeginTest("Catch block 2"); |
| 882 function catch_block_2() { | 913 function catch_block_2() { |
| 883 try { | 914 try { |
| 884 throw 'Exception'; | 915 throw 'Exception'; |
| 885 } catch (e) { | 916 } catch (e) { |
| 886 with({n:10}) { | 917 with({n:10}) { |
| 887 debugger; | 918 debugger; |
| 888 } | 919 } |
| 889 } | 920 } |
| 890 }; | 921 }; |
| 891 | 922 |
| 892 | 923 |
| 893 listener_delegate = function(exec_state) { | 924 listener_delegate = function(exec_state) { |
| 894 CheckScopeChain([debug.ScopeType.With, | 925 CheckScopeChain([debug.ScopeType.With, |
| 895 debug.ScopeType.Catch, | 926 debug.ScopeType.Catch, |
| 896 debug.ScopeType.Local, | 927 debug.ScopeType.Local, |
| 928 debug.ScopeType.Script, |
| 897 debug.ScopeType.Global], exec_state); | 929 debug.ScopeType.Global], exec_state); |
| 898 CheckScopeContent({n:10}, 0, exec_state); | 930 CheckScopeContent({n:10}, 0, exec_state); |
| 899 CheckScopeContent({e:'Exception'}, 1, exec_state); | 931 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 900 }; | 932 }; |
| 901 catch_block_2(); | 933 catch_block_2(); |
| 902 EndTest(); | 934 EndTest(); |
| 903 | 935 |
| 904 | 936 |
| 905 BeginTest("Catch block 3"); | 937 BeginTest("Catch block 3"); |
| 906 function catch_block_3() { | 938 function catch_block_3() { |
| 907 // Do eval to dynamically declare a local variable so that the context's | 939 // Do eval to dynamically declare a local variable so that the context's |
| 908 // extension slot is initialized with JSContextExtensionObject. | 940 // extension slot is initialized with JSContextExtensionObject. |
| 909 eval("var y = 78;"); | 941 eval("var y = 78;"); |
| 910 try { | 942 try { |
| 911 throw 'Exception'; | 943 throw 'Exception'; |
| 912 } catch (e) { | 944 } catch (e) { |
| 913 debugger; | 945 debugger; |
| 914 } | 946 } |
| 915 }; | 947 }; |
| 916 | 948 |
| 917 | 949 |
| 918 listener_delegate = function(exec_state) { | 950 listener_delegate = function(exec_state) { |
| 919 CheckScopeChain([debug.ScopeType.Catch, | 951 CheckScopeChain([debug.ScopeType.Catch, |
| 920 debug.ScopeType.Local, | 952 debug.ScopeType.Local, |
| 953 debug.ScopeType.Script, |
| 921 debug.ScopeType.Global], exec_state); | 954 debug.ScopeType.Global], exec_state); |
| 922 CheckScopeContent({e:'Exception'}, 0, exec_state); | 955 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 923 CheckScopeContent({y:78}, 1, exec_state); | 956 CheckScopeContent({y:78}, 1, exec_state); |
| 924 }; | 957 }; |
| 925 catch_block_3(); | 958 catch_block_3(); |
| 926 EndTest(); | 959 EndTest(); |
| 927 | 960 |
| 928 | 961 |
| 929 BeginTest("Catch block 4"); | 962 BeginTest("Catch block 4"); |
| 930 function catch_block_4() { | 963 function catch_block_4() { |
| 931 // Do eval to dynamically declare a local variable so that the context's | 964 // Do eval to dynamically declare a local variable so that the context's |
| 932 // extension slot is initialized with JSContextExtensionObject. | 965 // extension slot is initialized with JSContextExtensionObject. |
| 933 eval("var y = 98;"); | 966 eval("var y = 98;"); |
| 934 try { | 967 try { |
| 935 throw 'Exception'; | 968 throw 'Exception'; |
| 936 } catch (e) { | 969 } catch (e) { |
| 937 with({n:10}) { | 970 with({n:10}) { |
| 938 debugger; | 971 debugger; |
| 939 } | 972 } |
| 940 } | 973 } |
| 941 }; | 974 }; |
| 942 | 975 |
| 943 listener_delegate = function(exec_state) { | 976 listener_delegate = function(exec_state) { |
| 944 CheckScopeChain([debug.ScopeType.With, | 977 CheckScopeChain([debug.ScopeType.With, |
| 945 debug.ScopeType.Catch, | 978 debug.ScopeType.Catch, |
| 946 debug.ScopeType.Local, | 979 debug.ScopeType.Local, |
| 980 debug.ScopeType.Script, |
| 947 debug.ScopeType.Global], exec_state); | 981 debug.ScopeType.Global], exec_state); |
| 948 CheckScopeContent({n:10}, 0, exec_state); | 982 CheckScopeContent({n:10}, 0, exec_state); |
| 949 CheckScopeContent({e:'Exception'}, 1, exec_state); | 983 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 950 CheckScopeContent({y:98}, 2, exec_state); | 984 CheckScopeContent({y:98}, 2, exec_state); |
| 951 }; | 985 }; |
| 952 catch_block_4(); | 986 catch_block_4(); |
| 953 EndTest(); | 987 EndTest(); |
| 954 | 988 |
| 955 | 989 |
| 956 // Test catch in global scope. | 990 // Test catch in global scope. |
| 957 BeginTest("Catch block 5"); | 991 BeginTest("Catch block 5"); |
| 958 listener_delegate = function(exec_state) { | 992 listener_delegate = function(exec_state) { |
| 959 CheckScopeChain([debug.ScopeType.Catch, | 993 CheckScopeChain([debug.ScopeType.Catch, |
| 994 debug.ScopeType.Script, |
| 960 debug.ScopeType.Global], exec_state); | 995 debug.ScopeType.Global], exec_state); |
| 961 CheckScopeContent({e:'Exception'}, 0, exec_state); | 996 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 962 }; | 997 }; |
| 963 | 998 |
| 964 try { | 999 try { |
| 965 throw 'Exception'; | 1000 throw 'Exception'; |
| 966 } catch (e) { | 1001 } catch (e) { |
| 967 debugger; | 1002 debugger; |
| 968 } | 1003 } |
| 969 | 1004 |
| 970 EndTest(); | 1005 EndTest(); |
| 971 | 1006 |
| 972 | 1007 |
| 973 // Closure inside catch in global code. | 1008 // Closure inside catch in global code. |
| 974 BeginTest("Catch block 6"); | 1009 BeginTest("Catch block 6"); |
| 975 listener_delegate = function(exec_state) { | 1010 listener_delegate = function(exec_state) { |
| 976 CheckScopeChain([debug.ScopeType.Local, | 1011 CheckScopeChain([debug.ScopeType.Local, |
| 977 debug.ScopeType.Catch, | 1012 debug.ScopeType.Catch, |
| 1013 debug.ScopeType.Script, |
| 978 debug.ScopeType.Global], exec_state); | 1014 debug.ScopeType.Global], exec_state); |
| 979 CheckScopeContent({x: 2}, 0, exec_state); | 1015 CheckScopeContent({x: 2}, 0, exec_state); |
| 980 CheckScopeContent({e:'Exception'}, 1, exec_state); | 1016 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 981 }; | 1017 }; |
| 982 | 1018 |
| 983 try { | 1019 try { |
| 984 throw 'Exception'; | 1020 throw 'Exception'; |
| 985 } catch (e) { | 1021 } catch (e) { |
| 986 (function(x) { | 1022 (function(x) { |
| 987 debugger; | 1023 debugger; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 998 throw 'Exception'; | 1034 throw 'Exception'; |
| 999 } catch (e) { | 1035 } catch (e) { |
| 1000 debugger; | 1036 debugger; |
| 1001 } | 1037 } |
| 1002 }; | 1038 }; |
| 1003 | 1039 |
| 1004 | 1040 |
| 1005 listener_delegate = function(exec_state) { | 1041 listener_delegate = function(exec_state) { |
| 1006 CheckScopeChain([debug.ScopeType.Catch, | 1042 CheckScopeChain([debug.ScopeType.Catch, |
| 1007 debug.ScopeType.Local, | 1043 debug.ScopeType.Local, |
| 1044 debug.ScopeType.Script, |
| 1008 debug.ScopeType.Global], exec_state); | 1045 debug.ScopeType.Global], exec_state); |
| 1009 CheckScopeContent({e:'Exception'}, 0, exec_state); | 1046 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 1010 }; | 1047 }; |
| 1011 catch_block_7(); | 1048 catch_block_7(); |
| 1012 EndTest(); | 1049 EndTest(); |
| 1013 | 1050 |
| 1014 | 1051 |
| 1015 assertEquals(begin_test_count, break_count, | 1052 assertEquals(begin_test_count, break_count, |
| 1016 'one or more tests did not enter the debugger'); | 1053 'one or more tests did not enter the debugger'); |
| 1017 assertEquals(begin_test_count, end_test_count, | 1054 assertEquals(begin_test_count, end_test_count, |
| 1018 'one or more tests did not have its result checked'); | 1055 'one or more tests did not have its result checked'); |
| OLD | NEW |