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

Unified Diff: test/cctest/test-debug.cc

Issue 10695173: Merged r12019 into 3.11 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.11
Patch Set: Created 8 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index e40f406c3c5f869743cb13e2f0d75b4afb95b480..166b762913f440527a29489dc27ce7e500d46c12 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7350,4 +7350,47 @@ TEST(DebugBreakInline) {
}
+static void DebugEventStepNext(v8::DebugEvent event,
+ v8::Handle<v8::Object> exec_state,
+ v8::Handle<v8::Object> event_data,
+ v8::Handle<v8::Value> data) {
+ if (event == v8::Break) {
+ PrepareStep(StepNext);
+ }
+}
+
+
+static void RunScriptInANewCFrame(const char* source) {
+ v8::TryCatch try_catch;
+ CompileRun(source);
+ CHECK(try_catch.HasCaught());
+}
+
+
+TEST(Regress131642) {
+ // Bug description:
+ // When doing StepNext through the first script, the debugger is not reset
+ // after exiting through exception. A flawed implementation enabling the
+ // debugger to step into Array.prototype.forEach breaks inside the callback
+ // for forEach in the second script under the assumption that we are in a
+ // recursive call. In an attempt to step out, we crawl the stack using the
+ // recorded frame pointer from the first script and fail when not finding it
+ // on the stack.
+ v8::HandleScope scope;
+ DebugLocalContext env;
+ v8::Debug::SetDebugEventListener(DebugEventStepNext);
+
+ // We step through the first script. It exits through an exception. We run
+ // this inside a new frame to record a different FP than the second script
+ // would expect.
+ const char* script_1 = "debugger; throw new Error();";
+ RunScriptInANewCFrame(script_1);
+
+ // The second script uses forEach.
+ const char* script_2 = "[0].forEach(function() { });";
+ CompileRun(script_2);
+
+ v8::Debug::SetDebugEventListener(NULL);
+}
+
#endif // ENABLE_DEBUGGER_SUPPORT
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698