Diff
Modified: trunk/LayoutTests/ChangeLog (87398 => 87399)
--- trunk/LayoutTests/ChangeLog 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/LayoutTests/ChangeLog 2011-05-26 17:16:28 UTC (rev 87399)
@@ -1,3 +1,17 @@
+2011-05-26 Michael Schneider <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ WebInspector: Added tests for timeline data API in a inspector extension.
+ https://bugs.webkit.org/show_bug.cgi?id=61098
+
+ * inspector/extensions/extensions-api-expected.txt:
+ * inspector/extensions/extensions-events-expected.txt:
+ * inspector/extensions/extensions-events.html:
+ * inspector/timeline/timeline-test.js:
+ (initialize_Timeline.InspectorTest.startTimeline):
+ (initialize_Timeline.InspectorTest.stopTimeline):
+
2011-05-26 Adam Klein <[email protected]>
Unreviewed. Added baselines after r87387.
Modified: trunk/LayoutTests/inspector/extensions/extensions-api-expected.txt (87398 => 87399)
--- trunk/LayoutTests/inspector/extensions/extensions-api-expected.txt 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/LayoutTests/inspector/extensions/extensions-api-expected.txt 2011-05-26 17:16:28 UTC (rev 87399)
@@ -41,6 +41,12 @@
getHAR : <function>
addRequestHeaders : <function>
}
+ timeline : {
+ onEventRecorded : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ }
onReset : {
addListener : <function>
removeListener : <function>
Modified: trunk/LayoutTests/inspector/extensions/extensions-events-expected.txt (87398 => 87399)
--- trunk/LayoutTests/inspector/extensions/extensions-events-expected.txt 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/LayoutTests/inspector/extensions/extensions-events-expected.txt 2011-05-26 17:16:28 UTC (rev 87399)
@@ -16,5 +16,7 @@
Got onShown event for panel extension
Got onHidden event for panel extension
Got onShown event for panel elements
+RUNNING TEST: extension_testTimelineEvents
+Got Layout event from timeline
All tests done.
Modified: trunk/LayoutTests/inspector/extensions/extensions-events.html (87398 => 87399)
--- trunk/LayoutTests/inspector/extensions/extensions-events.html 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/LayoutTests/inspector/extensions/extensions-events.html 2011-05-26 17:16:28 UTC (rev 87399)
@@ -102,6 +102,23 @@
webInspector.panels.create("Test Panel", "extension-panel.png", "extension-panel.html", onPanelCreated);
}
+function extension_testTimelineEvents(nextTest)
+{
+ function onTimelineEvent(record)
+ {
+ if (record.type === "Layout") {
+ output("Got Layout event from timeline");
+ webInspector.timeline.onEventRecorded.removeListener(onTimelineEvent);
+ nextTest();
+ }
+ }
+
+ webInspector.timeline.onEventRecorded.addListener(onTimelineEvent);
+
+ // Trigger a relayout.
+ webInspector.inspectedWindow.eval("document.body.style.float = 'left';");
+}
+
</script>
</head>
<body _onload_="runTest()">
Modified: trunk/LayoutTests/inspector/timeline/timeline-test.js (87398 => 87399)
--- trunk/LayoutTests/inspector/timeline/timeline-test.js 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/LayoutTests/inspector/timeline/timeline-test.js 2011-05-26 17:16:28 UTC (rev 87399)
@@ -18,6 +18,7 @@
InspectorTest.startTimeline = function(callback)
{
InspectorTest._timelineRecords = [];
+ WebInspector.panels.timeline.toggleTimelineButton.toggled = true;
TimelineAgent.start(callback);
function addRecord(record)
{
@@ -25,13 +26,16 @@
for (var i = 0; record.children && i < record.children.length; ++i)
addRecord(record.children[i]);
}
- InspectorTest.addSniffer(WebInspector.TimelineDispatcher.prototype, "eventRecorded", addRecord, true);
+ WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, function(event) {
+ addRecord(event.data);
+ });
};
InspectorTest.stopTimeline = function(callback)
{
function didStop()
{
+ WebInspector.panels.timeline.toggleTimelineButton.toggled = false;
callback(InspectorTest._timelineRecords);
}
TimelineAgent.stop(didStop);
Modified: trunk/Source/WebCore/ChangeLog (87398 => 87399)
--- trunk/Source/WebCore/ChangeLog 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/ChangeLog 2011-05-26 17:16:28 UTC (rev 87399)
@@ -1,3 +1,37 @@
+2011-05-26 Michael Schneider <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ WebInspector: Added API to access the timeline data in a inspector extension.
+ https://bugs.webkit.org/show_bug.cgi?id=61098
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/front-end/ExtensionAPI.js:
+ (WebInspector.injectedExtensionAPI.InspectorExtensionAPI):
+ (WebInspector.injectedExtensionAPI):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer):
+ (WebInspector.ExtensionServer.prototype._addRecordToTimeline):
+ (WebInspector.ExtensionServer.prototype._onSubscribe):
+ (WebInspector.ExtensionServer.prototype._onUnsubscribe):
+ (WebInspector.ExtensionServer.prototype._registerHandler):
+ (WebInspector.ExtensionServer.prototype._registerSubscriptionHandler):
+ * inspector/front-end/TimelineManager.js: Added.
+ (WebInspector.TimelineManager):
+ (WebInspector.TimelineManager.prototype.start):
+ (WebInspector.TimelineManager.prototype.stop):
+ (WebInspector.TimelineDispatcher):
+ (WebInspector.TimelineDispatcher.prototype.started):
+ (WebInspector.TimelineDispatcher.prototype.stopped):
+ (WebInspector.TimelineDispatcher.prototype.eventRecorded):
+ * inspector/front-end/TimelinePanel.js:
+ (WebInspector.TimelinePanel):
+ (WebInspector.TimelinePanel.prototype._toggleTimelineButtonClicked):
+ (WebInspector.TimelinePanel.prototype._onTimelineEventRecorded):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+
2011-05-26 Andrey Kosyakov <[email protected]>
Reviewed by Yury Semikhatsky.
Modified: trunk/Source/WebCore/WebCore.gypi (87398 => 87399)
--- trunk/Source/WebCore/WebCore.gypi 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/WebCore.gypi 2011-05-26 17:16:28 UTC (rev 87399)
@@ -6273,6 +6273,7 @@
'inspector/front-end/TextPrompt.js',
'inspector/front-end/TextViewer.js',
'inspector/front-end/TimelineAgent.js',
+ 'inspector/front-end/TimelineManager.js',
'inspector/front-end/TimelineOverviewPane.js',
'inspector/front-end/TimelineGrid.js',
'inspector/front-end/TimelinePanel.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (87398 => 87399)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-05-26 17:16:28 UTC (rev 87399)
@@ -67973,6 +67973,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\TimelineManager.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\TimelineOverviewPane.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (87398 => 87399)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2011-05-26 17:16:28 UTC (rev 87399)
@@ -91,6 +91,7 @@
this.inspectedWindow = new InspectedWindow();
this.panels = new Panels();
this.resources = new Resources();
+ this.timeline = new Timeline();
this._onReset_ = new EventSink("reset");
}
@@ -378,6 +379,11 @@
}
}
+function TimelineImpl()
+{
+ this._onEventRecorded_ = new EventSink("timeline-event-recorded");
+}
+
function ExtensionServerClient()
{
this._callbacks = {};
@@ -484,6 +490,7 @@
var Panel = declareInterfaceClass(PanelImpl);
var PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl);
var Resource = declareInterfaceClass(ResourceImpl);
+var Timeline = declareInterfaceClass(TimelineImpl);
var extensionServer = new ExtensionServerClient();
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (87398 => 87399)
--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2011-05-26 17:16:28 UTC (rev 87399)
@@ -33,6 +33,8 @@
this._clientObjects = {};
this._handlers = {};
this._subscribers = {};
+ this._subscriptionStartHandlers = {};
+ this._subscriptionStopHandlers = {};
this._extraHeaders = {};
this._resources = {};
this._lastResourceId = 0;
@@ -55,10 +57,19 @@
this._registerHandler("subscribe", this._onSubscribe.bind(this));
this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this));
+ this._registerSubscriptionHandler("timeline-event-recorded", WebInspector.timelineManager.start.bind(WebInspector.timelineManager), WebInspector.timelineManager.stop.bind(WebInspector.timelineManager));
+
window.addEventListener("message", this._onWindowMessage.bind(this), false);
+
+ WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._addRecordToTimeline, this);
}
WebInspector.ExtensionServer.prototype = {
+ _addRecordToTimeline: function(event)
+ {
+ this._postNotification("timeline-event-recorded", event.data);
+ },
+
notifyObjectSelected: function(panelId, objectId)
{
this._postNotification("panel-objectSelected-" + panelId, objectId);
@@ -141,8 +152,11 @@
var subscribers = this._subscribers[message.type];
if (subscribers)
subscribers.push(port);
- else
+ else {
this._subscribers[message.type] = [ port ];
+ if (this._subscriptionStartHandlers[message.type])
+ this._subscriptionStartHandlers[message.type]()
+ }
},
_onUnsubscribe: function(message, port)
@@ -151,8 +165,11 @@
if (!subscribers)
return;
subscribers.remove(port);
- if (!subscribers.length)
+ if (!subscribers.length) {
delete this._subscribers[message.type];
+ if (this._subscriptionStopHandlers[message.type])
+ this._subscriptionStopHandlers[message.type]()
+ }
},
_onAddRequestHeaders: function(message)
@@ -446,6 +463,12 @@
_registerHandler: function(command, callback)
{
this._handlers[command] = callback;
+ },
+
+ _registerSubscriptionHandler: function(eventTopic, onSubscribeFirst, onUnsubscribeLast)
+ {
+ this._subscriptionStartHandlers[eventTopic] = onSubscribeFirst;
+ this._subscriptionStopHandlers[eventTopic] = onUnsubscribeLast;
}
}
Added: trunk/Source/WebCore/inspector/front-end/TimelineManager.js (0 => 87399)
--- trunk/Source/WebCore/inspector/front-end/TimelineManager.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/TimelineManager.js 2011-05-26 17:16:28 UTC (rev 87399)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.TimelineManager = function()
+{
+ WebInspector.Object.call(this);
+ this._dispatcher = new WebInspector.TimelineDispatcher(this);
+ this._enablementCount = 0;
+}
+
+WebInspector.TimelineManager.EventTypes = {
+ TimelineStarted: "TimelineStarted",
+ TimelineStopped: "TimelineStopped",
+ TimelineEventRecorded: "TimelineEventRecorded"
+}
+
+WebInspector.TimelineManager.prototype = {
+ start: function()
+ {
+ this._enablementCount++;
+ if (this._enablementCount === 1)
+ TimelineAgent.start();
+ },
+
+ stop: function()
+ {
+ if (!this._enablementCount) {
+ console.error("WebInspector.TimelineManager start/stop calls are unbalanced");
+ return;
+ }
+ this._enablementCount--;
+ if (!this._enablementCount)
+ TimelineAgent.stop();
+ }
+}
+
+WebInspector.TimelineManager.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.TimelineDispatcher = function(manager)
+{
+ this._manager = manager;
+ InspectorBackend.registerDomainDispatcher("Timeline", this);
+}
+
+WebInspector.TimelineDispatcher.prototype = {
+ started: function()
+ {
+ this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStarted);
+ },
+
+ stopped: function()
+ {
+ this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped);
+ },
+
+ eventRecorded: function(record)
+ {
+ this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, record);
+ }
+}
+
+WebInspector.timelineManager = new WebInspector.TimelineManager();
Property changes on: trunk/Source/WebCore/inspector/front-end/TimelineManager.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/TimelinePanel.js (87398 => 87399)
--- trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2011-05-26 17:16:28 UTC (rev 87399)
@@ -99,7 +99,7 @@
this._markTimelineRecords = [];
this._expandOffset = 15;
- InspectorBackend.registerDomainDispatcher("Timeline", new WebInspector.TimelineDispatcher(this));
+ WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this);
}
// Define row height, should be in sync with styles for timeline graphs.
@@ -273,11 +273,12 @@
_toggleTimelineButtonClicked: function()
{
if (this.toggleTimelineButton.toggled)
- TimelineAgent.stop();
+ WebInspector.timelineManager.stop();
else {
this._clearPanel();
- TimelineAgent.start();
+ WebInspector.timelineManager.start();
}
+ this.toggleTimelineButton.toggled = !this.toggleTimelineButton.toggled;
},
_toggleFilterButtonClicked: function()
@@ -293,16 +294,12 @@
ProfilerAgent.collectGarbage();
},
- _timelineProfilerWasStarted: function()
+ _onTimelineEventRecorded: function(event)
{
- this.toggleTimelineButton.toggled = true;
+ if (this.toggleTimelineButton.toggled)
+ this._addRecordToTimeline(event.data);
},
- _timelineProfilerWasStopped: function()
- {
- this.toggleTimelineButton.toggled = false;
- },
-
_addRecordToTimeline: function(record)
{
if (record.type === WebInspector.TimelineAgent.RecordType.ResourceSendRequest) {
@@ -660,28 +657,6 @@
WebInspector.TimelinePanel.prototype.__proto__ = WebInspector.Panel.prototype;
-WebInspector.TimelineDispatcher = function(timelinePanel)
-{
- this._timelinePanel = timelinePanel;
-}
-
-WebInspector.TimelineDispatcher.prototype = {
- started: function()
- {
- this._timelinePanel._timelineProfilerWasStarted();
- },
-
- stopped: function()
- {
- this._timelinePanel._timelineProfilerWasStopped();
- },
-
- eventRecorded: function(record)
- {
- this._timelinePanel._addRecordToTimeline(record);
- }
-}
-
WebInspector.TimelineCategory = function(name, title, color)
{
this.name = name;
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (87398 => 87399)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-05-26 17:16:28 UTC (rev 87399)
@@ -115,6 +115,7 @@
<file>TextPrompt.js</file>
<file>TextViewer.js</file>
<file>TimelineAgent.js</file>
+ <file>TimelineManager.js</file>
<file>TimelineGrid.js</file>
<file>TimelineOverviewPane.js</file>
<file>TimelinePanel.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (87398 => 87399)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2011-05-26 17:11:49 UTC (rev 87398)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2011-05-26 17:16:28 UTC (rev 87399)
@@ -65,6 +65,7 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""