Chromium Code Reviews| Index: test/mjsunit/es6/debug-promises-uncaught.js |
| diff --git a/test/mjsunit/es6/debug-promises-uncaught.js b/test/mjsunit/es6/debug-promises-uncaught.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..952b7194b152b8de976f928bb750afd144e1512c |
| --- /dev/null |
| +++ b/test/mjsunit/es6/debug-promises-uncaught.js |
| @@ -0,0 +1,53 @@ |
| +// 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 step = 0; |
| +var exception = undefined; |
| + |
| +var p = new Promise(function(resolve, reject) { |
| + log.push("resolve"); |
| + resolve(); |
| +}); |
| + |
| +var q = p.chain( |
| + function() { |
| + log.push("throw"); |
| + throw new Error("uncaught"); |
| + }); |
| + |
| +function listener(event, exec_state, event_data, data) { |
| + try { |
| + assertEquals(["resolve", "end main", "throw"], log); |
| + if (event == Debug.DebugEvent.Exception) { |
| + assertEquals(0, step); |
| + exception = event_data.exception(); |
| + assertEquals(undefined, event_data.deferred_promise()); |
| + } else if (event == Debug.DebugEvent.PendingExceptionInPromise) { |
| + assertEquals(1, step); |
| + assertEquals(exception, event_data.exception()); |
| + assertEquals("uncaught", exception.message); |
| + assertEquals('object', typeof event_data.deferred_promise()); |
|
rossberg
2014/04/24 07:27:36
You could more specifically test 'event_data.promi
|
| + } else { |
| + assertUnreachable(); |
| + } |
| + step++; |
| + } 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"); |