Commit 4c1dd581 authored by loislo@chromium.org's avatar loislo@chromium.org

DevTools: switch Timeline frontend into buffered mode and remove the corresponding experiment.

All the tests were adjusted to the buffered mode.
Console.timeline also records timeline in buffered mode.

BUG=361045
R=yurys@chromium.org

Review URL: https://codereview.chromium.org/399043002

git-svn-id: svn://svn.chromium.org/blink/trunk@179113 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e126735a
......@@ -41,11 +41,12 @@ InspectorTest.timelineModel = function()
InspectorTest.startTimeline = function(callback)
{
InspectorTest._timelineRecords = [];
WebInspector.inspectorView.panel("timeline").toggleTimelineButton.toggled = true;
WebInspector.inspectorView.panel("timeline")._model._collectionEnabled = true;
WebInspector.inspectorView.panel("timeline")._model._currentTarget = WebInspector.targetManager.mainTarget();
TimelineAgent.start(5, false, undefined, true, false, callback);
var panel = WebInspector.inspectorView.panel("timeline");
panel.toggleTimelineButton.toggled = true;
panel._model._collectionEnabled = true;
panel._userInitiatedRecording = true;
panel._model._currentTarget = WebInspector.targetManager.mainTarget();
TimelineAgent.start(5, true, undefined, true, false, callback);
function addRecord(record)
{
InspectorTest._timelineRecords.push(record);
......@@ -59,34 +60,16 @@ InspectorTest.startTimeline = function(callback)
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
};
InspectorTest.waitForRecordType = function(recordType, callback)
{
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addEvent);
function addEvent(event)
{
addRecord(event.data);
}
function addRecord(record)
{
if (record.type !== WebInspector.TimelineModel.RecordType[recordType]) {
for (var i = 0; record.children && i < record.children.length; ++i)
addRecord(record.children[i]);
return;
}
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addEvent);
callback(record);
}
}
InspectorTest.stopTimeline = function(callback)
{
function didStop()
function didStop(error)
{
if (error)
testRunner.logToStderr("error: " + error);
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
WebInspector.inspectorView.panel("timeline").toggleTimelineButton.toggled = false;
WebInspector.inspectorView.panel("timeline")._model._collectionEnabled = false;
var panel = WebInspector.inspectorView.panel("timeline");
panel.toggleTimelineButton.toggled = false;
panel._userInitiatedRecording = false;
callback(InspectorTest._timelineRecords);
}
TimelineAgent.stop(didStop);
......@@ -141,6 +124,30 @@ InspectorTest.performActionsAndPrint = function(actions, typeName, includeTimeSt
InspectorTest.evaluateWithTimeline(actions, callback);
};
InspectorTest.filterTimelineRecords = function(typeName, firstOnly)
{
var filteredRecords = [];
filterRecords(typeName, InspectorTest._timelineRecords);
return filteredRecords;
function filterRecords(typeName, records)
{
if (!records)
return false;
for (var i = 0; i < records.length; ++i) {
var recordTypeName = (typeof records[i].type === "string") ? records[i].type : records[i].type();
if (typeName && recordTypeName === WebInspector.TimelineModel.RecordType[typeName]) {
filteredRecords.push(records[i]);
if (firstOnly)
return true;
}
if (filterRecords(typeName, records[i].children))
return true;
}
return false;
}
}
InspectorTest.printTimelineRecords = function(typeName, formatter)
{
InspectorTest.innerPrintTimelineRecords(InspectorTest._timelineRecords, typeName, formatter);
......
......@@ -5,11 +5,11 @@
<script src="network-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var xhr = new XMLHttpRequest();
xhr.open("GET", "network/resources/resource.php", true);
xhr.onload = function () { }; // This is necessary for XHRLoad event.
xhr.onload = callback; // This is necessary for XHRLoad event.
xhr.onreadystatechange = function () { }; // This is necessary for XHRReadyStateChange event.
xhr.send(null);
}
......@@ -19,11 +19,7 @@ function test()
InspectorTest.resetInspectorResourcesData(step1);
function step1()
{
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("XHRLoad", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
......@@ -5,13 +5,19 @@
<script src="network-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var xhr = new XMLHttpRequest();
xhr.responseType = "blob";
xhr.open("GET", "network/resources/resource.php", true);
xhr.onload = function () { }; // This is necessary for XHRLoad event.
xhr.onreadystatechange = function () { }; // This is necessary for XHRReadyStateChange event.
xhr.onload = function() { }; // This is necessary for XHRLoad event.
// assigning callback to onload doesn't work here due to exception in responseXML handling for blob response type.
xhr.onreadystatechange = done;
function done()
{
if (xhr.readyState === 4)
callback();
}
xhr.send(null);
}
......@@ -20,11 +26,7 @@ function test()
InspectorTest.resetInspectorResourcesData(step1);
function step1()
{
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("XHRLoad", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
CONSOLE WARNING: 'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead.
Tests the Timeline events for WebSocket
WebSocketCreate Properties:
......
<html>
<head>
<script src="/inspector/inspector-test.js"></script>
<script src="/inspector/timeline-test.js"></script>
<script src="../inspector-test.js"></script>
<script src="../timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var ws = new WebSocket("ws://127.0.0.1:8880/simple");
ws.onclose = callback;
}
function test()
{
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("WebSocketDestroy", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
Recording started
Timeline.stopped event has arrived.
Events:
FunctionCall
TimeStamp
Recording stopped
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>
function testFunction()
{
console.timeStamp("Timestamp");
}
function test()
{
InspectorTest.eventHandler["Timeline.eventRecorded"] = eventRecorded;
InspectorTest.eventHandler["Timeline.stopped"] = timelineStopped;
InspectorTest.log("Recording started");
InspectorTest.sendCommand("Timeline.start", { bufferEvents: true }, onStart);
function onStart(response)
{
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, didEvaluate);
}
function didEvaluate(response)
{
InspectorTest.sendCommand("Timeline.stop", {}, onStop);
}
function eventRecorded(event)
{
InspectorTest.log("FAIL: event recorded: " + event.params.record.type);
}
function timelineStopped(event)
{
InspectorTest.log("Timeline.stopped event has arrived.");
InspectorTest.assert(!event.params.consoleTimeline, "It souldn't be event forced by console.timelineEnd");
InspectorTest.log("Events:");
var events = event.params.events;
for (var i = 0; i < events.length; ++i)
dump(events[i], "");
}
function onStop(response)
{
InspectorTest.log("Recording stopped");
InspectorTest.completeTest();
}
function dump(event, prefix)
{
var eventTypes = { "FunctionCall":true, "TimeStamp":true, "TimerInstall":true, "TimerFire":true };
if (event.type in eventTypes)
InspectorTest.log(prefix + event.type);
for (var i = 0; event.children && i < event.children.length; ++i)
dump(event.children[i], " " + prefix);
}
}
</script>
</head>
<body onLoad="runTest();">
</body>
</html>
......@@ -33,14 +33,11 @@ Tests console.timeline and timelineEnd commands.
Running: testStartStopTimeline
Timeline started from console.
Timeline 'one' started.
timestamp 1
Timeline 'one' finished.
Timeline stopped from console.
Running: testStartStopMultiple
Timeline started from console.
Timeline 'one' started.
timestamp 1
Timeline 'one' started.
......@@ -53,10 +50,8 @@ timestamp 3
Timeline 'two' finished.
timestamp 4
Timeline 'one' finished.
Timeline stopped from console.
Running: testStartMultipleStopInsideEvals
Timeline started from console.
Timeline 'one' started.
timestamp 1
Timeline 'two' started.
......@@ -66,47 +61,35 @@ Timeline 'two' finished.
timestamp 4
timestamp 5
Timeline 'one' finished.
Timeline stopped from console.
Running: testStopUnknown
Timeline started from console.
Timeline 'one' started.
timestamp 1
timestamp 2
Timeline 'one' finished.
Timeline stopped from console.
Running: testStartFromPanel
Timeline started from panel
timestamp 0
Timeline 'one' started.
timestamp 1
Timeline 'one' finished.
timestamp 2
Timeline stopped from panel
Running: testStopFromPanel
Timeline started from console.
Timeline 'one' started.
timestamp 1
Timeline 'two' started.
timestamp 2
Timeline stopped from panel
Running: testRacyStart
Timeline started from console.
Timeline 'one' started.
timestamp 1
Timeline 'two' started.
timestamp 2
Timeline stopped from panel
Running: testRacyStart2
Timeline started from panel
timestamp 0
Timeline 'one' started.
timestamp 1
Timeline 'two' started.
timestamp 2
Timeline stopped from panel
......@@ -77,9 +77,10 @@ function startTimeline()
function test()
{
WebInspector.inspectorView.showPanel("timeline");
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, eventRecorded);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, timelineStopped);
var panel = WebInspector.inspectorView.panel("timeline");
panel._model._currentTarget = WebInspector.targetManager.mainTarget();
InspectorTest.runTestSuite([
function testStartStopTimeline(next)
......@@ -94,8 +95,7 @@ function test()
function testStartMultipleStopInsideEvals(next)
{
var panel = WebInspector.inspectorView.panel("timeline");
panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
InspectorTest.evaluateInPage("startMultiple()", step2);
......@@ -108,10 +108,10 @@ function test()
{
InspectorTest.evaluateInPage("stopOne()", function() {});
}
function recordingStopped()
function finish()
{
panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
next();
}
},
......@@ -123,9 +123,8 @@ function test()
function testStartFromPanel(next)
{
var panel = WebInspector.inspectorView.panel("timeline");
panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, recordingStarted);
panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
panel._toggleTimelineButtonClicked();
function recordingStarted()
......@@ -139,17 +138,16 @@ function test()
panel._toggleTimelineButtonClicked();
}
function recordingStopped()
function finish()
{
panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
next();
}
},
function testStopFromPanel(next)
{
var panel = WebInspector.inspectorView.panel("timeline");
panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
InspectorTest.evaluateInPage("startTimeline()", step2);
......@@ -158,59 +156,55 @@ function test()
panel._toggleTimelineButtonClicked();
}
function recordingStopped()
function finish()
{
panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, recordingStopped);
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
next();
}
},
function testRacyStart(next)
{
var panel = WebInspector.inspectorView.panel("timeline");
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, timelineStopped);
InspectorTest.evaluateInPage("startTimeline()");
panel._toggleTimelineButtonClicked();
function timelineStarted()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
panel._toggleTimelineButtonClicked();
}
function timelineStopped()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, timelineStopped);
setTimeout(next); // Fool listeners order so that timeline panel got this notification first.
}
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
InspectorTest.evaluateInPage("startTimeline()");
panel._toggleTimelineButtonClicked();
function timelineStarted()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
panel._toggleTimelineButtonClicked();
}
function finish()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
next();
}
},
function testRacyStart2(next)
{
var panel = WebInspector.inspectorView.panel("timeline");
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, timelineStopped);
panel._toggleTimelineButtonClicked();
InspectorTest.evaluateInPage("startTimeline()");
function timelineStarted()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
// Fool listener order execution.
setTimeout(panel._toggleTimelineButtonClicked.bind(panel));
}
function timelineStopped()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, timelineStopped);
setTimeout(next); // Fool listeners order so that timeline panel got this notification first.
}
}
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
panel._toggleTimelineButtonClicked();
InspectorTest.evaluateInPage("startTimeline()");
function timelineStarted()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, timelineStarted);
// Fool listener order execution.
setTimeout(panel._toggleTimelineButtonClicked.bind(panel));
}
function finish()
{
WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, finish);
next();
}
}
]);
function eventRecorded(event)
......@@ -225,16 +219,6 @@ function test()
}
print(event.data);
}
function timelineStarted(event)
{
InspectorTest.addResult("Timeline started from " + (event.data ? "console." : "panel"));
}
function timelineStopped(event)
{
InspectorTest.addResult("Timeline stopped from " + (event.data ? "console." : "panel"));
}
}
</script>
......
......@@ -20,8 +20,6 @@ sources onSelectionChanged fired, selectionInfo:
startLine : 0
url : .../edit-me.js
}
RUNNING TEST: extension_testTimelineEvents
Got Layout event from timeline
RUNNING TEST: extension_testViewShowHide
Got onShown event for sidebar
Sidebar shown, location: .../extension-sidebar.html
......
......@@ -152,24 +152,6 @@ function extension_testViewShowHide(nextTest)
webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
}
function extension_testTimelineEvents(nextTest)
{
function onTimelineEvent(record)
{
if (record.type === "Layout") {
output("Got Layout event from timeline");
webInspector.timeline.onEventRecorded.removeListener(onTimelineEvent);
nextTest();
return;
}
(record.children || []).forEach(onTimelineEvent);
}
webInspector.timeline.onEventRecorded.addListener(onTimelineEvent);
// Trigger a relayout.
webInspector.inspectedWindow.eval("document.body.style.float = 'left'; document.body.offsetTop;");
}
</script>
</head>
<body onload="runTest()">
......
......@@ -4,23 +4,20 @@
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var element = document.getElementById("animation");
var requestId = window.requestAnimationFrame(animationFrameCallback, element);
function animationFrameCallback()
{
window.cancelAnimationFrame(requestId);
callback();
}
}
function test()
{
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("CancelAnimationFrame", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
Tests extracting information about original functions from bound ones
FunctionCall InjectedScript:1
FunctionCall timeline-bound-function.html:7
......@@ -16,9 +16,7 @@ function performActions()
function test()
{
InspectorTest.startTimeline();
InspectorTest.waitForRecordType("FunctionCall", finish);
InspectorTest.evaluateInPage("performActions()");
InspectorTest.evaluateWithTimeline("performActions()", finish);
function finish()
{
......@@ -27,7 +25,8 @@ function test()
if (record.type === "FunctionCall") {
var scriptName = record.data.scriptName;
var scriptNameShort = scriptName.substring(scriptName.lastIndexOf("/") + 1);
InspectorTest.addResult(record.type + " " + scriptNameShort + ":" + record.data.scriptLine);
if (scriptNameShort !== "InjectedScript")
InspectorTest.addResult(record.type + " " + scriptNameShort + ":" + record.data.scriptLine);
}
}
InspectorTest.printTimelineRecords(null, formatter);
......
......@@ -6,20 +6,15 @@
function test()
{
finishCalled = 0;
InspectorTest.startTimeline(function() { InspectorTest.reloadPage(pageReloaded); });
InspectorTest.startTimeline(function() { InspectorTest.reloadPage(finish); });
InspectorTest.waitForRecordType("MarkDOMContent", contentEvent);
function contentEvent()
function pageReloaded()
{
InspectorTest.stopTimeline(finish);
}
function finish()
{
if (++finishCalled < 2)
return;
InspectorTest.printTimelineRecords("MarkDOMContent");
InspectorTest.completeTest();
}
......
......@@ -18,13 +18,12 @@ function test()
function validate(records)
{
for (var i = 0; i < records.length; ++i) {
var record = records[i];
if (record.type === WebInspector.TimelineModel.RecordType.GCEvent) {
InspectorTest.addResult("The expected GC event record");
InspectorTest.addObject(record, InspectorTest.timelinePropertyFormatters);
break;
}
var gcRecords = InspectorTest.filterTimelineRecords(WebInspector.TimelineModel.RecordType.GCEvent, true);
if (gcRecords.length) {
InspectorTest.addResult("The expected GC event record");
InspectorTest.addObject(gcRecords[0], InspectorTest.timelinePropertyFormatters);
} else {
InspectorTest.addResult("FAILED: GC event record wasn't found");
}
InspectorTest.completeTest();
......
......@@ -6,21 +6,15 @@
function test()
{
finishCalled = 0;
InspectorTest.startTimeline(function() { InspectorTest.reloadPage(pageReloaded); });
InspectorTest.startTimeline(function() { InspectorTest.reloadPage(finish); });
InspectorTest.waitForRecordType("MarkLoad", contentEvent);
function contentEvent()
function pageReloaded()
{
InspectorTest.stopTimeline(finish);
}
function finish()
{
if (++finishCalled !== 2)
return;
InspectorTest.addResult("Model records:");
InspectorTest.printTimelineRecords("MarkDOMContent");
InspectorTest.printTimelineRecords("MarkLoad");
......
......@@ -4,53 +4,46 @@
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
function onImageLoad()
{
window._imageLoaded = true;
if (window._scriptEvaluated)
callback();
}
function scriptEvaluated()
{
window._scriptEvaluated = true;
if (window._imageLoaded)
callback();
}
var image = new Image();
image.onload = onImageLoad;
image.src = "resources/anImage.png";
var script = document.createElement("script");
script.src = "timeline-network-resource.js";
document.body.appendChild(script);
window.timelineNetworkResourceEvaluated = scriptEvaluated;
}
function test()
{
var callbackBarrier = new CallbackBarrier();
var resourceReceivedCallback = callbackBarrier.createCallback();
// It will be called from timeline-network-resource.js script by evaluateInWebInspector call.
InspectorTest.scriptEvaluated = callbackBarrier.createCallback();
callbackBarrier.callWhenDone(done);
InspectorTest.invokeAsyncWithTimeline("performActions", done);
function done()
{
InspectorTest.addResult("Script evaluated.");
InspectorTest.addResult("Resource received data has length, test passed.");
InspectorTest.completeTest();
}
var calledOnce;
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("ResourceReceivedData", finish);
function finish(object)
{
for (var prop in object) {
if (!InspectorTest.timelinePropertyFormatters[prop]) {
for (var property in object[prop]) {
if (property === "encodedDataLength") {
if (!calledOnce) {
calledOnce = true;
resourceReceivedCallback();
}
return;
}
}
}
var filteredRecords = InspectorTest.filterTimelineRecords("ResourceReceivedData");
if (filteredRecords.length) {
var record = filteredRecords[0];
if (record.data && record.data && typeof record.data.encodedDataLength === "number")
InspectorTest.addResult("Resource received data has length, test passed.");
}
InspectorTest.completeTest();
}
}
......
......@@ -6,8 +6,9 @@
var scriptUrl = "timeline-network-resource.js";
function performActions()
function performActions(callback)
{
window.timelineNetworkResourceEvaluated = callback;
var script = document.createElement("script");
script.src = scriptUrl;
document.body.appendChild(script);
......@@ -21,20 +22,9 @@ function test()
var model = WebInspector.panels.timeline._model;
var presentationModel = InspectorTest.timelinePresentationModel();
InspectorTest.startTimeline(step1);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function step1()
{
InspectorTest.evaluateInPage("performActions()");
}
// It will be called from timeline-network-resource.js script by evaluateInWebInspector call.
InspectorTest.scriptEvaluated = function()
{
InspectorTest.stopTimeline(step3);
}
function step3()
function finish()
{
var lastRecordStartTime;
function format(record)
......
......@@ -4,4 +4,4 @@ var element = document.createElement("div");
element.innerHTML = "Script resource loaded";
document.body.appendChild(element);
testRunner.evaluateInWebInspector(1000, "InspectorTest.scriptEvaluated();");
\ No newline at end of file
window.timelineNetworkResourceEvaluated();
......@@ -24,31 +24,25 @@ function updateSubframeAndDisplay(callback)
function test()
{
step1();
InspectorTest.invokeAsyncWithTimeline("display", step1);
function step1()
function step1(records)
{
InspectorTest.invokeAsyncWithTimeline("display", step2);
}
function step2(records)
{
for (var i = 0; i < records.length; ++i) {
var record = records[i];
if (record.type === WebInspector.TimelineModel.RecordType.Paint) {
InspectorTest.printTimelineRecordProperties(record);
break;
}
}
var filteredRecords = InspectorTest.filterTimelineRecords(WebInspector.TimelineModel.RecordType.Paint, true);
if (filteredRecords.length)
InspectorTest.printTimelineRecordProperties(filteredRecords[0]);
else
InspectorTest.addResult("FAIL: no paint record found");
InspectorTest.invokeAsyncWithTimeline("updateSubframeAndDisplay", step3);
}
function step3(records)
{
var filteredRecords = InspectorTest.filterTimelineRecords(WebInspector.TimelineModel.RecordType.Paint, true);
var paintRecord;
for (var i = 0; i < records.length; ++i) {
var record = records[i];
if (record.type === WebInspector.TimelineModel.RecordType.Paint && record.children && record.children.length) {
for (var i = 0; i < filteredRecords.length; ++i) {
var record = filteredRecords[i];
if (record.children && record.children.length) {
paintRecord = record;
break;
}
......
......@@ -4,7 +4,7 @@
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var image = new Image();
image.onload = bar;
......@@ -12,7 +12,7 @@ function performActions()
function bar() {
var image = new Image();
image.onload = function() { testRunner.evaluateInWebInspector(0, "window.step2()"); }
image.onload = function(event) { callback(); } // do not pass event argument to the callback.
image.src = "resources/anotherImage.png";
}
}
......@@ -20,22 +20,10 @@ function performActions()
function test()
{
WebInspector.inspectorView.showPanel("timeline");
WebInspector.panels.timeline._model._collectionEnabled = true;
WebInspector.inspectorView.panel("timeline")._model._currentTarget = WebInspector.targetManager.mainTarget();
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
TimelineAgent.start(step1);
function step1()
{
InspectorTest.evaluateInPage("performActions()");
}
window.step2 = function()
{
TimelineAgent.stop(step3);
}
function step3()
function finish()
{
function dumpFormattedRecord(presentationRecord, prefix)
{
......@@ -54,8 +42,6 @@ function test()
dumpFormattedRecord(presentationRecord.presentationChildren()[i], childPrefix);
}
}
WebInspector.panels.timeline._model._collectionEnabled = false;
var records = WebInspector.panels.timeline._currentViews[0]._rootRecord().presentationChildren();
for (var i = 0; i < records.length; ++i)
dumpFormattedRecord(records[i]);
......
......@@ -6,7 +6,7 @@
function test()
{
function performActions()
function performActions(callback)
{
var timerOne = setTimeout("1 + 1", 10);
var timerTwo = setInterval(intervalTimerWork, 20);
......@@ -17,18 +17,15 @@ function test()
if (++iteration < 2)
return;
clearInterval(timerTwo);
callback();
}
}
InspectorTest.startTimeline(function() {
var source = performActions.toString();
source += "\n" +
"performActions();\n" +
"//@ sourceURL=performActions.js";
InspectorTest.evaluateInPage(source);
});
var source = performActions.toString();
source += "\n//@ sourceURL=performActions.js";
InspectorTest.evaluateInPage(source);
InspectorTest.waitForRecordType("TimerRemove", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
var linkifier = new WebInspector.Linkifier();
......
......@@ -51,6 +51,7 @@ function consoleTimeWithoutConsoleTimeEnd()
function test()
{
InspectorTest.startDumpingProtocolMessages();
InspectorTest.runTestSuite([
function testSimpleConsoleTime(next)
{
......
......@@ -4,13 +4,20 @@
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
window.callWhenDone = callback;
var content = "" +
"var fn2 = function() {console.markTimeline(\"Script evaluated\");};\\n" +
"var fn1 = function() {window.setTimeout(fn2, 1);};\\n" +
"window.setTimeout(fn1, 1);\\n"
content = "eval('" + content + "//# sourceURL=fromEval.js" + "');";
"var fn2 = function() {" +
" console.markTimeline(\"Script evaluated\");" +
" window.callWhenDone();" +
"};\\n" +
"var fn1 = function() {" +
" window.setTimeout(fn2, 1);" +
"};\\n" +
"window.setTimeout(fn1, 1);\\n" +
"//# sourceURL=fromEval.js";
content = "eval('" + content + "');";
var scriptElement = document.createElement('script');
var contentNode = document.createTextNode(content);
scriptElement.appendChild(contentNode);
......@@ -20,13 +27,7 @@ function performActions()
function test()
{
InspectorTest.startTimeline(start);
InspectorTest.waitForRecordType("TimeStamp", finish);
function start()
{
InspectorTest.evaluateInPage("performActions()");
}
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
......@@ -4,7 +4,7 @@
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script>
function performActions()
function performActions(callback)
{
var timerOne = setTimeout("1 + 1", 10);
var timerTwo = setInterval(intervalTimerWork, 20);
......@@ -15,16 +15,13 @@ function performActions()
if (++iteration < 2)
return;
clearInterval(timerTwo);
callback();
}
}
function test()
{
InspectorTest.startTimeline(function() {
InspectorTest.evaluateInPage("performActions()");
});
InspectorTest.waitForRecordType("TimerRemove", finish);
InspectorTest.invokeAsyncWithTimeline("performActions", finish);
function finish()
{
......
......@@ -7,7 +7,6 @@
function test()
{
WebInspector.experimentsSettings.timelineOnTraceEvents.enableForTest();
var timelineData = InspectorTest.timelineData();
WebInspector.inspectorView.showPanel("timeline");
......
......@@ -827,6 +827,9 @@ void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St
mainFrame()->console().addMessage(JSMessageSource, DebugMessageLevel, message, String(), 0, 0, nullptr, scriptState);
m_consoleTimelines.append(title);
if (!isStarted()) {
m_state->setBoolean(TimelineAgentState::bufferEvents, true);
m_bufferedEvents = TypeBuilder::Array<TimelineEvent>::create();
innerStart();
bool fromConsole = true;
m_frontend->started(&fromConsole);
......
......@@ -303,7 +303,6 @@ WebInspector.ExperimentsSettings = function(experimentsEnabled)
this.timelineOnTraceEvents = this._createExperiment("timelineOnTraceEvents", "Timeline on trace events", true);
this.timelinePowerProfiler = this._createExperiment("timelinePowerProfiler", "Timeline power profiler");
this.timelineJSCPUProfile = this._createExperiment("timelineJSCPUProfile", "Timeline with JS sampling");
this.timelineNoLiveUpdate = this._createExperiment("timelineNoLiveUpdate", "Timeline w/o live update", true);
this.workersInMainWindow = this._createExperiment("workersInMainWindow", "Workers in main window", true);
this._cleanUpSetting();
......
......@@ -46,6 +46,7 @@ WebInspector.TimelineManager.EventTypes = {
TimelineStarted: "TimelineStarted",
TimelineStopped: "TimelineStopped",
TimelineEventRecorded: "TimelineEventRecorded",
TimelineAllEventsReceived: "TimelineAllEventsReceived",
TimelineProgress: "TimelineProgress"
}
......@@ -60,13 +61,12 @@ WebInspector.TimelineManager.prototype = {
/**
* @param {number=} maxCallStackDepth
* @param {boolean=} bufferEvents
* @param {string=} liveEvents
* @param {boolean=} includeCounters
* @param {boolean=} includeGPUEvents
* @param {function(?Protocol.Error)=} callback
*/
start: function(maxCallStackDepth, bufferEvents, liveEvents, includeCounters, includeGPUEvents, callback)
start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEvents, callback)
{
this._enablementCount++;
this.target().profilingLock.acquire();
......@@ -76,7 +76,7 @@ WebInspector.TimelineManager.prototype = {
this.target().profilerAgent().start();
}
if (this._enablementCount === 1)
this.target().timelineAgent().start(maxCallStackDepth, bufferEvents, liveEvents, includeCounters, includeGPUEvents, callback);
this.target().timelineAgent().start(maxCallStackDepth, true, liveEvents, includeCounters, includeGPUEvents, callback);
else if (callback)
callback(null);
},
......@@ -102,7 +102,6 @@ WebInspector.TimelineManager.prototype = {
}
if (!this._enablementCount)
this.target().timelineAgent().stop(callbackBarrier.createCallback(timelineCallback));
TimelineAgent.stop(callbackBarrier.createCallback(timelineCallback));
callbackBarrier.callWhenDone(allDoneCallback.bind(this));
......@@ -135,14 +134,17 @@ WebInspector.TimelineManager.prototype = {
},
/**
* @param {boolean=} consoleTimeline
* @param {!Array.<!TimelineAgent.TimelineEvent>=} events
*/
_processBufferedEvents: function(events)
_stopped: function(consoleTimeline, events)
{
this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped, consoleTimeline);
if (events) {
for (var i = 0; i < events.length; ++i)
this._dispatcher.eventRecorded(events[i]);
}
this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, 0);
},
_configureCpuProfilerSamplingInterval: function()
......@@ -207,8 +209,7 @@ WebInspector.TimelineDispatcher.prototype = {
stopped: function(consoleTimeline, events)
{
this._started = false;
this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped, consoleTimeline);
this._manager._processBufferedEvents(events);
this._manager._stopped(consoleTimeline, events);
},
/**
......
......@@ -20,6 +20,7 @@ WebInspector.TimelineModelImpl = function()
WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this);
WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineStarted, this._onStarted, this);
WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineStopped, this._onStopped, this);
WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineAllEventsReceived, this._onAllEventsReceived, this);
WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineProgress, this._onProgress, this);
WebInspector.targetManager.observeTargets(this);
}
......@@ -60,7 +61,7 @@ WebInspector.TimelineModelImpl.prototype = {
WebInspector.TimelineModel.RecordType.DrawFrame,
WebInspector.TimelineModel.RecordType.RequestMainThreadFrame,
WebInspector.TimelineModel.RecordType.ActivateLayerTree ];
this._currentTarget.timelineManager.start(maxStackFrames, WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
this._currentTarget.timelineManager.start(maxStackFrames, liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
},
stopRecording: function()
......@@ -69,7 +70,7 @@ WebInspector.TimelineModelImpl.prototype = {
return;
if (!this._clientInitiatedRecording) {
this._currentTarget.timelineManager.start(undefined, undefined, undefined, undefined, undefined, stopTimeline.bind(this));
this._currentTarget.timelineManager.start(undefined, undefined, undefined, undefined, stopTimeline.bind(this));
return;
}
......@@ -129,17 +130,26 @@ WebInspector.TimelineModelImpl.prototype = {
var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
if (timelineManager.target() !== this._currentTarget)
return;
// If we were buffering events, discard those that got through, the real ones are coming!
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) {
this.reset();
this._currentTarget = timelineManager.target();
}
// We were buffering events, discard those that got through, the real ones are coming!
this.reset();
this._currentTarget = timelineManager.target();
if (event.data) {
// Stopped from console.
this._fireRecordingStopped(null, null);
}
},
/**
* @param {!WebInspector.Event} event
*/
_onAllEventsReceived: function(event)
{
var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
if (timelineManager.target() !== this._currentTarget)
return;
this._collectionEnabled = false;
},
/**
* @param {!WebInspector.Event} event
*/
......@@ -162,7 +172,6 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_fireRecordingStopped: function(error, cpuProfile)
{
this._collectionEnabled = false;
if (cpuProfile)
WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(this, cpuProfile);
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);
......
......@@ -280,7 +280,6 @@ WebInspector.TimelinePanel.prototype = {
this._lazyFrameModel = tracingFrameModel;
} else {
var frameModel = new WebInspector.TimelineFrameModel();
frameModel.setMergeRecords(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() || !this._recordingInProgress);
frameModel.addRecords(this._model.records());
this._lazyFrameModel = frameModel;
}
......@@ -706,7 +705,7 @@ WebInspector.TimelinePanel.prototype = {
{
this._userInitiatedRecording = userInitiated;
this._model.startRecording(this._captureStacksSetting.get(), this._captureMemorySetting.get(), this._captureLayersAndPicturesSetting && this._captureLayersAndPicturesSetting.get());
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() && this._lazyFrameModel)
if (this._lazyFrameModel)
this._lazyFrameModel.setMergeRecords(false);
for (var i = 0; i < this._overviewControls.length; ++i)
......@@ -802,8 +801,7 @@ WebInspector.TimelinePanel.prototype = {
_onRecordingStarted: function()
{
this._updateToggleTimelineButton(true);
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
this._updateProgress(WebInspector.UIString("%d events collected", 0));
this._updateProgress(WebInspector.UIString("%d events collected", 0));
},
_recordingInProgress: function()
......@@ -816,8 +814,6 @@ WebInspector.TimelinePanel.prototype = {
*/
_onRecordingProgress: function(event)
{
if (!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
return;
this._updateProgress(WebInspector.UIString("%d events collected", event.data));
},
......@@ -858,12 +854,11 @@ WebInspector.TimelinePanel.prototype = {
this._stopPending = false;
this._updateToggleTimelineButton(false);
if (this._lazyFrameModel) {
this._lazyFrameModel.reset();
if (this._tracingTimelineModel) {
this._lazyFrameModel.reset();
this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._tracingModel.sessionId());
this._overviewPane.update();
} else if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) {
this._lazyFrameModel.reset();
} else {
this._lazyFrameModel.addRecords(this._model.records());
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment