2010-10-01 Andrey Kosyakov <caseq@chromium.org>
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Oct 2010 13:43:02 +0000 (13:43 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Oct 2010 13:43:02 +0000 (13:43 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: [Extensions API] expose page load events timings
        Added webInspector.resources.getPageTimings()
        https://bugs.webkit.org/show_bug.cgi?id=45954

        * inspector/front-end/ExtensionAPI.js:
        (WebInspector.injectedExtensionAPI.Resources.prototype):
        (WebInspector.injectedExtensionAPI.Resources.prototype.getPageTimings):
        * inspector/front-end/ExtensionServer.js:
        (WebInspector.ExtensionServer):
        (WebInspector.ExtensionServer.prototype._onGetPageTimings):
        * inspector/front-end/HAREntry.js: Return page event timings as -1 if start or event time unknown.
        (WebInspector.HARLog.prototype._buildPages):
        (WebInspector.HARLog.prototype.buildMainResourceTimings):
        (WebInspector.HARLog.prototype._convertResource):
        (WebInspector.HARLog.prototype._pageEventTime):

2010-10-01  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: [Extensions API] expose page load events timings
        Added webInspector.resources.getPageTimings()
        https://bugs.webkit.org/show_bug.cgi?id=45954

        * inspector/extensions-api-expected.txt:
        * inspector/extensions-resources-expected.txt:
        * inspector/extensions-resources.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@68887 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/extensions-api-expected.txt
LayoutTests/inspector/extensions-resources-expected.txt
LayoutTests/inspector/extensions-resources.html
WebCore/ChangeLog
WebCore/inspector/front-end/ExtensionAPI.js
WebCore/inspector/front-end/ExtensionServer.js
WebCore/inspector/front-end/HAREntry.js

index 5cc426b..9668b36 100644 (file)
@@ -1,3 +1,15 @@
+2010-10-01  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Extensions API] expose page load events timings
+        Added webInspector.resources.getPageTimings()
+        https://bugs.webkit.org/show_bug.cgi?id=45954
+
+        * inspector/extensions-api-expected.txt:
+        * inspector/extensions-resources-expected.txt:
+        * inspector/extensions-resources.html:
+
 2010-10-01  Adam Roben  <aroben@apple.com>
 
         Remove the fixed test from the Skipped file, too
index 95d3a26..fda0842 100644 (file)
@@ -59,6 +59,7 @@ RUNNING TEST: extension_testAPI
         }
         getAll : <function>
         get : <function>
+        getPageTimings : <function>
     }
     onReset : {
         addListener : <function>
index 029cbb8..179d3cc 100644 (file)
@@ -15,6 +15,12 @@ resource: .../inspector/resources/audits-style1.css, type: stylesheet
 resource: .../inspector/resources/missing-image.png, type: other
 RUNNING TEST: extension_testGetInvalidResource
 Attempted to retrieve invalid resource: {"code":"E_NOTFOUND","description":"Object not found: %s","details":[2128506],"isError":true}
+RUNNING TEST: extension_testGetPageTimings
+Got callback from getPageTimings, pageTimings dump follows
+{
+    onContentLoad : <number>
+    onLoad : <number>
+}
 RUNNING TEST: extension_testResourceNotification
 Resource finished: .../LayoutTests/inspector/extensions-resources.html
 All tests done.
index a6a15b4..da9878f 100755 (executable)
@@ -42,6 +42,16 @@ function extension_testGetInvalidResource(nextTest)
     webInspector.resources.get(2128506, callbackAndNextTest(onResource, nextTest));
 }
 
