Chromium Code Reviews| 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..1fffd8c8218d9fc47ee3cd39af80644f9389afaa |
| --- /dev/null |
| +++ b/LayoutTests/inspector/sources/debugger/promise-tracker.html |
| @@ -0,0 +1,82 @@ |
| +<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) { |
|
aandrey
2014/09/02 14:34:49
new line before {
Alexandra Mikhaylova
2014/09/03 14:28:54
Done.
aandrey
2014/09/03 14:57:57
*before* {, not after
Alexandra Mikhaylova
2014/09/03 15:01:20
Done.
|
| + function comparePromiseData(x, y) |
| + { |
| + if (x.id < y.id) |
| + return -1; |
| + else if (x.id === y.id) |
| + return 0; |
| + else |
| + return 1; |
| + } |
| + |
| + response.sort(comparePromiseData); |
| + for (var i = 0; i < response.length; i++) { |
| + var promise = response[i]; |
| + var promiseInfo = "Promise:" + |
| + "\n id: " + promise.id + |
|
aandrey
2014/09/02 14:34:49
should be (promise.id - minPromiseId) to avoid tes
Alexandra Mikhaylova
2014/09/03 14:28:54
Done.
|
| + "\n status: " + promise.status + |
| + "\n parent id: " + promise.parentId; |
|
aandrey
2014/09/02 14:34:49
ditto
Alexandra Mikhaylova
2014/09/03 14:28:54
Done.
|
| + var callFrame = promise.callFrame; |
| + if (callFrame) |
| + promiseInfo = promiseInfo + |
|
aandrey
2014/09/02 14:34:49
promiseInfo += ...
Alexandra Mikhaylova
2014/09/03 14:28:54
Done.
|
| + "\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> |