Diff
Modified: trunk/LayoutTests/ChangeLog (91251 => 91252)
--- trunk/LayoutTests/ChangeLog 2011-07-19 13:11:32 UTC (rev 91251)
+++ trunk/LayoutTests/ChangeLog 2011-07-19 13:45:04 UTC (rev 91252)
@@ -1,3 +1,13 @@
+2011-07-19 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: implement import/export for timeline data.
+ https://bugs.webkit.org/show_bug.cgi?id=64601
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/timeline/timeline-load-expected.txt: Added.
+ * inspector/timeline/timeline-load.html: Added.
+
2011-07-19 Gabor Loki <[email protected]>
[Qt] Add missing expected file after r91191
Added: trunk/LayoutTests/inspector/timeline/timeline-load-expected.txt (0 => 91252)
--- trunk/LayoutTests/inspector/timeline/timeline-load-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/timeline/timeline-load-expected.txt 2011-07-19 13:45:04 UTC (rev 91252)
@@ -0,0 +1,4 @@
+Tests the Timeline save/load functionality.
+
+passed
+
Property changes on: trunk/LayoutTests/inspector/timeline/timeline-load-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/timeline/timeline-load.html (0 => 91252)
--- trunk/LayoutTests/inspector/timeline/timeline-load.html (rev 0)
+++ trunk/LayoutTests/inspector/timeline/timeline-load.html 2011-07-19 13:45:04 UTC (rev 91252)
@@ -0,0 +1,51 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+ WebInspector.showPanel("timeline");
+ InspectorTest.addSniffer(WebInspector.TimelineModel.prototype, "_importNextChunk", importNextChunk);
+ InspectorFrontendHost.saveAs = saveAs;
+ var data = [
+ {"startTime":1310749854316.8408,"data":{"identifier":43,"url":"http://www.webkit.org/","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":1819936,"totalHeapSize":7629120},
+ {"startTime":1310749855118.9329,"data":{"identifier":43,"statusCode":200,"mimeType":"text/html"},"children":[],"endTime":1310749855118.968,"type":"ResourceReceiveResponse","usedHeapSize":1819936,"totalHeapSize":7629120},
+ {"startTime":1310749855136.245,"data":{"identifier":44,"url":"http://www.webkit.org/css/main.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855136.655,"data":{"identifier":45,"url":"http://www.webkit.org/css/green.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855137.023,"data":{"identifier":46,"url":"http://www.webkit.org/css/blue.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855137.342,"data":{"identifier":47,"url":"http://www.webkit.org/css/yellow.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855137.656,"data":{"identifier":48,"url":"http://www.webkit.org/css/pink.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855137.989,"data":{"identifier":49,"url":"http://www.webkit.org/css/purple.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
+ {"startTime":1310749855138.308,"data":{"identifier":50,"url":"http://www.webkit.org/css/gray.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120}];
+
+ WebInspector.panels.timeline._model._importNextChunk(data, 0);
+
+ function importNextChunk()
+ {
+ WebInspector.panels.timeline._model._exportToFile();
+ }
+
+ function saveAs(name, saveData)
+ {
+ saveData = JSON.parse(saveData);
+ saveData.shift(); // strip version info
+ if (JSON.stringify(data) == JSON.stringify(saveData))
+ InspectorTest.addResult("passed");
+ else
+ InspectorTest.addResult("saved data is not equal to restored");
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests the Timeline save/load functionality.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/timeline/timeline-load.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (91251 => 91252)
--- trunk/Source/WebCore/ChangeLog 2011-07-19 13:11:32 UTC (rev 91251)
+++ trunk/Source/WebCore/ChangeLog 2011-07-19 13:45:04 UTC (rev 91252)
@@ -1,3 +1,33 @@
+2011-07-19 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: implement import/export for timeline data.
+ https://bugs.webkit.org/show_bug.cgi?id=64601
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: inspector/timeline/timeline-load.html
+
+ * English.lproj/localizedStrings.js:
+ * inspector/InspectorFrontendHost.cpp:
+ (WebCore::FrontendMenuProvider::contextMenuItemSelected):
+ * inspector/front-end/TimelinePanel.js:
+ (WebInspector.TimelinePanel):
+ (WebInspector.TimelinePanel.prototype._createFileSelector):
+ (WebInspector.TimelinePanel.prototype._contextMenu):
+ (WebInspector.TimelinePanel.prototype._exportToFile):
+ (WebInspector.TimelinePanel.prototype._importFromFile):
+ (WebInspector.TimelinePanel.prototype._addRecordToTimeline):
+ (WebInspector.TimelinePanel.prototype._clearPanel):
+ (WebInspector.TimelineModel):
+ (WebInspector.TimelineModel.prototype._addRecord):
+ (WebInspector.TimelineModel.prototype._importNextChunk):
+ (WebInspector.TimelineModel.prototype._importFromFile):
+ (WebInspector.TimelineModel.prototype._importFromFile.onError):
+ (WebInspector.TimelineModel.prototype._exportToFile):
+ (WebInspector.TimelineModel.prototype._reset):
+ * inspector/front-end/utilities.js:
+ ():
+
2011-07-19 Vsevolod Vlasov <[email protected]>
Web Inspector: Rename agentIdentifierPrefix to processId, move out from page agent and make static.
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (91251 => 91252)
--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2011-07-19 13:11:32 UTC (rev 91251)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2011-07-19 13:45:04 UTC (rev 91252)
@@ -47,6 +47,7 @@
#include "Page.h"
#include "Pasteboard.h"
#include "ScriptFunctionCall.h"
+#include "UserGestureIndicator.h"
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
@@ -91,6 +92,7 @@
virtual void contextMenuItemSelected(ContextMenuItem* item)
{
if (m_frontendHost) {
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
ScriptFunctionCall function(m_webInspector, "contextMenuItemSelected");
Modified: trunk/Source/WebCore/inspector/front-end/TimelinePanel.js (91251 => 91252)
--- trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2011-07-19 13:11:32 UTC (rev 91251)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2011-07-19 13:45:04 UTC (rev 91252)
@@ -33,6 +33,7 @@
WebInspector.Panel.call(this, "timeline");
this.element.appendChild(this._createTopPane());
+ this.element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
this.element.tabIndex = 0;
this._sidebarBackgroundElement = document.createElement("div");
@@ -100,6 +101,9 @@
this._timeStampRecords = [];
this._expandOffset = 15;
+ this._createFileSelector();
+ this._model = new WebInspector.TimelineModel(this);
+
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this);
}
@@ -217,6 +221,43 @@
this.recordsCounter.className = "timeline-records-counter";
},
+ _createFileSelector: function()
+ {
+ if (this._fileSelectorElement)
+ this.element.removeChild(this._fileSelectorElement);
+
+ var fileSelectorElement = document.createElement("input");
+ fileSelectorElement.type = "file";
+ fileSelectorElement.style.opacity = 0;
+ fileSelectorElement._onchange_ = this._importFromFile.bind(this);
+ this.element.appendChild(fileSelectorElement);
+ this._fileSelectorElement = fileSelectorElement;
+ },
+
+ _contextMenu: function(event)
+ {
+ var contextMenu = new WebInspector.ContextMenu();
+ contextMenu.appendItem(WebInspector.UIString("&Export Timeline data\u2026"), this._exportToFile.bind(this));
+ contextMenu.appendItem(WebInspector.UIString("&Import Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement));
+ contextMenu.show(event);
+ },
+
+ _exportToFile: function()
+ {
+ this._model._exportToFile();
+ },
+
+ _importFromFile: function()
+ {
+ if (this.toggleTimelineButton.toggled)
+ WebInspector.timelineManager.stop();
+
+ this._clearPanel();
+
+ this._model._importFromFile(this._fileSelectorElement.files[0]);
+ this._createFileSelector();
+ },
+
_updateRecordsCounter: function()
{
this.recordsCounter.textContent = WebInspector.UIString("%d of %d captured records are visible", this._rootRecord._visibleRecordsCount, this._rootRecord._allRecordsCount);
@@ -314,6 +355,7 @@
this._clearPanel();
}
}
+ this._model._addRecord(record);
this._innerAddRecordToTimeline(record, this._rootRecord);
this._scheduleRefresh();
},
@@ -444,6 +486,7 @@
this._adjustScrollPosition(0);
this._refresh();
this._closeRecordDetails();
+ this._model._reset();
},
show: function()
@@ -1172,3 +1215,72 @@
this._element.parentElement.removeChild(this._element);
}
}
+
+WebInspector.TimelineModel = function(timelinePanel)
+{
+ this._panel = timelinePanel;
+ this._records = [];
+}
+
+WebInspector.TimelineModel.prototype = {
+ _addRecord: function(record)
+ {
+ this._records.push(record);
+ },
+
+ _importNextChunk: function(data, index)
+ {
+ for (var i = 0; i < 20 && index < data.length; ++i, ++index)
+ this._panel._addRecordToTimeline(data[index]);
+
+ if (index !== data.length)
+ setTimeout(this._importNextChunk.bind(this, data, index), 0);
+ },
+
+ _importFromFile: function(file)
+ {
+ function onLoad(e)
+ {
+ var data = ""
+ var version = data[0];
+ this._importNextChunk(data, 1);
+ }
+
+ function onError(e)
+ {
+ switch(e.target.error.code) {
+ case e.target.error.NOT_FOUND_ERR:
+ WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" not found.', file.name));
+ break;
+ case e.target.error.NOT_READABLE_ERR:
+ WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" is not readable', file.name));
+ break;
+ case e.target.error.ABORT_ERR:
+ break;
+ default:
+ WebInspector.log(WebInspector.UIString('Timeline.importFromFile: An error occurred while reading the file "%s"', file.name));
+ }
+ }
+
+ var reader = new FileReader();
+ reader._onload_ = onLoad.bind(this);
+ reader._onerror_ = onError;
+ reader.readAsText(file);
+ },
+
+ _exportToFile: function()
+ {
+ var records = ['[' + JSON.stringify(window.navigator.appVersion)];
+ for (var i = 0; i < this._records.length - 1; ++i)
+ records.push(JSON.stringify(this._records[i]));
+ records.push(JSON.stringify(this._records[this._records.length - 1]) + "]");
+
+ var now= new Date();
+ InspectorFrontendHost.saveAs("TimelineRawData-" + now.toRFC3339() + ".json", records.join(",\n"));
+ },
+
+ _reset: function()
+ {
+ this._records = [];
+ }
+}
Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (91251 => 91252)
--- trunk/Source/WebCore/inspector/front-end/utilities.js 2011-07-19 13:11:32 UTC (rev 91251)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js 2011-07-19 13:45:04 UTC (rev 91252)
@@ -688,6 +688,23 @@
return num;
}
+Date.prototype.toRFC3339 = function()
+{
+ function leadZero(x)
+ {
+ return x > 9 ? x : '0' + x
+ }
+ var offset = Math.abs(this.getTimezoneOffset());
+ var offsetString = Math.floor(offset / 60) + ':' + leadZero(offset % 60);
+ return this.getFullYear() + '-' +
+ leadZero(this.getMonth() + 1) + '-' +
+ leadZero(this.getDate()) + 'T' +
+ leadZero(this.getHours()) + ':' +
+ leadZero(this.getMinutes()) + ':' +
+ leadZero(this.getSeconds()) +
+ (!offset ? "Z" : (this.getTimezoneOffset() > 0 ? '-' : '+') + offsetString);
+}
+
HTMLTextAreaElement.prototype.moveCursorToEnd = function()
{
var length = this.value.length;