| Index: LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
|
| diff --git a/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html b/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4f0e1d46174f15715d1df2bf3a5f3154dbdfd3e1
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
|
| @@ -0,0 +1,109 @@
|
| +<html>
|
| +<head>
|
| +<style>
|
| +div#test {
|
| + display: none;
|
| + background-color: blue;
|
| + width: 100px;
|
| + height: 100px;
|
| +}
|
| +</style>
|
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
|
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
|
| +<script>
|
| +function performActions(callback)
|
| +{
|
| + var element = document.getElementById("test");
|
| + element.style.display = "block";
|
| + var unused = element.clientWidth;
|
| + callback();
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + InspectorTest.startTracingAndSaveAsStream(onStart);
|
| +
|
| + function onStart()
|
| + {
|
| + InspectorTest.invokePageFunctionAsync("performActions", evalDone);
|
| + }
|
| +
|
| + function evalDone()
|
| + {
|
| + InspectorTest.stopTracingAndReturnStream(onStop);
|
| + }
|
| +
|
| + function onStop(streamHandle)
|
| + {
|
| + var data1;
|
| + InspectorTest.retrieveStream(streamHandle, null, null, onGotStream1);
|
| +
|
| + function onGotStream1(data)
|
| + {
|
| + data1 = data;
|
| + InspectorTest.retrieveStream(streamHandle, 0, 1000, onGotStream2);
|
| + }
|
| + function onGotStream2(data)
|
| + {
|
| + if (data1 !== data)
|
| + InspectorTest.log("FAIL: got different data for cunked vs. non-chunked reads");
|
| + InspectorTest.sendCommandOrDie("IO.close", { handle: streamHandle }, onCloseDone);
|
| + }
|
| + function onCloseDone(response)
|
| + {
|
| + InspectorTest.log("Error after legit close: " + JSON.stringify(response.error));
|
| + InspectorTest.sendCommand("IO.read", { handle: streamHandle }, onReadAfterClose);
|
| + }
|
| + function onReadAfterClose(response)
|
| + {
|
| + InspectorTest.log("Error after illegal read: " + JSON.stringify(response.error));
|
| + InspectorTest.sendCommand("IO.close", { handle: streamHandle }, onCloseAfterClose);
|
| + }
|
| + function onCloseAfterClose(response)
|
| + {
|
| + InspectorTest.log("Error after illegal close: " + JSON.stringify(response.error));
|
| + performEventsSanityCheck(JSON.parse(data1));
|
| + }
|
| + }
|
| +
|
| + function assertGreaterOrEqual(a, b, message)
|
| + {
|
| + if (a >= b)
|
| + return;
|
| + InspectorTest.log(message + " (" + a + " < " + b + ")");
|
| + InspectorTest.completeTest();
|
| + }
|
| +
|
| + function performEventsSanityCheck(events)
|
| + {
|
| + var phaseComplete = 0;
|
| +
|
| + var knownEvents = {
|
| + "MessageLoop::PostTask": 0,
|
| + "FunctionCall": 0,
|
| + "UpdateLayoutTree": 0,
|
| + "Layout": 0
|
| + };
|
| +
|
| + for (var i = 0; i < events.length; ++i) {
|
| + var event = events[i];
|
| + if (event.phase === "X")
|
| + ++phaseComplete;
|
| + if (event.name in knownEvents)
|
| + ++knownEvents[event.name];
|
| + }
|
| + assertGreaterOrEqual(events.length, 10, "Too few trace events recorded");
|
| + assertGreaterOrEqual(knownEvents["FunctionCall"], 1, "Too few FunctionCall events");
|
| + assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few UpdateLayoutTree events");
|
| + assertGreaterOrEqual(knownEvents["Layout"], 1, "Too few Layout events");
|
| + InspectorTest.log("Event sanity test done");
|
| + InspectorTest.completeTest();
|
| + }
|
| +}
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<div id="test">
|
| +</div>
|
| +</body>
|
| +</html>
|
|
|