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 = "../../../http/tests/inspector/tracing/resources/timeline-netwo
rk-resource.js"; | 14 script.src = "../../../http/tests/inspector/tracing/resources/timeline-netwo
rk-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 async function test() |
22 { | 22 { |
23 InspectorTest.invokeAsyncWithTimeline("performActions", finish); | 23 await new Promise(fulfill => InspectorTest.invokeAsyncWithTimeline("performA
ctions", fulfill)); |
24 | 24 |
25 function finish() | 25 var model = InspectorTest.timelineModel(); |
| 26 var linkifier = new Components.Linkifier(); |
| 27 var badgePool = new ProductRegistry.BadgePool(); |
| 28 |
| 29 for (var request of model.networkRequests()) { |
| 30 var element = await Timeline.TimelineUIUtils.buildNetworkRequestDetails(
request, model, linkifier, badgePool); |
| 31 printElement(element); |
| 32 } |
| 33 InspectorTest.completeTest(); |
| 34 |
| 35 function printElement(element) |
26 { | 36 { |
27 var model = InspectorTest.timelineModel(); | 37 var rows = element.querySelectorAll(".timeline-details-view-row"); |
28 var linkifier = new Components.Linkifier(); | 38 for (var i = 0; i < rows.length; ++i) { |
29 function printRequestDetails(request) | 39 var title = InspectorTest.deepTextContent(rows[i].firstChild); |
30 { | 40 var value = InspectorTest.deepTextContent(rows[i].lastChild); |
31 return Timeline.TimelineUIUtils.buildNetworkRequestDetails(request,
model, linkifier).then(printElement); | 41 if (title === "Duration" || title === "Mime Type") |
| 42 value = typeof value; |
| 43 if (/^file:\/\//.test(value)) |
| 44 value = /[^/]*$/.exec(value)[0]; |
| 45 if (!title && !value) |
| 46 continue; |
| 47 InspectorTest.addResult(title + ": " + value); |
32 } | 48 } |
33 function printElement(element) | |
34 { | |
35 var rows = element.querySelectorAll(".timeline-details-view-row"); | |
36 for (var i = 0; i < rows.length; ++i) { | |
37 var title = rows[i].firstChild.firstChild.textContent; | |
38 var value = rows[i].lastChild.firstChild; | |
39 if (value.children && value.children.length) | |
40 value = Array.from(value.children, element => element.textCont
ent).slice(1).join(''); | |
41 else | |
42 value = value.textContent; | |
43 if (title === "Duration" || title === "Mime Type") | |
44 value = typeof value; | |
45 if (/^file:\/\//.test(value)) | |
46 value = /[^/]*$/.exec(value)[0]; | |
47 InspectorTest.addResult(title + ": " + value); | |
48 } | |
49 } | |
50 Promise.all(model.networkRequests().map(printRequestDetails)).then(Inspe
ctorTest.completeTest); | |
51 } | 49 } |
52 } | 50 } |
53 | 51 |
54 </script> | 52 </script> |
55 </head> | 53 </head> |
56 | 54 |
57 <body onload="runTest()"> | 55 <body onload="runTest()"> |
58 <p> | 56 <p> |
59 Tests the Timeline UI API for network requests. | 57 Tests the Timeline UI API for network requests. |
60 </p> | 58 </p> |
61 </body> | 59 </body> |
62 </html> | 60 </html> |
OLD | NEW |