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

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

Issue 249503002: Trigger debug event on not yet caught exception in promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: always use original exception Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
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: --harmony-promises --expose-debug-as debug
6
7 // Test debug events when an exception is thrown inside a Promise, which is
8 // caught by a custom promise, which has no reject handler.
9 // We expect a PendingExceptionInPromise event to be triggered.
10
11 Debug = debug.Debug;
12
13 var log = [];
14 var step = 0;
15
16 var p = new Promise(function(resolve, reject) {
17 log.push("resolve");
18 resolve();
19 });
20
21 function MyPromise(resolver) {
22 var reject = undefined;
23 var resolve = function() { };
24 log.push("construct");
25 resolver(resolve, reject);
26 };
27
28 MyPromise.prototype = p;
29 p.constructor = MyPromise;
30
31 var q = p.chain(
32 function() {
33 log.push("throw caught");
34 throw new Error("caught");
35 });
36
37 function listener(event, exec_state, event_data, data) {
38 try {
39 if (event == Debug.DebugEvent.PendingExceptionInPromise) {
40 assertEquals(["resolve", "construct", "end main", "throw caught"], log);
41 assertEquals("caught", event_data.exception().message);
42 } else if (event == Debug.DebugEvent.Exception) {
43 assertUnreachable();
44 }
45 } catch (e) {
46 // Signal a failure with exit code 1. This is necessary since the
47 // debugger swallows exceptions and we expect the chained function
48 // and this listener to be executed after the main script is finished.
49 print("Unexpected exception: " + e + "\n" + e.stack);
50 quit(1);
51 }
52 }
53
54 Debug.setBreakOnUncaughtException();
55 Debug.setListener(listener);
56
57 log.push("end main");
OLDNEW
« src/debug-debugger.js ('K') | « test/mjsunit/es6/debug-promises-uncaught-uncaught.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698