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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 listener_delegate = null; | 64 listener_delegate = null; |
65 listener_called = false; | 65 listener_called = false; |
66 exception = null; | 66 exception = null; |
67 begin_test_count++; | 67 begin_test_count++; |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 // Check result of a test. | 71 // Check result of a test. |
72 function EndTest() { | 72 function EndTest() { |
73 assertTrue(listener_called, "listerner not called for " + test_name); | 73 assertTrue(listener_called, "listerner not called for " + test_name); |
74 assertNull(exception, test_name); | 74 assertNull(exception, test_name + " / " + exception); |
75 end_test_count++; | 75 end_test_count++; |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 // Check that two scope are the same. | 79 // Check that two scope are the same. |
80 function CheckScopeMirrors(scope1, scope2) { | 80 function assertScopeMirrorEquals(scope1, scope2) { |
81 assertEquals(scope1.scopeType(), scope2.scopeType()); | 81 assertEquals(scope1.scopeType(), scope2.scopeType()); |
82 assertEquals(scope1.frameIndex(), scope2.frameIndex()); | 82 assertEquals(scope1.frameIndex(), scope2.frameIndex()); |
83 assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); | 83 assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); |
| 84 assertPropertiesEqual(scope1.scopeObject().value(), scope2.scopeObject().value
()); |
| 85 } |
| 86 |
| 87 function CheckFastAllScopes(scopes, exec_state) |
| 88 { |
| 89 var fast_all_scopes = exec_state.frame().allScopes(true); |
| 90 var length = fast_all_scopes.length; |
| 91 assertTrue(scopes.length >= length); |
| 92 for (var i = 0; i < scopes.length && i < length; i++) { |
| 93 var scope = fast_all_scopes[length - i - 1]; |
| 94 assertTrue(scope.isScope()); |
| 95 var index = scopes.length - i - 1; |
| 96 assertEquals(scope.scopeType(), scopes[index]); |
| 97 scope.scope_index_ = index; // to pass the following assert |
| 98 assertScopeMirrorEquals(scope, exec_state.frame().scope(index)); |
| 99 } |
84 } | 100 } |
85 | 101 |
86 | 102 |
87 // Check that the scope chain contains the expected types of scopes. | 103 // Check that the scope chain contains the expected types of scopes. |
88 function CheckScopeChain(scopes, exec_state) { | 104 function CheckScopeChain(scopes, exec_state) { |
89 var all_scopes = exec_state.frame().allScopes(); | 105 var all_scopes = exec_state.frame().allScopes(); |
90 assertEquals(scopes.length, exec_state.frame().scopeCount()); | 106 assertEquals(scopes.length, exec_state.frame().scopeCount()); |
91 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; | 107 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; |
92 for (var i = 0; i < scopes.length; i++) { | 108 for (var i = 0; i < scopes.length; i++) { |
93 var scope = exec_state.frame().scope(i); | 109 var scope = exec_state.frame().scope(i); |
94 assertTrue(scope.isScope()); | 110 assertTrue(scope.isScope()); |
95 assertEquals(scopes[i], scope.scopeType()); | 111 assertEquals(scopes[i], scope.scopeType()); |
96 CheckScopeMirrors(all_scopes[i], scope); | 112 assertScopeMirrorEquals(all_scopes[i], scope); |
97 | 113 |
98 // Check the global object when hitting the global scope. | 114 // Check the global object when hitting the global scope. |
99 if (scopes[i] == debug.ScopeType.Global) { | 115 if (scopes[i] == debug.ScopeType.Global) { |
100 // Objects don't have same class (one is "global", other is "Object", | 116 // Objects don't have same class (one is "global", other is "Object", |
101 // so just check the properties directly. | 117 // so just check the properties directly. |
102 assertPropertiesEqual(this, scope.scopeObject().value()); | 118 assertPropertiesEqual(this, scope.scopeObject().value()); |
103 } | 119 } |
104 } | 120 } |
| 121 CheckFastAllScopes(scopes, exec_state); |
105 | 122 |
106 // Get the debug command processor. | 123 // Get the debug command processor. |
107 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | 124 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
108 | 125 |
109 // Send a scopes request and check the result. | 126 // Send a scopes request and check the result. |
110 var json; | 127 var json; |
111 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; | 128 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; |
112 var response_json = dcp.processDebugJSONRequest(request_json); | 129 var response_json = dcp.processDebugJSONRequest(request_json); |
113 var response = JSON.parse(response_json); | 130 var response = JSON.parse(response_json); |
114 assertEquals(scopes.length, response.body.scopes.length); | 131 assertEquals(scopes.length, response.body.scopes.length); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 CheckScopeContent({e:'Exception'}, 0, exec_state); | 1016 CheckScopeContent({e:'Exception'}, 0, exec_state); |
1000 }; | 1017 }; |
1001 catch_block_7(); | 1018 catch_block_7(); |
1002 EndTest(); | 1019 EndTest(); |
1003 | 1020 |
1004 | 1021 |
1005 assertEquals(begin_test_count, break_count, | 1022 assertEquals(begin_test_count, break_count, |
1006 'one or more tests did not enter the debugger'); | 1023 'one or more tests did not enter the debugger'); |
1007 assertEquals(begin_test_count, end_test_count, | 1024 assertEquals(begin_test_count, end_test_count, |
1008 'one or more tests did not have its result checked'); | 1025 'one or more tests did not have its result checked'); |
OLD | NEW |