Chromium Code Reviews| Index: test/mjsunit/es6/debug-promises-caught.js |
| diff --git a/test/mjsunit/es6/debug-promises-caught.js b/test/mjsunit/es6/debug-promises-caught.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8af49769ba725660aa6cdabdeb83251dec67aaca |
| --- /dev/null |
| +++ b/test/mjsunit/es6/debug-promises-caught.js |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Flags: --harmony-promises --expose-debug-as debug |
| + |
| +Debug = debug.Debug; |
| + |
| +var resolve_fun; |
| +var log = []; |
| + |
| +var p = new Promise(function(resolve, reject) { |
| + log.push("resolve"); |
| + resolve(); |
| +}); |
| + |
| +var q = p.chain( |
| + function() { |
| + log.push("throw"); |
| + throw new Error("caught"); |
| + }); |
| + |
| +q.catch(function(e) { |
| + assertEquals("caught", e.message); |
| +}); |
| + |
| +function listener(event, exec_state, event_data, data) { |
| + try { |
| + 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
|
| + assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise); |
| + if (event == Debug.DebugEvent.Exception) { |
| + assertEquals("caught", event_data.exception().message); |
| + assertEquals(undefined, event_data.deferred_promise()); |
| + } |
| + } catch (e) { |
| + // Signal a failure with exit code 1. This is necessary since the |
| + // debugger swallows exceptions and we expect the chained function |
| + // and this listener to be executed after the main script is finished. |
| + print(e + "\n" + e.stack); |
|
rossberg
2014/04/24 07:27:36
Maybe add "Unexpected exception: ".
|
| + quit(1); |
| + } |
| +} |
| + |
| +Debug.setBreakOnException(); |
| +Debug.setListener(listener); |
| + |
| +log.push("end main"); |