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

Side by Side Diff: test/mjsunit/es6/debug-promises-uncaught.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: 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 Debug = debug.Debug;
8
9 var resolve_fun;
10 var log = [];
11 var step = 0;
12 var exception = undefined;
13
14 var p = new Promise(function(resolve, reject) {
15 log.push("resolve");
16 resolve();
17 });
18
19 var q = p.chain(
20 function() {
21 log.push("throw");
22 throw new Error("uncaught");
23 });
24
25 function listener(event, exec_state, event_data, data) {
26 try {
27 assertEquals(["resolve", "end main", "throw"], log);
28 if (event == Debug.DebugEvent.Exception) {
29 assertEquals(0, step);
30 exception = event_data.exception();
31 assertEquals(undefined, event_data.deferred_promise());
32 } else if (event == Debug.DebugEvent.PendingExceptionInPromise) {
33 assertEquals(1, step);
34 assertEquals(exception, event_data.exception());
35 assertEquals("uncaught", exception.message);
36 assertEquals('object', typeof event_data.deferred_promise());
rossberg 2014/04/24 07:27:36 You could more specifically test 'event_data.promi
37 } else {
38 assertUnreachable();
39 }
40 step++;
41 } catch (e) {
42 // Signal a failure with exit code 1. This is necessary since the
43 // debugger swallows exceptions and we expect the chained function
44 // and this listener to be executed after the main script is finished.
45 print(e + "\n" + e.stack);
rossberg 2014/04/24 07:27:36 Maybe add "Unexpected exception: ".
46 quit(1);
47 }
48 }
49
50 Debug.setBreakOnException();
51 Debug.setListener(listener);
52
53 log.push("end main");
OLDNEW
« test/mjsunit/es6/debug-promises-caught.js ('K') | « test/mjsunit/es6/debug-promises-caught.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698