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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 testRequest(dcp, '{"expression":"({\\"a\\":1,\\"b\\":2}).b+2"}', true, 4); | 80 testRequest(dcp, '{"expression":"({\\"a\\":1,\\"b\\":2}).b+2"}', true, 4); |
81 | 81 |
82 // Test evaluation of a in the stack frames and the global context. | 82 // Test evaluation of a in the stack frames and the global context. |
83 testRequest(dcp, '{"expression":"a"}', true, 3); | 83 testRequest(dcp, '{"expression":"a"}', true, 3); |
84 testRequest(dcp, '{"expression":"a","frame":0}', true, 3); | 84 testRequest(dcp, '{"expression":"a","frame":0}', true, 3); |
85 testRequest(dcp, '{"expression":"a","frame":1}', true, 2); | 85 testRequest(dcp, '{"expression":"a","frame":1}', true, 2); |
86 testRequest(dcp, '{"expression":"a","frame":2}', true, 1); | 86 testRequest(dcp, '{"expression":"a","frame":2}', true, 1); |
87 testRequest(dcp, '{"expression":"a","global":true}', true, 1); | 87 testRequest(dcp, '{"expression":"a","global":true}', true, 1); |
88 testRequest(dcp, '{"expression":"this.a","global":true}', true, 1); | 88 testRequest(dcp, '{"expression":"this.a","global":true}', true, 1); |
89 | 89 |
| 90 // Test that the whole string text is returned if maxStringLength |
| 91 // parameter is passed. |
| 92 testRequest( |
| 93 dcp, |
| 94 '{"expression":"this.longString","global":true,maxStringLength:-1}', |
| 95 true, |
| 96 longString); |
| 97 testRequest( |
| 98 dcp, |
| 99 '{"expression":"this.longString","global":true,maxStringLength:' + |
| 100 longString.length + '}', |
| 101 true, |
| 102 longString); |
| 103 var truncatedStringSuffix = '... (length: ' + longString.length + ')'; |
| 104 testRequest( |
| 105 dcp, |
| 106 '{"expression":"this.longString","global":true,maxStringLength:0}', |
| 107 true, |
| 108 truncatedStringSuffix); |
| 109 testRequest( |
| 110 dcp, |
| 111 '{"expression":"this.longString","global":true,maxStringLength:1}', |
| 112 true, |
| 113 longString.charAt(0) + truncatedStringSuffix); |
| 114 // Test that by default string is truncated to first 80 chars. |
| 115 testRequest( |
| 116 dcp, |
| 117 '{"expression":"this.longString","global":true}', |
| 118 true, |
| 119 longString.substring(0, 80) + truncatedStringSuffix); |
| 120 |
90 // Indicate that all was processed. | 121 // Indicate that all was processed. |
91 listenerComplete = true; | 122 listenerComplete = true; |
92 } | 123 } |
93 } catch (e) { | 124 } catch (e) { |
94 exception = e | 125 exception = e |
95 }; | 126 }; |
96 }; | 127 }; |
97 | 128 |
98 // Add the debug event listener. | 129 // Add the debug event listener. |
99 Debug.setListener(listener); | 130 Debug.setListener(listener); |
100 | 131 |
101 function f() { | 132 function f() { |
102 var a = 3; | 133 var a = 3; |
103 }; | 134 }; |
104 | 135 |
105 function g() { | 136 function g() { |
106 var a = 2; | 137 var a = 2; |
107 f(); | 138 f(); |
108 }; | 139 }; |
109 | 140 |
110 a = 1; | 141 a = 1; |
111 | 142 |
| 143 // String which is longer than 80 chars. |
| 144 var longString = "1234567890_"; |
| 145 for (var i = 0; i < 4; i++) { |
| 146 longString += longString; |
| 147 } |
| 148 |
112 // Set a break point at return in f and invoke g to hit the breakpoint. | 149 // Set a break point at return in f and invoke g to hit the breakpoint. |
113 Debug.setBreakPoint(f, 2, 0); | 150 Debug.setBreakPoint(f, 2, 0); |
114 g(); | 151 g(); |
115 | 152 |
116 assertFalse(exception, "exception in listener") | 153 assertFalse(exception, "exception in listener") |
117 // Make sure that the debug event listener vas invoked. | 154 // Make sure that the debug event listener vas invoked. |
118 assertTrue(listenerComplete, "listener did not run to completion"); | 155 assertTrue(listenerComplete, "listener did not run to completion"); |
OLD | NEW |