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

Unified Diff: test/debugger/debugger/debug-step-4.js

Issue 2447073007: [debugger] Various break-related functionality in test wrapper (Closed)
Patch Set: Move DebugEvent to DebugWrapper to preserve old API Created 4 years, 2 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 | « test/debugger/debugger/debug-step-3.js ('k') | test/debugger/test-api.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/debugger/debugger/debug-step-4.js
diff --git a/test/debugger/debugger/debug-step-4.js b/test/debugger/debugger/debug-step-4.js
new file mode 100644
index 0000000000000000000000000000000000000000..95afacac2ec8efaf3a572e98f0dc1a221f726860
--- /dev/null
+++ b/test/debugger/debugger/debug-step-4.js
@@ -0,0 +1,80 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+const Debug = new DebugWrapper();
+Debug.enable();
+
+// Tests how debugger can step over not necessarily in the top frame.
+
+// Simple 3 functions, that protocol their execution state in global
+// variable state.
+var state;
+
+function f() {
+ var a = 1978;
+ for (state[2] = 0; state[2] < 3; state[2]++) {
+ void String(a);
+ }
+}
+function g() {
+ for (state[1] = 0; state[1] < 3; state[1]++) {
+ f();
+ }
+}
+function h() {
+ state = [-1, -1, -1];
+ for (state[0] = 0; state[0] < 3; state[0]++) {
+ g();
+ }
+}
+
+function TestCase(expected_final_state) {
+ var listener_exception = null;
+ var state_snapshot;
+ var listener_state;
+ var bp;
+
+ function listener(event, exec_state, event_data, data) {
+ const location = exec_state.frames[0].location
+ print("Here (" + event + "/" + listener_state + "): " +
+ location.lineNumber + ":" + location.columnNumber);
+ try {
+ if (event == Debug.DebugEvent.Break) {
+ if (listener_state == 0) {
+ Debug.clearBreakPoint(bp);
+ Debug.stepOver();
+ listener_state = 1;
+ } else if (listener_state == 1) {
+ state_snapshot = String(state);
+ print("State: " + state_snapshot);
+ Debug.setListener(null);
+ listener_state = 2;
+ }
+ }
+ } catch (e) {
+ listener_exception = e;
+ }
+ }
+
+
+ // Add the debug event listener.
+ listener_state = 0;
+ Debug.setListener(listener);
+ bp = Debug.setBreakPoint(f, 1);
+
+ h();
+ Debug.setListener(null);
+ if (listener_exception !== null) {
+ print("Exception caught: " + listener_exception);
+ assertUnreachable();
+ }
+
+ assertEquals(expected_final_state, state_snapshot);
+}
+
+
+// Warm-up -- make sure all is compiled and ready for breakpoint.
+h();
+
+TestCase("0,0,-1");
« no previous file with comments | « test/debugger/debugger/debug-step-3.js ('k') | test/debugger/test-api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698