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

Side by Side Diff: test/mjsunit/es6/debug-promises/reject-uncaught-late.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 --allow-natives-syntax
6
7 // Test debug events when we only listen to uncaught exceptions and
8 // there is a catch handler for the to-be-rejected Promise.
9 // We expect an Exception debug event with a promise to be triggered.
10
11 Debug = debug.Debug;
12
13 var expected_events = 1;
14 var log = [];
15
16 var reject_closure;
17
18 var p = new Promise(function(resolve, reject) {
19 log.push("postpone p");
20 reject_closure = reject;
21 });
22
23 var q = new Promise(function(resolve, reject) {
24 log.push("resolve q");
25 resolve();
26 });
27
28 q.then(function() {
29 log.push("reject p");
30 reject_closure(new Error("uncaught reject p")); // event
31 })
32
33
34 function listener(event, exec_state, event_data, data) {
35 try {
36 if (event == Debug.DebugEvent.Exception) {
37 expected_events--;
38 assertTrue(expected_events >= 0);
39 assertEquals("uncaught reject p", event_data.exception().message);
40 assertTrue(event_data.promise() instanceof Promise);
41 assertEquals(p, event_data.promise());
42 assertTrue(event_data.uncaught());
43 // Assert that the debug event is triggered at the throw site.
44 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
45 }
46 } catch (e) {
47 %AbortJS(e + "\n" + e.stack);
48 }
49 }
50
51 Debug.setBreakOnUncaughtException();
52 Debug.setListener(listener);
53
54 log.push("end main");
55
56 function testDone(iteration) {
57 function checkResult() {
58 try {
59 assertTrue(iteration < 10);
60 if (expected_events === 0) {
61 assertEquals(["postpone p", "resolve q", "end main", "reject p"], log);
62 } else {
63 testDone(iteration + 1);
64 }
65 } catch (e) {
66 %AbortJS(e + "\n" + e.stack);
67 }
68 }
69
70 // Run testDone through the Object.observe processing loop.
71 var dummy = {};
72 Object.observe(dummy, checkResult);
73 dummy.dummy = dummy;
74 }
75
76 testDone(0);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises/reject-uncaught-all.js ('k') | test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698