Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: test/debugger/debug/harmony/async-function-debug-scopes.js

Issue 2566093002: [debug-wrapper] migrate some scope related tests (Closed)
Patch Set: address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
6 6
7 var Debug = debug.Debug; 7 var Debug = debug.Debug;
8 var global_marker = 7;
8 9
9 async function thrower() { throw 'Exception'; } 10 async function thrower() { throw 'Exception'; }
10 11
11 async function test(name, func, args, handler, continuation) { 12 async function test(name, func, args, handler, continuation) {
12 var handler_called = false; 13 var handler_called = false;
13 var exception = null; 14 var exception = null;
14 15
15 function listener(event, exec_state, event_data, data) { 16 function listener(event, exec_state, event_data, data) {
16 try { 17 try {
17 if (event == Debug.DebugEvent.Break) { 18 if (event == Debug.DebugEvent.Break) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 assertPropertiesEqual( 485 assertPropertiesEqual(
485 scope1.scopeObject().value(), scope2.scopeObject().value()); 486 scope1.scopeObject().value(), scope2.scopeObject().value());
486 } 487 }
487 488
488 function CheckFastAllScopes(scopes, exec_state) { 489 function CheckFastAllScopes(scopes, exec_state) {
489 var fast_all_scopes = exec_state.frame().allScopes(true); 490 var fast_all_scopes = exec_state.frame().allScopes(true);
490 var length = fast_all_scopes.length; 491 var length = fast_all_scopes.length;
491 assertTrue(scopes.length >= length); 492 assertTrue(scopes.length >= length);
492 for (var i = 0; i < scopes.length && i < length; i++) { 493 for (var i = 0; i < scopes.length && i < length; i++) {
493 var scope = fast_all_scopes[length - i - 1]; 494 var scope = fast_all_scopes[length - i - 1];
494 assertTrue(scope.isScope());
495 assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); 495 assertEquals(scopes[scopes.length - i - 1], scope.scopeType());
496 } 496 }
497 } 497 }
498 498
499 // Check that the scope chain contains the expected types of scopes. 499 // Check that the scope chain contains the expected types of scopes.
500 function CheckScopeChain(scopes, exec_state) { 500 function CheckScopeChain(scopes, exec_state) {
501 var all_scopes = exec_state.frame().allScopes(); 501 var all_scopes = exec_state.frame().allScopes();
502 assertEquals( 502 assertEquals(
503 scopes.length, all_scopes.length, "FrameMirror.allScopes length"); 503 scopes.length, all_scopes.length, "FrameMirror.allScopes length");
504 for (var i = 0; i < scopes.length; i++) { 504 for (var i = 0; i < scopes.length; i++) {
505 var scope = exec_state.frame().scope(i); 505 var scope = exec_state.frame().scope(i);
506 assertTrue(scope.isScope());
507 assertEquals(scopes[i], scope.scopeType()); 506 assertEquals(scopes[i], scope.scopeType());
508 assertScopeMirrorEquals(all_scopes[i], scope); 507 assertScopeMirrorEquals(all_scopes[i], scope);
509 508
510 // Check the global object when hitting the global scope. 509 // Check the global object when hitting the global scope.
511 if (scopes[i] == debug.ScopeType.Global) { 510 if (scopes[i] == debug.ScopeType.Global) {
512 // Objects don't have same class (one is "global", other is "Object", 511 assertEquals(global_marker, scope.scopeObject().value().global_marker);
513 // so just check the properties directly.
514 assertPropertiesEqual(this, scope.scopeObject().value());
515 } 512 }
516 } 513 }
517 CheckFastAllScopes(scopes, exec_state); 514 CheckFastAllScopes(scopes, exec_state);
518 } 515 }
519 516
520 // Check that the content of the scope is as expected. For functions just check 517 // Check that the content of the scope is as expected. For functions just check
521 // that there is a function. 518 // that there is a function.
522 function CheckScopeContent(content, number, exec_state) { 519 function CheckScopeContent(content, number, exec_state) {
523 var scope = exec_state.frame().scope(number); 520 var scope = exec_state.frame().scope(number);
524 var count = 0; 521 var count = 0;
525 for (var p in content) { 522 for (var p in content) {
526 var property_mirror = scope.scopeObject().property(p); 523 var property_mirror = scope.scopeObject().property(p);
527 assertFalse(property_mirror.isUndefined(), 524 assertFalse(property_mirror.isUndefined(),
528 `property ${p} not found in scope`); 525 `property ${p} not found in scope`);
529 if (typeof(content[p]) === 'function') { 526 assertEquals(content[p], property_mirror.value().value(),
530 assertTrue(property_mirror.value().isFunction()); 527 `property ${p} has unexpected value`);
531 } else {
532 assertEquals(content[p], property_mirror.value().value(),
533 `property ${p} has unexpected value`);
534 }
535 count++; 528 count++;
536 } 529 }
537 530
538 // 'arguments' and might be exposed in the local and closure scope. Just 531 // 'arguments' and might be exposed in the local and closure scope. Just
539 // ignore this. 532 // ignore this.
540 var scope_size = scope.scopeObject().properties().length; 533 var scope_size = scope.scopeObject().properties().length;
541 if (!scope.scopeObject().property('arguments').isUndefined()) { 534 if (!scope.scopeObject().property('arguments').isUndefined()) {
542 scope_size--; 535 scope_size--;
543 } 536 }
544 // Skip property with empty name. 537 // Skip property with empty name.
545 if (!scope.scopeObject().property('').isUndefined()) { 538 if (!scope.scopeObject().property('').isUndefined()) {
546 scope_size--; 539 scope_size--;
547 } 540 }
548 541
549 if (count != scope_size) { 542 if (scope_size < count) {
550 print('Names found in scope:'); 543 print('Names found in scope:');
551 var names = scope.scopeObject().propertyNames(); 544 var names = scope.scopeObject().propertyNames();
552 for (var i = 0; i < names.length; i++) { 545 for (var i = 0; i < names.length; i++) {
553 print(names[i]); 546 print(names[i]);
554 } 547 }
555 } 548 }
556 assertEquals(count, scope_size); 549 assertTrue(scope_size >= count);
557 } 550 }
OLDNEW
« no previous file with comments | « test/debugger/debug/es6/generators-debug-scopes.js ('k') | test/debugger/debug/ignition/debug-step-prefix-bytecodes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698