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..6bc2699f622bae570c34c6038070f9293ff72e3f |
--- /dev/null |
+++ b/LayoutTests/inspector/sources/debugger/promise-tracker.html |
@@ -0,0 +1,90 @@ |
+<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++) { |
aandrey
2014/09/03 14:57:57
drop { and }
Alexandra Mikhaylova
2014/09/03 15:01:20
Done.
|
+ 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> |