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

Side by Side Diff: test/mjsunit/es6/debug-promises-uncaught-all.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 we listen to all exceptions and
8 // there is a catch handler for the exception thrown in a Promise.
9 // Expectation:
10 // - the normal Exception debug event is triggered.
11 // - the PendingExceptionInPromise debug event is triggered afterwards,
12 // with the same exception object.
13
14 Debug = debug.Debug;
15
16 var log = [];
17 var step = 0;
18 var exception = undefined;
19
20 var p = new Promise(function(resolve, reject) {
21 log.push("resolve");
22 resolve();
23 });
24
25 var q = p.chain(
26 function() {
27 log.push("throw");
28 throw new Error("uncaught");
29 });
30
31 function listener(event, exec_state, event_data, data) {
32 try {
33 // Ignore exceptions during startup in stress runs.
34 if (step > 1) return;
35 assertEquals(["resolve", "end main", "throw"], log);
36 if (event == Debug.DebugEvent.Exception) {
37 assertEquals(0, step);
38 exception = event_data.exception();
39 assertEquals(undefined, event_data.promise());
40 } else if (event == Debug.DebugEvent.PendingExceptionInPromise) {
41 assertEquals(1, step);
42 assertEquals(exception, event_data.exception());
43 assertEquals("uncaught", exception.message);
44 assertTrue(event_data.promise() instanceof Promise);
45 assertTrue(event_data.uncaught());
46 } else {
47 return;
48 }
49 step++;
50 } catch (e) {
51 // Signal a failure with exit code 1. This is necessary since the
52 // debugger swallows exceptions and we expect the chained function
53 // and this listener to be executed after the main script is finished.
54 print("Unexpected exception: " + e + "\n" + e.stack);
55 quit(1);
56 }
57 }
58
59 Debug.setBreakOnException();
60 Debug.setListener(listener);
61
62 log.push("end main");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698