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..0e85b354e699575d0f7d3a4795298f457d836fb2 |
| --- /dev/null |
| +++ b/test/mjsunit/es6/debug-promises-uncaught.js |
| @@ -0,0 +1,57 @@ |
| +// 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 { |
| + // Ignore exceptions during startup in stress runs. |
| + if (step > 1) return; |
| + assertEquals(["resolve", "end main", "throw"], log); |
| + if (event == Debug.DebugEvent.Exception) { |
|
yurys
2014/04/24 08:49:50
Would be nice to also test that this branch is not
|
| + assertEquals(0, step); |
| + exception = event_data.exception(); |
| + assertEquals(undefined, event_data.promise()); |
| + } else if (event == Debug.DebugEvent.PendingExceptionInPromise) { |
| + assertEquals(1, step); |
| + assertEquals(exception, event_data.exception()); |
| + assertEquals("uncaught", exception.message); |
| + assertTrue(event_data.promise() instanceof Promise); |
| + assertTrue(event_data.uncaught()); |
| + } else { |
| + return; |
| + } |
| + 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("Unexpected exception:"); |
|
rossberg
2014/04/24 08:08:38
Nit: don't need a newline after this
Yang
2014/04/24 10:42:04
Done.
|
| + print(e + "\n" + e.stack); |
| + quit(1); |
| + } |
| +} |
| + |
| +Debug.setBreakOnException(); |
| +Debug.setListener(listener); |
| + |
| +log.push("end main"); |