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

Side by Side Diff: test/mjsunit/es6/debug-stepin-promises.js

Issue 734163002: Allow stepping into Promise handlers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed Created 6 years, 1 month 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 unified diff | Download patch
« src/debug.cc ('K') | « src/promise.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax --expose-debug-as debug
6
7 Debug = debug.Debug
8 var exception = null;
9 var break_count = 0;
arv (Not doing code reviews) 2014/11/18 18:51:08 no underscores in js
10 var expected_breaks = 7;
11
12 function listener(event, exec_state, event_data, data) {
13 try {
14 if (event == Debug.DebugEvent.Break) {
15 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace");
16 var source = exec_state.frame(0).sourceLineText();
17 print("paused at: " + source);
18 assertTrue(source.indexOf("// Break " + break_count + ".") > 0,
19 "Unexpected pause at: " + source);
20 if (source.indexOf("StepOver.") !== -1) {
21 exec_state.prepareStep(Debug.StepAction.StepNext, 1);
22 } else {
23 exec_state.prepareStep(Debug.StepAction.StepIn, 1);
24 }
25 ++break_count;
26 } else if (event == Debug.DebugEvent.AsyncTaskEvent &&
27 event_data.type() === "willHandle" &&
28 event_data.name() !== "Object.observe" &&
29 break_count > 0) {
30 exec_state.prepareStep(Debug.StepAction.StepIn, 1);
31 }
32 } catch (e) {
33 exception = e;
34 print(e, e.stack);
35 }
36 };
37
38 Debug.setListener(listener);
39
40 Promise.resolve(42)
41 .then(promise1)
42 .then(Object) // Should skip stepping into native.
43 .then(Boolean) // Should skip stepping into native.
44 .then(promise2)
45 .then(undefined, promise3)
arv (Not doing code reviews) 2014/11/18 18:51:08 or .catch(promise3)
46 .catch(function(e) {
47 %AbortJS("FAIL: uncaught exception " + e);
48 });
49
50 function promise1()
51 {
arv (Not doing code reviews) 2014/11/18 18:51:08 { on previous line
aandrey 2014/11/19 11:41:27 Addressed in https://codereview.chromium.org/73952
52 debugger; // Break 0.
53 return exception || 1; // Break 1.
54 } // Break 2.
55
56 function promise2()
57 {
58 throw new Error; // Break 3.
59 }
60
61 function promise3()
62 {
63 finalize(); // Break 4. StepOver.
64 return break_count; // Break 5.
65 } // Break 6.
66
67 function finalize()
68 {
69 var dummy = {};
70 Object.observe(dummy, function() {
71 if (expected_breaks !== break_count) {
72 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" +
73 break_count + ">");
74 }
75 if (exception !== null) {
76 %AbortJS("FAIL: exception: " + exception);
77 }
78 });
79 dummy.foo = 1;
80 }
OLDNEW
« src/debug.cc ('K') | « src/promise.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698