| 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/timeline-test.js"></script> | 4 <script src="../../../http/tests/inspector/timeline-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function performActions() | 7 function performActions() |
| 8 { | 8 { |
| 9 var image = new Image(); | 9 var image = new Image(); |
| 10 var imagePromise = new Promise((fulfill) => image.onload = fulfill); | 10 var imagePromise = new Promise((fulfill) => image.onload = fulfill); |
| 11 image.src = "../resources/anImage.png"; | 11 image.src = "../resources/anImage.png"; |
| 12 | 12 |
| 13 var script = document.createElement("script"); | 13 var script = document.createElement("script"); |
| 14 script.src = "timeline-network-resource.js"; | 14 script.src = "timeline-network-resource.js"; |
| 15 document.body.appendChild(script); | 15 document.body.appendChild(script); |
| 16 var scriptPromise = new Promise((fulfill) => window.timelineNetworkResourceE
valuated = fulfill); | 16 var scriptPromise = new Promise((fulfill) => window.timelineNetworkResourceE
valuated = fulfill); |
| 17 | 17 |
| 18 return Promise.all([imagePromise, scriptPromise]); | 18 return Promise.all([imagePromise, scriptPromise]); |
| 19 } | 19 } |
| 20 | 20 |
| 21 function test() | 21 function test() |
| 22 { | 22 { |
| 23 var model = WebInspector.panels.timeline._model; | 23 var model = UI.panels.timeline._model; |
| 24 | 24 |
| 25 InspectorTest.invokeAsyncWithTimeline("performActions", finish); | 25 InspectorTest.invokeAsyncWithTimeline("performActions", finish); |
| 26 | 26 |
| 27 function finish() | 27 function finish() |
| 28 { | 28 { |
| 29 var linkifier = new WebInspector.Linkifier(); | 29 var linkifier = new Components.Linkifier(); |
| 30 function printRequestDetails(request) | 30 function printRequestDetails(request) |
| 31 { | 31 { |
| 32 return WebInspector.TimelineUIUtils.buildNetworkRequestDetails(reque
st, model, linkifier).then(printElement); | 32 return Timeline.TimelineUIUtils.buildNetworkRequestDetails(request,
model, linkifier).then(printElement); |
| 33 } | 33 } |
| 34 function printElement(element) | 34 function printElement(element) |
| 35 { | 35 { |
| 36 var rows = element.querySelectorAll(".timeline-details-view-row"); | 36 var rows = element.querySelectorAll(".timeline-details-view-row"); |
| 37 for (var i = 0; i < rows.length; ++i) { | 37 for (var i = 0; i < rows.length; ++i) { |
| 38 var title = rows[i].firstChild.firstChild.textContent; | 38 var title = rows[i].firstChild.firstChild.textContent; |
| 39 var value = rows[i].lastChild.firstChild.textContent; | 39 var value = rows[i].lastChild.firstChild.textContent; |
| 40 if (title === "Duration" || title === "Mime Type") | 40 if (title === "Duration" || title === "Mime Type") |
| 41 value = typeof value; | 41 value = typeof value; |
| 42 if (/^file:\/\//.test(value)) | 42 if (/^file:\/\//.test(value)) |
| 43 value = /[^/]*$/.exec(value)[0]; | 43 value = /[^/]*$/.exec(value)[0]; |
| 44 InspectorTest.addResult(title + ": " + value); | 44 InspectorTest.addResult(title + ": " + value); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 Promise.all(model.networkRequests().map(printRequestDetails)).then(Inspe
ctorTest.completeTest); | 47 Promise.all(model.networkRequests().map(printRequestDetails)).then(Inspe
ctorTest.completeTest); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 </script> | 51 </script> |
| 52 </head> | 52 </head> |
| 53 | 53 |
| 54 <body onload="runTest()"> | 54 <body onload="runTest()"> |
| 55 <p> | 55 <p> |
| 56 Tests the Timeline UI API for network requests. | 56 Tests the Timeline UI API for network requests. |
| 57 </p> | 57 </p> |
| 58 </body> | 58 </body> |
| 59 </html> | 59 </html> |
| OLD | NEW |