| 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() | |
| 15 { | |
| 16 var element = document.getElementById("test"); | |
| 17 element.style.display = "block"; | |
| 18 var unused = element.clientWidth; | |
| 19 } | |
| 20 | |
| 21 function test() | |
| 22 { | |
| 23 InspectorTest.startTracingAndSaveAsStream(onStart); | |
| 24 | |
| 25 function onStart() | |
| 26 { | |
| 27 InspectorTest.evaluateInPage("performActions()", evalDone); | |
| 28 } | |
| 29 | |
| 30 function evalDone() | |
| 31 { | |
| 32 InspectorTest.stopTracingAndReturnStream(onStop); | |
| 33 } | |
| 34 | |
| 35 function onStop(streamHandle) | |
| 36 { | |
| 37 var data1; | |
| 38 InspectorTest.retrieveStream(streamHandle, null, null, onGotStream1); | |
| 39 | |
| 40 function onGotStream1(data) | |
| 41 { | |
| 42 data1 = data; | |
| 43 InspectorTest.retrieveStream(streamHandle, 0, 1000, onGotStream2); | |
| 44 } | |
| 45 function onGotStream2(data) | |
| 46 { | |
| 47 if (data1 !== data) | |
| 48 InspectorTest.log("FAIL: got different data for cunked vs. non-c
hunked reads"); | |
| 49 InspectorTest.sendCommandOrDie("IO.close", { handle: streamHandle },
onCloseDone); | |
| 50 } | |
| 51 function onCloseDone(response) | |
| 52 { | |
| 53 InspectorTest.log("Error after legit close: " + JSON.stringify(respo
nse.error)); | |
| 54 InspectorTest.sendCommand("IO.read", { handle: streamHandle }, onRea
dAfterClose); | |
| 55 } | |
| 56 function onReadAfterClose(response) | |
| 57 { | |
| 58 InspectorTest.log("Error after illegal read: " + JSON.stringify(resp
onse.error)); | |
| 59 InspectorTest.sendCommand("IO.close", { handle: streamHandle }, onCl
oseAfterClose); | |
| 60 } | |
| 61 function onCloseAfterClose(response) | |
| 62 { | |
| 63 InspectorTest.log("Error after illegal close: " + JSON.stringify(res
ponse.error)); | |
| 64 var trace = JSON.parse(data1); | |
| 65 performEventsSanityCheck(trace["traceEvents"]); | |
| 66 InspectorTest.log("Metadata: " + typeof trace["metadata"] + (trace["metadata"] ?
", not null" : "")); | |
| 67 InspectorTest.completeTest(); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 function assertGreaterOrEqual(a, b, message) | |
| 72 { | |
| 73 if (a >= b) | |
| 74 return; | |
| 75 InspectorTest.log(message + " (" + a + " < " + b + ")"); | |
| 76 InspectorTest.completeTest(); | |
| 77 } | |
| 78 | |
| 79 function performEventsSanityCheck(events) | |
| 80 { | |
| 81 var phaseComplete = 0; | |
| 82 | |
| 83 var knownEvents = { | |
| 84 "MessageLoop::PostTask": 0, | |
| 85 "FunctionCall": 0, | |
| 86 "UpdateLayoutTree": 0, | |
| 87 "Layout": 0 | |
| 88 }; | |
| 89 | |
| 90 for (var i = 0; i < events.length; ++i) { | |
| 91 var event = events[i]; | |
| 92 if (event.phase === "X") | |
| 93 ++phaseComplete; | |
| 94 if (event.name in knownEvents) | |
| 95 ++knownEvents[event.name]; | |
| 96 } | |
| 97 assertGreaterOrEqual(events.length, 10, "Too few trace events recorded")
; | |
| 98 assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few Update
LayoutTree events"); | |
| 99 assertGreaterOrEqual(knownEvents["Layout"], 1, "Too few Layout events"); | |
| 100 InspectorTest.log("Event sanity test done"); | |
| 101 } | |
| 102 } | |
| 103 </script> | |
| 104 </head> | |
| 105 <body onload="runTest()"> | |
| 106 <div id="test"> | |
| 107 </div> | |
| 108 </body> | |
| 109 </html> | |
| OLD | NEW |