| Index: third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.js
|
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.js b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a4fed070985cc94043486b57da851dfa4de264eb
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.js
|
| @@ -0,0 +1,96 @@
|
| +(async function() {
|
| + let {page, session, Protocol} = await InspectorTest.startHTML(`
|
| + <style>
|
| + div#test {
|
| + display: none;
|
| + background-color: blue;
|
| + width: 100px;
|
| + height: 100px;
|
| + }
|
| + </style>
|
| + <div id='test'>
|
| + </div>
|
| + `, '');
|
| +
|
| + (await InspectorTest.loadScript('../resources/tracing-test.js'))(session);
|
| + InspectorTest.startTracingAndSaveAsStream(onStart);
|
| +
|
| + function onStart() {
|
| + session.evaluate(`
|
| + (function performActions()
|
| + {
|
| + var element = document.getElementById('test');
|
| + element.style.display = 'block';
|
| + var unused = element.clientWidth;
|
| + })();
|
| + `).then(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');
|
| + Protocol.IO.close({ handle: streamHandle }).then(onCloseDone);
|
| + }
|
| +
|
| + function onCloseDone(response) {
|
| + InspectorTest.log('Error after legit close: ' + JSON.stringify(response.error));
|
| + Protocol.IO.read({ handle: streamHandle }).then(onReadAfterClose);
|
| + }
|
| +
|
| + function onReadAfterClose(response) {
|
| + InspectorTest.log('Error after illegal read: ' + JSON.stringify(response.error));
|
| + Protocol.IO.close({ handle: streamHandle }).then(onCloseAfterClose);
|
| + }
|
| +
|
| + function onCloseAfterClose(response) {
|
| + InspectorTest.log('Error after illegal close: ' + JSON.stringify(response.error));
|
| + var trace = JSON.parse(data1);
|
| + performEventsSanityCheck(trace['traceEvents']);
|
| + InspectorTest.log('Metadata: ' + typeof trace['metadata'] + (trace['metadata'] ? ', not null' : ''));
|
| + InspectorTest.completeTest();
|
| + }
|
| + }
|
| +
|
| + 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['UpdateLayoutTree'], 1, 'Too few UpdateLayoutTree events');
|
| + assertGreaterOrEqual(knownEvents['Layout'], 1, 'Too few Layout events');
|
| + InspectorTest.log('Event sanity test done');
|
| + }
|
| +})();
|
|
|