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

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: second round of comments 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;
aandrey 2014/04/24 11:04:59 remove
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 // Ignore exceptions during startup in stress runs.
28 if (step > 1) return;
29 assertEquals(["resolve", "end main", "throw"], log);
30 if (event == Debug.DebugEvent.Exception) {
31 assertEquals(0, step);
32 exception = event_data.exception();
33 assertEquals(undefined, event_data.promise());
34 } else if (event == Debug.DebugEvent.PendingExceptionInPromise) {
35 assertEquals(1, step);
36 assertEquals(exception, event_data.exception());
37 assertEquals("uncaught", exception.message);
38 assertTrue(event_data.promise() instanceof Promise);
39 assertTrue(event_data.uncaught());
40 } else {
41 return;
42 }
43 step++;
44 } catch (e) {
45 // Signal a failure with exit code 1. This is necessary since the
46 // debugger swallows exceptions and we expect the chained function
47 // and this listener to be executed after the main script is finished.
48 print("Unexpected exception: " + e + "\n" + e.stack);
49 quit(1);
50 }
51 }
52
53 Debug.setBreakOnException();
54 Debug.setListener(listener);
55
56 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