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

Unified Diff: LayoutTests/inspector/sources/debugger/promise-tracker.html

Issue 529723002: [WIP] Protocol for sending information about Promises to frontend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comments + REBASE Created 6 years, 3 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 | « no previous file | LayoutTests/inspector/sources/debugger/promise-tracker-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/inspector/sources/debugger/promise-tracker.html
diff --git a/LayoutTests/inspector/sources/debugger/promise-tracker.html b/LayoutTests/inspector/sources/debugger/promise-tracker.html
new file mode 100644
index 0000000000000000000000000000000000000000..c724ecfa7717dd66cce6cdce0cbdd15d59026a19
--- /dev/null
+++ b/LayoutTests/inspector/sources/debugger/promise-tracker.html
@@ -0,0 +1,89 @@
+<html>
+<head>
+<script src="../../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../../http/tests/inspector/debugger-test.js"></script>
+<script>
+
+function testFunction()
+{
+ var promise = new Promise(function promiseConstructor(resolve, reject) {
+ resolve("Resolved!");
+ });
+ promise
+ .then(thenCallback, errorCallback)
+ .then(thenCallback2, errorCallback);
+}
+
+function thenCallback() { }
+
+function thenCallback2()
+{
+ debugger;
+}
+
+function errorCallback() { }
+
+var test = function ()
+{
+ var output = [];
+
+ InspectorTest.startDebuggerTest(step1);
+
+ function step1()
+ {
+ DebuggerAgent.enablePromiseTracker();
+ InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
+ }
+
+ function step2()
+ {
+ DebuggerAgent.getPromises(didGetPromises);
+ }
+
+ function didGetPromises(error, response)
+ {
+ function comparePromiseData(x, y)
+ {
+ if (x.id < y.id)
+ return -1;
+ else if (x.id === y.id)
+ return 0;
+ else
+ return 1;
+ }
+
+ var minPromiseId;
+ if (response.length) {
+ minPromiseId = response[0].id;
+ for (var i = 0; i < response.length; i++)
+ minPromiseId = Math.min(minPromiseId, response[i].id);
+ }
+ response.sort(comparePromiseData);
+ for (var i = 0; i < response.length; i++) {
+ var promise = response[i];
+ var parentId = promise.parentId ? promise.parentId - minPromiseId : undefined;
+ var promiseInfo = "Promise:" +
+ "\n id: " + (promise.id - minPromiseId) +
+ "\n status: " + promise.status +
+ "\n parent id: " + parentId;
+ var callFrame = promise.callFrame;
+ if (callFrame)
+ promiseInfo += "\n " + callFrame.functionName + " " + callFrame.url + ":" + callFrame.lineNumber;
+ output.push(promiseInfo);
+ }
+
+ InspectorTest.addResults(output);
+ DebuggerAgent.disablePromiseTracker();
+ InspectorTest.completeDebuggerTest();
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests promise tracker in debugger.
+</p>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/inspector/sources/debugger/promise-tracker-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698