OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-async-await --expose-debug-as debug | 5 // Flags: --harmony-async-await --expose-debug-as debug |
6 | 6 |
7 var Debug = debug.Debug; | 7 var Debug = debug.Debug; |
8 | 8 |
9 async function thrower() { throw 'Exception'; } | 9 async function thrower() { throw 'Exception'; } |
10 | 10 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 assertScopeMirrorEquals(all_scopes[i], scope); | 508 assertScopeMirrorEquals(all_scopes[i], scope); |
509 | 509 |
510 // Check the global object when hitting the global scope. | 510 // Check the global object when hitting the global scope. |
511 if (scopes[i] == debug.ScopeType.Global) { | 511 if (scopes[i] == debug.ScopeType.Global) { |
512 // Objects don't have same class (one is "global", other is "Object", | 512 // Objects don't have same class (one is "global", other is "Object", |
513 // so just check the properties directly. | 513 // so just check the properties directly. |
514 assertPropertiesEqual(this, scope.scopeObject().value()); | 514 assertPropertiesEqual(this, scope.scopeObject().value()); |
515 } | 515 } |
516 } | 516 } |
517 CheckFastAllScopes(scopes, exec_state); | 517 CheckFastAllScopes(scopes, exec_state); |
518 | |
519 // Get the debug command processor. | |
520 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | |
521 | |
522 // Send a scopes request and check the result. | |
523 var json; | |
524 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; | |
525 var response_json = dcp.processDebugJSONRequest(request_json); | |
526 var response = JSON.parse(response_json); | |
527 assertEquals(scopes.length, response.body.scopes.length); | |
528 for (var i = 0; i < scopes.length; i++) { | |
529 var scopeRef = response.body.scopes[i].object.ref; | |
530 assertEquals(i, response.body.scopes[i].index); | |
531 assertEquals(scopes[i], response.body.scopes[i].type); | |
532 if (scopes[i] == debug.ScopeType.Local || | |
533 scopes[i] == debug.ScopeType.Script || | |
534 scopes[i] == debug.ScopeType.Closure) { | |
535 assertTrue(response.body.scopes[i].object.ref < 0); | |
536 } else { | |
537 assertTrue(response.body.scopes[i].object.ref >= 0); | |
538 } | |
539 var found = false; | |
540 for (var j = 0; j < response.refs.length && !found; j++) { | |
541 found = response.refs[j].handle == response.body.scopes[i].object.ref; | |
542 } | |
543 assertTrue(found, `Scope object ${scopeRef} not found`); | |
544 } | |
545 } | 518 } |
546 | 519 |
547 // Check that the content of the scope is as expected. For functions just check | 520 // Check that the content of the scope is as expected. For functions just check |
548 // that there is a function. | 521 // that there is a function. |
549 function CheckScopeContent(content, number, exec_state) { | 522 function CheckScopeContent(content, number, exec_state) { |
550 var scope = exec_state.frame().scope(number); | 523 var scope = exec_state.frame().scope(number); |
551 var count = 0; | 524 var count = 0; |
552 for (var p in content) { | 525 for (var p in content) { |
553 var property_mirror = scope.scopeObject().property(p); | 526 var property_mirror = scope.scopeObject().property(p); |
554 assertFalse(property_mirror.isUndefined(), | 527 assertFalse(property_mirror.isUndefined(), |
(...skipping 19 matching lines...) Expand all Loading... |
574 } | 547 } |
575 | 548 |
576 if (count != scope_size) { | 549 if (count != scope_size) { |
577 print('Names found in scope:'); | 550 print('Names found in scope:'); |
578 var names = scope.scopeObject().propertyNames(); | 551 var names = scope.scopeObject().propertyNames(); |
579 for (var i = 0; i < names.length; i++) { | 552 for (var i = 0; i < names.length; i++) { |
580 print(names[i]); | 553 print(names[i]); |
581 } | 554 } |
582 } | 555 } |
583 assertEquals(count, scope_size); | 556 assertEquals(count, scope_size); |
584 | |
585 // Get the debug command processor. | |
586 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | |
587 | |
588 // Send a scope request for information on a single scope and check the | |
589 // result. | |
590 var request_json = `{ | |
591 "seq": 0, | |
592 "type": "request", | |
593 "command": "scope", | |
594 "arguments": { | |
595 "number": `; | |
596 request_json += scope.scopeIndex(); | |
597 request_json += '}}'; | |
598 var response_json = dcp.processDebugJSONRequest(request_json); | |
599 var response = JSON.parse(response_json); | |
600 assertEquals(scope.scopeType(), response.body.type); | |
601 assertEquals(number, response.body.index); | |
602 if (scope.scopeType() == debug.ScopeType.Local || | |
603 scope.scopeType() == debug.ScopeType.Script || | |
604 scope.scopeType() == debug.ScopeType.Closure) { | |
605 assertTrue(response.body.object.ref < 0); | |
606 } else { | |
607 assertTrue(response.body.object.ref >= 0); | |
608 } | |
609 var found = false; | |
610 for (var i = 0; i < response.refs.length && !found; i++) { | |
611 found = response.refs[i].handle == response.body.object.ref; | |
612 } | |
613 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); | |
614 } | 557 } |
OLD | NEW |