| Index: test/mjsunit/es6/debug-promises-throw-in-constructor.js
|
| diff --git a/test/mjsunit/es6/debug-promises-uncaught-uncaught.js b/test/mjsunit/es6/debug-promises-throw-in-constructor.js
|
| similarity index 70%
|
| copy from test/mjsunit/es6/debug-promises-uncaught-uncaught.js
|
| copy to test/mjsunit/es6/debug-promises-throw-in-constructor.js
|
| index ae58c628cacb7e88e29456cd6fe6ef3f7b45675c..d0267cefb52d940f57c2229af55c75ef69da6efc 100644
|
| --- a/test/mjsunit/es6/debug-promises-uncaught-uncaught.js
|
| +++ b/test/mjsunit/es6/debug-promises-throw-in-constructor.js
|
| @@ -5,38 +5,25 @@
|
| // Flags: --harmony-promises --expose-debug-as debug
|
|
|
| // Test debug events when we only listen to uncaught exceptions and
|
| -// there is a catch handler for the exception thrown in a Promise.
|
| -// Expectation:
|
| -// - only the PendingExceptionInPromise debug event is triggered.
|
| +// an exception is thrown in the the Promise constructor.
|
| +// We expect an Exception debug event with a promise to be triggered.
|
|
|
| Debug = debug.Debug;
|
|
|
| -var log = [];
|
| var step = 0;
|
| -
|
| -var p = new Promise(function(resolve, reject) {
|
| - log.push("resolve");
|
| - resolve();
|
| -});
|
| -
|
| -var q = p.chain(
|
| - function() {
|
| - log.push("throw");
|
| - throw new Error("uncaught");
|
| - });
|
| +var exception = null;
|
|
|
| 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) {
|
| - assertUnreachable();
|
| - } else if (event == Debug.DebugEvent.PendingExceptionInPromise) {
|
| assertEquals(0, step);
|
| assertEquals("uncaught", event_data.exception().message);
|
| assertTrue(event_data.promise() instanceof Promise);
|
| assertTrue(event_data.uncaught());
|
| + // Assert that the debug event is triggered at the throw site.
|
| + assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
|
| step++;
|
| }
|
| } catch (e) {
|
| @@ -44,11 +31,16 @@ function listener(event, exec_state, event_data, data) {
|
| // debugger swallows exceptions and we expect the chained function
|
| // and this listener to be executed after the main script is finished.
|
| print("Unexpected exception: " + e + "\n" + e.stack);
|
| - quit(1);
|
| + exception = e;
|
| }
|
| }
|
|
|
| Debug.setBreakOnUncaughtException();
|
| Debug.setListener(listener);
|
|
|
| -log.push("end main");
|
| +var p = new Promise(function(resolve, reject) {
|
| + throw new Error("uncaught"); // event
|
| +});
|
| +
|
| +assertEquals(1, step);
|
| +assertNull(exception);
|
|
|