+function extension_testGetPageTimings(nextTest)
+{
+    function onTimings(result)
+    {
+        output("Got callback from getPageTimings, pageTimings dump follows");
+        dumpObject(result, { onContentLoad: 1, onLoad: 1 });
+    }
+    webInspector.resources.getPageTimings(callbackAndNextTest(onTimings, nextTest));
+}
+
 function doXHR()
 {
     var xhr = new XMLHttpRequest();
index 8d2b65c..4682cc8 100644 (file)
@@ -1,3 +1,24 @@
+2010-10-01  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Extensions API] expose page load events timings
+        Added webInspector.resources.getPageTimings()
+        
+        https://bugs.webkit.org/show_bug.cgi?id=45954
+
+        * inspector/front-end/ExtensionAPI.js:
+        (WebInspector.injectedExtensionAPI.Resources.prototype):
+        (WebInspector.injectedExtensionAPI.Resources.prototype.getPageTimings):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype._onGetPageTimings):
+        * inspector/front-end/HAREntry.js: Return page event timings as -1 if start or event time unknown.
+        (WebInspector.HARLog.prototype._buildPages):
+        (WebInspector.HARLog.prototype.buildMainResourceTimings):
+        (WebInspector.HARLog.prototype._convertResource):
+        (WebInspector.HARLog.prototype._pageEventTime):
+
 2010-10-01  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Adam Roben.
index 64f5482..9062126 100644 (file)
@@ -123,6 +123,11 @@ Resources.prototype = {
     get: function(id, callback)
     {
         return extensionServer.sendRequest({ command: "getResources", id: id }, callback);
+    },
+
+    getPageTimings: function(callback)
+    {
+        return extensionServer.sendRequest({ command: "getPageTimings" }, callback);
     }
 }
 
index bdf3a25..c8a95a0 100644 (file)
@@ -38,6 +38,7 @@ WebInspector.ExtensionServer = function()
     this._registerHandler("subscribe", this._onSubscribe.bind(this));
     this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this));
     this._registerHandler("getResources", this._onGetResources.bind(this));
+    this._registerHandler("getPageTimings", this._onGetPageTimings.bind(this));
     this._registerHandler("createPanel", this._onCreatePanel.bind(this));
     this._registerHandler("createSidebarPane", this._onCreateSidebar.bind(this));
     this._registerHandler("log", this._onLog.bind(this));
@@ -265,6 +266,11 @@ WebInspector.ExtensionServer.prototype = {
         return response;
     },
 
+    _onGetPageTimings: function()
+    {
+        return (new WebInspector.HARLog()).buildMainResourceTimings();
+    },
+
     _onAddAuditCategory: function(request)
     {
         var category = new WebInspector.ExtensionAuditCategory(request.id, request.displayName, request.ruleCount);
index 85e4f59..2cf0740 100644 (file)
@@ -192,23 +192,31 @@ WebInspector.HARLog.prototype = {
                 startedDateTime: new Date(WebInspector.mainResource.startTime * 1000),
                 id: WebInspector.mainResource.documentURL,
                 title: "",
-                pageTimings: this._buildMainResourceTimings()
+                pageTimings: this.buildMainResourceTimings()
             }
         ];
     },
 
-    _buildMainResourceTimings: function()
+    buildMainResourceTimings: function()
     {
         var resourcesPanel = WebInspector.panels.resources;
         var startTime = WebInspector.mainResource.startTime;
         return {
-             onContentLoad: WebInspector.HAREntry._toMilliseconds(resourcesPanel.mainResourceDOMContentTime - startTime),
-             onLoad: WebInspector.HAREntry._toMilliseconds(resourcesPanel.mainResourceLoadTime - startTime),
+             onContentLoad: this._pageEventTime(resourcesPanel.mainResourceDOMContentTime),
+             onLoad: this._pageEventTime(resourcesPanel.mainResourceLoadTime),
         }
     },
 
     _convertResource: function(id)
     {
         return (new WebInspector.HAREntry(WebInspector.resources[id])).build();
+    },
+
+    _pageEventTime: function(time)
+    {
+        var startTime = WebInspector.mainResource.startTime;
+        if (time === -1 || startTime === -1)
+            return -1;
+        return WebInspector.HAREntry._toMilliseconds(time - startTime);
     }
 };