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

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: addressed comments 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
« no previous file with comments | « test/mjsunit/es6/debug-promises-caught.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « 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