OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 function testFunction() | 7 function testFunction() |
8 { | 8 { |
9 var promise = new Promise(function promiseConstructor(resolve, reject) { | 9 var promise = new Promise(function promiseConstructor(resolve, reject) { |
10 resolve("Resolved!"); | 10 resolve("Resolved!"); |
11 }); | 11 }); |
12 promise | 12 promise |
13 .then(thenCallback, errorCallback) | 13 .then(thenCallback, errorCallback) |
14 .then(thenCallback2, errorCallback); | 14 .then(thenCallback2, errorCallback); |
15 } | 15 } |
16 | 16 |
17 function thenCallback() { } | 17 function thenCallback() { } |
18 | 18 |
19 function thenCallback2() | 19 function thenCallback2() |
20 { | 20 { |
21 debugger; | 21 debugger; |
22 } | 22 } |
23 | 23 |
24 function errorCallback() { } | 24 function errorCallback() { } |
25 | 25 |
26 var test = function () | 26 var test = function () |
27 { | 27 { |
28 var output = []; | |
29 | |
30 InspectorTest.startDebuggerTest(step1); | 28 InspectorTest.startDebuggerTest(step1); |
31 | 29 |
32 function step1() | 30 function step1() |
33 { | 31 { |
34 DebuggerAgent.enablePromiseTracker(); | 32 DebuggerAgent.enablePromiseTracker(); |
35 InspectorTest.runTestFunctionAndWaitUntilPaused(step2); | 33 InspectorTest.runTestFunctionAndWaitUntilPaused(step2); |
36 } | 34 } |
37 | 35 |
38 function step2() | 36 function step2() |
39 { | 37 { |
40 DebuggerAgent.getPromises(didGetPromises); | 38 DebuggerAgent.getPromises(didGetPromises); |
41 } | 39 } |
42 | 40 |
43 function didGetPromises(error, response) | 41 function didGetPromises(error, response) |
44 { | 42 { |
| 43 InspectorTest.assertTrue(!error, "FAIL: " + error); |
| 44 |
45 function comparePromiseData(x, y) | 45 function comparePromiseData(x, y) |
46 { | 46 { |
47 if (x.id < y.id) | 47 if (x.id < y.id) |
48 return -1; | 48 return -1; |
49 else if (x.id === y.id) | 49 else if (x.id === y.id) |
50 return 0; | 50 return 0; |
51 else | 51 else |
52 return 1; | 52 return 1; |
53 } | 53 } |
54 | 54 |
55 var minPromiseId; | 55 var minPromiseId; |
56 if (response.length) { | 56 if (response.length) { |
57 minPromiseId = response[0].id; | 57 minPromiseId = response[0].id; |
58 for (var i = 0; i < response.length; i++) | 58 for (var i = 0; i < response.length; i++) |
59 minPromiseId = Math.min(minPromiseId, response[i].id); | 59 minPromiseId = Math.min(minPromiseId, response[i].id); |
60 } | 60 } |
61 response.sort(comparePromiseData); | 61 response.sort(comparePromiseData); |
| 62 |
| 63 var output = []; |
62 for (var i = 0; i < response.length; i++) { | 64 for (var i = 0; i < response.length; i++) { |
63 var promise = response[i]; | 65 var promise = response[i]; |
64 var parentId = promise.parentId ? promise.parentId - minPromiseId :
undefined; | 66 var parentId = promise.parentId ? promise.parentId - minPromiseId :
undefined; |
65 var promiseInfo = "Promise:" + | 67 var promiseInfo = "Promise:" + |
66 "\n id: " + (promise.id - minPromiseId) + | 68 "\n id: " + (promise.id - minPromiseId) + |
67 "\n status: " + promise.status + | 69 "\n status: " + promise.status + |
68 "\n parent id: " + parentId; | 70 "\n parent id: " + parentId; |
69 var callFrame = promise.callFrame; | 71 var callFrame = promise.callFrame; |
70 if (callFrame) | 72 if (callFrame) |
71 promiseInfo += "\n " + callFrame.functionName + " " + callFra
me.url + ":" + callFrame.lineNumber; | 73 promiseInfo += "\n " + callFrame.functionName + " " + callFra
me.url + ":" + callFrame.lineNumber; |
72 output.push(promiseInfo); | 74 output.push(promiseInfo); |
73 } | 75 } |
74 | 76 |
75 InspectorTest.addResults(output); | 77 InspectorTest.addResults(output); |
76 DebuggerAgent.disablePromiseTracker(); | 78 DebuggerAgent.disablePromiseTracker(); |
| 79 DebuggerAgent.getPromises(didGetPromises2); |
| 80 } |
| 81 |
| 82 function didGetPromises2(error, response) |
| 83 { |
| 84 var hasData = !error && response && response.length > 0; |
| 85 InspectorTest.assertTrue(!hasData, "FAIL: expected error or no data afte
r disabling promise tracker."); |
77 InspectorTest.completeDebuggerTest(); | 86 InspectorTest.completeDebuggerTest(); |
78 } | 87 } |
79 } | 88 } |
80 | 89 |
81 </script> | 90 </script> |
82 </head> | 91 </head> |
83 | 92 |
84 <body onload="runTest()"> | 93 <body onload="runTest()"> |
85 <p> | 94 <p> |
86 Tests promise tracker in debugger. | 95 Tests promise tracker in debugger. |
87 </p> | 96 </p> |
88 </body> | 97 </body> |
89 </html> | 98 </html> |
OLD | NEW |