OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 }; | 83 }; |
84 } | 84 } |
85 | 85 |
86 function WrapInNativeCall(f) { | 86 function WrapInNativeCall(f) { |
87 return function() { | 87 return function() { |
88 return %Call(f, undefined); | 88 return %Call(f, undefined); |
89 }; | 89 }; |
90 } | 90 } |
91 | 91 |
| 92 function ExecuteInDebugContext(f) { |
| 93 var result; |
| 94 var exception = null; |
| 95 Debug.setListener(function(event) { |
| 96 if (event == Debug.DebugEvent.Break) { |
| 97 try { |
| 98 result = f(); |
| 99 } catch (e) { |
| 100 // Rethrow this exception later. |
| 101 exception = e; |
| 102 } |
| 103 } |
| 104 }); |
| 105 debugger; |
| 106 Debug.setListener(null); |
| 107 if (exception !== null) throw exception; |
| 108 return result; |
| 109 } |
| 110 |
92 function WrapInDebuggerCall(f) { | 111 function WrapInDebuggerCall(f) { |
93 return function() { | 112 return function() { |
94 return %ExecuteInDebugContext(f); | 113 return ExecuteInDebugContext(f); |
95 }; | 114 }; |
96 } | 115 } |
97 | 116 |
98 function WrapInRestartProof(f) { | 117 function WrapInRestartProof(f) { |
99 var already_called = false; | 118 var already_called = false; |
100 return function() { | 119 return function() { |
101 if (already_called) { | 120 if (already_called) { |
102 return; | 121 return; |
103 } | 122 } |
104 already_called = true; | 123 already_called = true; |
(...skipping 24 matching lines...) Expand all Loading... |
129 assertEquals("Capybara", test.ChooseAnimal(WrapInDebuggerCall(WrapInRestartProof
(test.ScriptChanger)))); | 148 assertEquals("Capybara", test.ChooseAnimal(WrapInDebuggerCall(WrapInRestartProof
(test.ScriptChanger)))); |
130 | 149 |
131 | 150 |
132 test = new TestBase("Test with function on stack and with constructor frame"); | 151 test = new TestBase("Test with function on stack and with constructor frame"); |
133 assertEquals("Capybara", test.ChooseAnimal(WrapInConstructor(WrapInDebuggerCall(
WrapInRestartProof(test.ScriptChanger))))); | 152 assertEquals("Capybara", test.ChooseAnimal(WrapInConstructor(WrapInDebuggerCall(
WrapInRestartProof(test.ScriptChanger))))); |
134 | 153 |
135 test = new TestBase("Test with C++ frame above ChooseAnimal frame"); | 154 test = new TestBase("Test with C++ frame above ChooseAnimal frame"); |
136 exception_holder = {}; | 155 exception_holder = {}; |
137 assertEquals("Cat", test.ChooseAnimal(WrapInNativeCall(WrapInDebuggerCall(WrapIn
Catcher(test.ScriptChanger, exception_holder))))); | 156 assertEquals("Cat", test.ChooseAnimal(WrapInNativeCall(WrapInDebuggerCall(WrapIn
Catcher(test.ScriptChanger, exception_holder))))); |
138 assertTrue(!!exception_holder[0]); | 157 assertTrue(!!exception_holder[0]); |
OLD | NEW |