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

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

Issue 440773004: Trigger exception debug events on Promise reject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 6 years, 4 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: --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 throws a new exception in its reject
9 // handler. We expect an Exception debug event with a promise 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 = function() {
23 log.push("throw reject");
24 throw new Error("reject"); // event
25 };
26 var resolve = function() { };
27 log.push("construct");
28 resolver(resolve, reject);
29 };
30
31 MyPromise.prototype = p;
32 p.constructor = MyPromise;
33
34 var q = p.chain(
35 function() {
36 log.push("throw caught");
37 throw new Error("caught");
38 });
39
40 function listener(event, exec_state, event_data, data) {
41 try {
42 if (event == Debug.DebugEvent.Exception) {
43 assertEquals(["resolve", "construct", "end main",
44 "throw caught", "throw reject"], log);
45 assertEquals("reject", event_data.exception().message);
46 assertEquals(q, event_data.promise());
47 assertTrue(exec_state.frame(0).sourceLineText().indexOf('// event') > 0);
48 }
49 } catch (e) {
50 // Signal a failure with exit code 1. This is necessary since the
51 // debugger swallows exceptions and we expect the chained function
52 // and this listener to be executed after the main script is finished.
53 print("Unexpected exception: " + e + "\n" + e.stack);
54 quit(1);
55 }
56 }
57
58 Debug.setBreakOnUncaughtException();
59 Debug.setListener(listener);
60
61 log.push("end main");
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises-throw-in-constructor.js ('k') | test/mjsunit/es6/debug-promises-uncaught-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698