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

Unified Diff: LayoutTests/inspector/console/console-uncaught-promise.html

Issue 625943002: Catch uncaught promise rejections from V8 and log to console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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: LayoutTests/inspector/console/console-uncaught-promise.html
diff --git a/LayoutTests/inspector/console/console-uncaught-promise.html b/LayoutTests/inspector/console/console-uncaught-promise.html
new file mode 100644
index 0000000000000000000000000000000000000000..3a5c6983f8c9a5ba4dd67fe1ad8b03cda366999e
--- /dev/null
+++ b/LayoutTests/inspector/console/console-uncaught-promise.html
@@ -0,0 +1,73 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/console-test.js"></script>
+<script>
+
+function runPromises(source)
+{
+ Promise.reject(new Error(source + ".err1"))
+ .then()
+ .then()
+ .then(); // Last is unhandled.
+
+ var reject
+ var m0 = new Promise(function(res, rej) { reject = rej; });
+ var m1 = m0.then(function() {});
+ var m2 = m0.then(function() {});
+ var m3 = m0.then(function() {});
+ var m4 = 0;
+ m0.catch(function() {
+ m2.catch(function() {
+ m1.catch(function() {
+ m4 = m3.then(function() {}); // Unhandled.
+ });
+ });
+ });
+ reject(new Error(source + ".err2"));
+}
+
+function onload()
+{
+ runPromises("onload");
+ runTest();
+}
+
+function test()
+{
+ InspectorTest.addConsoleViewSniffer(addMessage, true);
+
+ WebInspector.console.showPromise().then(function() {
+ InspectorTest.evaluateInPage("runPromises('inspector')");
+ });
+
+ var count = 0;
+ function addMessage(uiMessage)
+ {
+ if (uiMessage.toString().indexOf("inspector.err") !== -1)
+ ++count;
+ if (count === 2)
+ InspectorTest.expandConsoleMessages(dump);
+ }
+
+ function dump()
+ {
+ // Sort console messages from async Promises to avoid flakiness.
+ var results = InspectorTest.dumpConsoleMessagesIntoArray(false, false, InspectorTest.textContentWithLineBreaks);
+ results.sort();
+ InspectorTest.addResults(results);
+ InspectorTest.completeTest();
+ }
+
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests that uncaught promise rejections are logged into console.
+</p>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698