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

Side by Side Diff: test/mjsunit/es6/reject-caught-by-default-reject-handler.js

Issue 461233003: Fix test expectations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 = 2;
14 var log = [];
15
16 var resolve, reject;
17 var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; });
18 var p1 = p0.then(function() {
19 log.push("p0.then");
20 return Promise.reject(new Error("123"));
21 });
22 var p2 = p1.then(function() {
23 log.push("p1.then");
24 });
25
26 var q = new Promise(function(res, rej) {
27 log.push("resolve q");
28 res();
29 });
30
31 q.then(function() {
32 log.push("resolve p");
33 resolve();
34 })
35
36
37 function listener(event, exec_state, event_data, data) {
38 try {
39 if (event == Debug.DebugEvent.Exception) {
40 expected_events--;
41 assertTrue(expected_events >= 0);
42 assertTrue(event_data.uncaught());
43 assertTrue(event_data.promise() instanceof Promise);
44 if (expected_events == 1) {
45 // p1 is rejected, uncaught except for its default reject handler.
46 assertEquals(0, exec_state.frameCount());
47 assertSame(p1, event_data.promise());
48 } else {
49 // p2 is rejected by p1's default reject handler.
50 assertEquals(0, exec_state.frameCount());
51 assertSame(p2, event_data.promise());
52 }
53 }
54 } catch (e) {
55 %AbortJS(e + "\n" + e.stack);
56 }
57 }
58
59 Debug.setBreakOnUncaughtException();
60 Debug.setListener(listener);
61
62 log.push("end main");
63
64 function testDone(iteration) {
65 function checkResult() {
66 try {
67 assertTrue(iteration < 10);
68 if (expected_events === 0) {
69 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log);
70 } else {
71 testDone(iteration + 1);
72 }
73 } catch (e) {
74 %AbortJS(e + "\n" + e.stack);
75 }
76 }
77
78 // Run testDone through the Object.observe processing loop.
79 var dummy = {};
80 Object.observe(dummy, checkResult);
81 dummy.dummy = dummy;
82 }
83
84 testDone(0);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698