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

Side by Side Diff: test/mjsunit/es6/throw-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 throw new Error("123"); // event
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 assertTrue(
47 exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
48 assertSame(p1, event_data.promise());
49 } else {
50 // p2 is rejected by p1's default reject handler.
51 assertEquals(0, exec_state.frameCount());
52 assertSame(p2, event_data.promise());
53 }
54 }
55 } catch (e) {
56 %AbortJS(e + "\n" + e.stack);
57 }
58 }
59
60 Debug.setBreakOnUncaughtException();
61 Debug.setListener(listener);
62
63 log.push("end main");
64
65 function testDone(iteration) {
66 function checkResult() {
67 try {
68 assertTrue(iteration < 10);
69 if (expected_events === 0) {
70 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log);
71 } else {
72 testDone(iteration + 1);
73 }
74 } catch (e) {
75 %AbortJS(e + "\n" + e.stack);
76 }
77 }
78
79 // Run testDone through the Object.observe processing loop.
80 var dummy = {};
81 Object.observe(dummy, checkResult);
82 dummy.dummy = dummy;
83 }
84
85 testDone(0);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/reject-caught-by-default-reject-handler.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698