OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <style> |
| 4 div#test { |
| 5 display: none; |
| 6 background-color: blue; |
| 7 width: 100px; |
| 8 height: 100px; |
| 9 } |
| 10 </style> |
| 11 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 12 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-
test.js"></script> |
| 13 <script> |
| 14 function performActions(callback) |
| 15 { |
| 16 var element = document.getElementById("test"); |
| 17 element.style.display = "block"; |
| 18 var unused = element.clientWidth; |
| 19 callback(); |
| 20 } |
| 21 |
| 22 function test() |
| 23 { |
| 24 InspectorTest.startTracing(onStart); |
| 25 |
| 26 function onStart() |
| 27 { |
| 28 InspectorTest.invokePageFunctionAsync("performActions", evalDone); |
| 29 } |
| 30 |
| 31 function evalDone() |
| 32 { |
| 33 InspectorTest.stopTracingAndSaveAsStream(onStop); |
| 34 } |
| 35 |
| 36 function onStop(streamId) |
| 37 { |
| 38 var data1; |
| 39 InspectorTest.retrieveStream(streamId, null, null, onGotStream1); |
| 40 |
| 41 function onGotStream1(data) |
| 42 { |
| 43 data1 = data; |
| 44 InspectorTest.retrieveStream(streamId, 0, 1000, onGotStream2); |
| 45 } |
| 46 function onGotStream2(data) |
| 47 { |
| 48 if (data1 !== data) |
| 49 InspectorTest.log("FAIL: got different data for cunked vs. non-c
hunked reads"); |
| 50 InspectorTest.sendCommandOrDie("IO.close", { id: streamId }, onClose
Done); |
| 51 } |
| 52 function onCloseDone(response) |
| 53 { |
| 54 InspectorTest.log("Error after legit close: " + JSON.stringify(respo
nse.error)); |
| 55 InspectorTest.sendCommand("IO.read", { id: streamId }, onReadAfterCl
ose); |
| 56 } |
| 57 function onReadAfterClose(response) |
| 58 { |
| 59 InspectorTest.log("Error after illegal read: " + JSON.stringify(resp
onse.error)); |
| 60 InspectorTest.sendCommand("IO.close", { id: streamId }, onCloseAfter
Close); |
| 61 } |
| 62 function onCloseAfterClose(response) |
| 63 { |
| 64 InspectorTest.log("Error after illegal close: " + JSON.stringify(res
ponse.error)); |
| 65 performEventsSanityCheck(JSON.parse(data1)); |
| 66 } |
| 67 } |
| 68 |
| 69 function assertGreaterOrEqual(a, b, message) |
| 70 { |
| 71 if (a >= b) |
| 72 return; |
| 73 InspectorTest.log(message + " (" + a + " < " + b + ")"); |
| 74 InspectorTest.completeTest(); |
| 75 } |
| 76 |
| 77 function performEventsSanityCheck(events) |
| 78 { |
| 79 var phaseComplete = 0; |
| 80 |
| 81 var knownEvents = { |
| 82 "MessageLoop::PostTask": 0, |
| 83 "FunctionCall": 0, |
| 84 "UpdateLayoutTree": 0, |
| 85 "Layout": 0 |
| 86 }; |
| 87 |
| 88 for (var i = 0; i < events.length; ++i) { |
| 89 var event = events[i]; |
| 90 if (event.phase === "X") |
| 91 ++phaseComplete; |
| 92 if (event.name in knownEvents) |
| 93 ++knownEvents[event.name]; |
| 94 } |
| 95 assertGreaterOrEqual(events.length, 10, "Too few trace events recorded")
; |
| 96 assertGreaterOrEqual(knownEvents["FunctionCall"], 1, "Too few FunctionCa
ll events"); |
| 97 assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few Update
LayoutTree events"); |
| 98 assertGreaterOrEqual(knownEvents["Layout"], 1, "Too few Layout events"); |
| 99 InspectorTest.log("Event sanity test done"); |
| 100 InspectorTest.completeTest(); |
| 101 } |
| 102 } |
| 103 </script> |
| 104 </head> |
| 105 <body onload="runTest()"> |
| 106 <div id="test"> |
| 107 </div> |
| 108 </body> |
| 109 </html> |
OLD | NEW |