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

Unified Diff: LayoutTests/inspector/sources/debugger/debugger-pause-on-promise-rejection.html

Issue 651533003: DevTools: Introduce Debugger::Reason::PromiseRejection pause reason. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: also disaply <exception> in scopes sidebar 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/sources/debugger/debugger-pause-on-promise-rejection.html
diff --git a/LayoutTests/inspector/sources/debugger/debugger-pause-on-promise-rejection.html b/LayoutTests/inspector/sources/debugger/debugger-pause-on-promise-rejection.html
new file mode 100644
index 0000000000000000000000000000000000000000..2918ab8249f2a00454224d60e2b9c8030227fb5c
--- /dev/null
+++ b/LayoutTests/inspector/sources/debugger/debugger-pause-on-promise-rejection.html
@@ -0,0 +1,92 @@
+<html>
+<head>
+<script src="../../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../../http/tests/inspector/debugger-test.js"></script>
+<script>
+
+function createPromise()
+{
+ var result = {};
+ var p = new Promise(function(resolve, reject) {
+ result.resolve = resolve;
+ result.reject = reject;
+ });
+ result.promise = p;
+ return result;
+}
+
+function testFunction()
+{
+ var resolved = createPromise();
+ var caught = createPromise();
+ var uncaught = createPromise();
+
+ caught.promise
+ .then(function c1() {})
+ .then(function c2() {})
+ .catch(function c3() {});
+ uncaught.promise
+ .then(function f1() {})
+ .then(function f2() {})
+ .then(function f3() {}); // Last is uncaught.
+
+ resolved.resolve(42); // Should not pause.
+ caught.reject(new Error("caught"));
+ uncaught.reject(new Error("uncaught"));
+}
+
+var test = function()
+{
+ InspectorTest.setQuiet(true);
+ InspectorTest.startDebuggerTest(step1);
+
+ function waitUntilPausedNTimes(count, callback)
+ {
+ function inner()
+ {
+ if (count--)
+ InspectorTest.waitUntilPausedAndDumpStackAndResume(inner);
+ else
+ callback();
+ }
+ inner();
+ }
+
+ function step1()
+ {
+ DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions);
+ InspectorTest.showScriptSource("debugger-pause-on-promise-rejection.html", step2);
+ }
+
+ function step2()
+ {
+ InspectorTest.addResult("=== Pausing only on uncaught exceptions ===");
+ InspectorTest.runTestFunction();
+ waitUntilPausedNTimes(1, step3);
+ }
+
+ function step3()
+ {
+ DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions);
+ InspectorTest.addResult("\n=== Pausing on all exceptions ===");
+ InspectorTest.runTestFunction();
+ waitUntilPausedNTimes(2, step4);
+ }
+
+ function step4()
+ {
+ DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions);
+ InspectorTest.completeDebuggerTest();
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests that pause on promise rejection works.
+</p>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698