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; | |
|
aandrey
2014/04/24 11:04:59
remove
| |
| 10 var log = []; | |
| 11 var step = 0; | |
| 12 | |
| 13 var p = new Promise(function(resolve, reject) { | |
| 14 log.push("resolve"); | |
| 15 resolve(); | |
| 16 }); | |
| 17 | |
| 18 var q = p.chain( | |
| 19 function() { | |
| 20 log.push("throw"); | |
| 21 throw new Error("caught"); | |
| 22 }); | |
| 23 | |
| 24 q.catch(function(e) { | |
| 25 assertEquals("caught", e.message); | |
| 26 }); | |
| 27 | |
| 28 function listener(event, exec_state, event_data, data) { | |
| 29 try { | |
| 30 // Ignore exceptions during startup in stress runs. | |
| 31 if (step > 0) return; | |
| 32 assertEquals(["resolve", "end main", "throw"], log); | |
| 33 assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise); | |
| 34 if (event == Debug.DebugEvent.Exception) { | |
| 35 assertEquals("caught", event_data.exception().message); | |
| 36 assertEquals(undefined, event_data.promise()); | |
| 37 step++; | |
| 38 } | |
| 39 } catch (e) { | |
| 40 // Signal a failure with exit code 1. This is necessary since the | |
| 41 // debugger swallows exceptions and we expect the chained function | |
| 42 // and this listener to be executed after the main script is finished. | |
| 43 print("Unexpected exception: " + e + "\n" + e.stack); | |
| 44 quit(1); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 Debug.setBreakOnException(); | |
| 49 Debug.setListener(listener); | |
| 50 | |
| 51 log.push("end main"); | |
| OLD | NEW |