Chromium Code Reviews| 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(callback) |
| 8 { | 8 { |
| 9 function onImageLoad() | |
| 10 { | |
| 11 window._imageLoaded = true; | |
| 12 if (window._scriptEvaluated) | |
| 13 callback(); | |
| 14 } | |
| 15 | |
| 16 function scriptEvaluated() | |
| 17 { | |
| 18 window._scriptEvaluated = true; | |
|
yurys
2014/07/17 10:42:24
may be use callback counter?
| |
| 19 if (window._imageLoaded) | |
| 20 callback(); | |
| 21 } | |
| 22 | |
| 9 var image = new Image(); | 23 var image = new Image(); |
| 24 image.onload = onImageLoad; | |
| 10 image.src = "resources/anImage.png"; | 25 image.src = "resources/anImage.png"; |
| 11 var script = document.createElement("script"); | 26 var script = document.createElement("script"); |
| 12 script.src = "timeline-network-resource.js"; | 27 script.src = "timeline-network-resource.js"; |
| 13 document.body.appendChild(script); | 28 document.body.appendChild(script); |
| 29 | |
| 30 window.timelineNetworkResourceEvaluated = scriptEvaluated; | |
| 14 } | 31 } |
| 15 | 32 |
| 16 function test() | 33 function test() |
| 17 { | 34 { |
| 18 var callbackBarrier = new CallbackBarrier(); | 35 InspectorTest.invokeAsyncWithTimeline("performActions", done); |
| 19 var resourceReceivedCallback = callbackBarrier.createCallback(); | |
| 20 // It will be called from timeline-network-resource.js script by evaluateInW ebInspector call. | |
| 21 InspectorTest.scriptEvaluated = callbackBarrier.createCallback(); | |
| 22 callbackBarrier.callWhenDone(done); | |
| 23 | 36 |
| 24 function done() | 37 function done() |
| 25 { | 38 { |
| 26 InspectorTest.addResult("Script evaluated."); | 39 InspectorTest.addResult("Script evaluated."); |
| 27 InspectorTest.addResult("Resource received data has length, test passed. "); | 40 var filteredRecords = InspectorTest.filterTimelineRecords("ResourceRecei vedData"); |
|
yurys
2014/07/17 10:42:24
filterTimelineRecords("ResourceReceivedData", true
| |
| 41 if (filteredRecords.length) { | |
| 42 var record = filteredRecords[0]; | |
| 43 if (record.data && record.data && typeof record.data.encodedDataLeng th === "number") | |
| 44 InspectorTest.addResult("Resource received data has length, test passed."); | |
| 45 } | |
| 28 InspectorTest.completeTest(); | 46 InspectorTest.completeTest(); |
| 29 } | 47 } |
| 30 | |
| 31 var calledOnce; | |
| 32 | |
| 33 InspectorTest.startTimeline(function() { | |
| 34 InspectorTest.evaluateInPage("performActions()"); | |
| 35 }); | |
| 36 | |
| 37 InspectorTest.waitForRecordType("ResourceReceivedData", finish); | |
| 38 | |
| 39 function finish(object) | |
| 40 { | |
| 41 for (var prop in object) { | |
| 42 if (!InspectorTest.timelinePropertyFormatters[prop]) { | |
| 43 for (var property in object[prop]) { | |
| 44 if (property === "encodedDataLength") { | |
| 45 if (!calledOnce) { | |
| 46 calledOnce = true; | |
| 47 resourceReceivedCallback(); | |
| 48 } | |
| 49 return; | |
| 50 } | |
| 51 } | |
| 52 } | |
| 53 } | |
| 54 } | |
| 55 } | 48 } |
| 56 | 49 |
| 57 </script> | 50 </script> |
| 58 </head> | 51 </head> |
| 59 | 52 |
| 60 <body onload="runTest()"> | 53 <body onload="runTest()"> |
| 61 <p> | 54 <p> |
| 62 Tests the Timeline API instrumentation of a network resource received data | 55 Tests the Timeline API instrumentation of a network resource received data |
| 63 </p> | 56 </p> |
| 64 </body> | 57 </body> |
| 65 </html> | 58 </html> |
| OLD | NEW |