| 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(callback) | 7 function performActions(callback) |
| 8 { | 8 { |
| 9 var image = new Image(); | 9 var image = new Image(); |
| 10 image.onload = bar; | 10 image.onload = bar; |
| 11 image.src = "resources/anImage.png"; | 11 image.src = "resources/anImage.png"; |
| 12 | 12 |
| 13 function bar() | 13 function bar() |
| 14 { | 14 { |
| 15 var image = new Image(); | 15 var image = new Image(); |
| 16 image.onload = function(event) { callback(); } // do not pass event arg
ument to the callback. | 16 image.onload = function(event) { callback(); } // do not pass event arg
ument to the callback. |
| 17 image.src = "resources/anotherImage.png"; | 17 image.src = "resources/anotherImage.png"; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 function test() | 21 function test() |
| 22 { | 22 { |
| 23 WebInspector.TimelinePanel.show(); | 23 WebInspector.TimelinePanel.show(); |
| 24 WebInspector.panels.timeline._model._currentTarget = WebInspector.targetMana
ger.mainTarget(); | 24 WebInspector.panels.timeline._model._currentTarget = WebInspector.targetMana
ger.mainTarget(); |
| 25 InspectorTest.invokeAsyncWithTimeline("performActions", finish); | 25 InspectorTest.invokeAsyncWithTimeline("performActions", finish); |
| 26 | 26 |
| 27 function finish() | 27 function finish() |
| 28 { | 28 { |
| 29 var recordTypes = WebInspector.TimelineModel.RecordType; |
| 30 var typesToDump = new Set([recordTypes.ResourceSendRequest, recordTypes.
ResourceReceiveResponse, recordTypes.ResourceReceivedData, recordTypes.ResourceF
inish, |
| 31 recordTypes.EventDispatch, recordTypes.FunctionCall]); |
| 29 function dumpFormattedRecord(presentationRecord, prefix) | 32 function dumpFormattedRecord(presentationRecord, prefix) |
| 30 { | 33 { |
| 31 var record = presentationRecord.record(); | 34 var record = presentationRecord.record(); |
| 32 prefix = prefix || ""; | 35 prefix = prefix || ""; |
| 33 // Ignore stray paint & rendering events for better stability. | 36 // Ignore stray paint & rendering events for better stability. |
| 34 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(re
cord).name; | 37 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(re
cord).name; |
| 35 if (categoryName !== "loading" && categoryName !== "scripting") | 38 if (categoryName !== "loading" && categoryName !== "scripting") |
| 36 return; | 39 return; |
| 37 var childPrefix = prefix; | 40 var childPrefix = prefix; |
| 38 // Here and below: pretend coalesced record are just not there, as c
oalescation is time dependent and, hence, not stable. | 41 // Here and below: pretend coalesced record are just not there, as c
oalescation is time dependent and, hence, not stable. |
| 39 // Filter out InjectedScript function call because they happen out o
f sync. | 42 // Filter out InjectedScript function call because they happen out o
f sync. |
| 40 if (!presentationRecord.coalesced() | 43 if (!presentationRecord.coalesced() && typesToDump.has(record.type()
) |
| 41 && record.type() !== "GCEvent" | |
| 42 && (record.type() !== "FunctionCall" || record.traceEvent().args
["data"].scriptName)) { | 44 && (record.type() !== "FunctionCall" || record.traceEvent().args
["data"].scriptName)) { |
| 43 InspectorTest.addResult(prefix + record.type()); | 45 InspectorTest.addResult(prefix + record.type()); |
| 44 childPrefix = childPrefix + " "; | 46 childPrefix = childPrefix + " "; |
| 45 } | 47 } |
| 46 if (presentationRecord.presentationChildren()) { | 48 if (presentationRecord.presentationChildren()) { |
| 47 for (var i = 0; i < presentationRecord.presentationChildren().le
ngth; ++i) | 49 for (var i = 0; i < presentationRecord.presentationChildren().le
ngth; ++i) |
| 48 dumpFormattedRecord(presentationRecord.presentationChildren(
)[i], childPrefix); | 50 dumpFormattedRecord(presentationRecord.presentationChildren(
)[i], childPrefix); |
| 49 } | 51 } |
| 50 } | 52 } |
| 51 var records = InspectorTest.timelinePresentationModel().rootRecord().pre
sentationChildren(); | 53 var records = InspectorTest.timelinePresentationModel().rootRecord().pre
sentationChildren(); |
| 52 for (var i = 0; i < records.length; ++i) | 54 for (var i = 0; i < records.length; ++i) |
| 53 dumpFormattedRecord(records[i]); | 55 dumpFormattedRecord(records[i]); |
| 54 InspectorTest.completeTest(); | 56 InspectorTest.completeTest(); |
| 55 } | 57 } |
| 56 } | 58 } |
| 57 | 59 |
| 58 if (!window.testRunner) | 60 if (!window.testRunner) |
| 59 setTimeout(performActions, 3000); | 61 setTimeout(performActions, 3000); |
| 60 | 62 |
| 61 </script> | 63 </script> |
| 62 </head> | 64 </head> |
| 63 | 65 |
| 64 <body onload="runTest()"> | 66 <body onload="runTest()"> |
| 65 <p> | 67 <p> |
| 66 Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc. | 68 Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc. |
| 67 </p> | 69 </p> |
| 68 | 70 |
| 69 </body> | 71 </body> |
| 70 </html> | 72 </html> |
| OLD | NEW |