Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 Debug = debug.Debug; | |
| 8 | |
| 9 var resolve_fun; | |
| 10 var log = []; | |
| 11 | |
| 12 var p = new Promise(function(resolve, reject) { | |
| 13 log.push("resolve"); | |
| 14 resolve(); | |
| 15 }); | |
| 16 | |
| 17 var q = p.chain( | |
| 18 function() { | |
| 19 log.push("throw"); | |
| 20 throw new Error("caught"); | |
| 21 }); | |
| 22 | |
| 23 q.catch(function(e) { | |
| 24 assertEquals("caught", e.message); | |
| 25 }); | |
| 26 | |
| 27 function listener(event, exec_state, event_data, data) { | |
| 28 try { | |
| 29 assertEquals(["resolve", "end main", "throw"], log); | |
|
yurys
2014/04/24 07:48:43
Just curious: I'd expect "end main" to be logged b
Yang
2014/04/24 07:59:59
Yes. The function in line 12 is executed immediate
| |
| 30 assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise); | |
| 31 if (event == Debug.DebugEvent.Exception) { | |
| 32 assertEquals("caught", event_data.exception().message); | |
| 33 assertEquals(undefined, event_data.deferred_promise()); | |
| 34 } | |
| 35 } catch (e) { | |
| 36 // Signal a failure with exit code 1. This is necessary since the | |
| 37 // debugger swallows exceptions and we expect the chained function | |
| 38 // and this listener to be executed after the main script is finished. | |
| 39 print(e + "\n" + e.stack); | |
|
rossberg
2014/04/24 07:27:36
Maybe add "Unexpected exception: ".
| |
| 40 quit(1); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 Debug.setBreakOnException(); | |
| 45 Debug.setListener(listener); | |
| 46 | |
| 47 log.push("end main"); | |
| OLD | NEW |