Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Unified Diff: test/mjsunit/es6/debug-promises-uncaught.js

Issue 249503002: Trigger debug event on not yet caught exception in promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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");
« test/mjsunit/es6/debug-promises-caught.js ('K') | « test/mjsunit/es6/debug-promises-caught.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698