Changeset 67615 in webkit
- Timestamp:
- Sep 16, 2010 6:56:43 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r67614 r67615 1 2010-09-16 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: [Resources panel] [HAR] Need a way to save timing data. 6 Added support to export HAR to file from Resources panel (conditional on Preferences) 7 Added support for HARLog (a higher-level aggregate than HAREntry) 8 https://bugs.webkit.org/show_bug.cgi?id=45663 9 10 * English.lproj/localizedStrings.js: 11 * inspector/front-end/HAREntry.js: 12 (WebInspector.HAREntry.prototype.build): 13 (WebInspector.HAREntry.prototype._buildTimings): 14 (WebInspector.HAREntry._toMilliseconds): 15 (WebInspector.HARLog): 16 (WebInspector.HARLog.prototype.build): 17 (WebInspector.HARLog.prototype._buildPages): 18 (WebInspector.HARLog.prototype._buildMainResourceTimings): 19 (WebInspector.HARLog.prototype._convertResource): 20 * inspector/front-end/ResourcesPanel.js: 21 (WebInspector.ResourcesPanel): 22 (WebInspector.ResourcesPanel.prototype.hide): 23 (WebInspector.ResourcesPanel.prototype._contextMenu): 24 (WebInspector.ResourcesPanel.prototype._exportAll): 25 (WebInspector.ResourcesPanel.prototype._exportResource): 26 * inspector/front-end/Settings.js: 27 * inspector/front-end/utilities.js: 28 (): 29 1 30 2010-09-16 Eric Uhrhane <ericu@chromium.org> 2 31 -
trunk/WebCore/inspector/front-end/HAREntry.js
r67474 r67615 43 43 pageref: this._resource.documentURL, 44 44 startedDateTime: new Date(this._resource.startTime * 1000), 45 time: this._toMilliseconds(this._resource.duration),45 time: WebInspector.HAREntry._toMilliseconds(this._resource.duration), 46 46 request: this._buildRequest(), 47 47 response: this._buildResponse(), … … 122 122 send: send, 123 123 wait: this._interval("sendEnd", "receiveHeadersEnd"), 124 receive: this._toMilliseconds(this._resource.receiveDuration),124 receive: WebInspector.HAREntry._toMilliseconds(this._resource.receiveDuration), 125 125 ssl: ssl 126 126 }; … … 149 149 { 150 150 return parameters.slice(); 151 },152 153 _toMilliseconds: function(time)154 {155 return time === -1 ? -1 : Math.round(time * 1000);156 151 }, 157 152 … … 165 160 } 166 161 }; 162 163 WebInspector.HAREntry._toMilliseconds = function(time) 164 { 165 return time === -1 ? -1 : Math.round(time * 1000); 166 } 167 168 WebInspector.HARLog = function() 169 { 170 } 171 172 WebInspector.HARLog.prototype = { 173 build: function() 174 { 175 var webKitVersion = /AppleWebKit\/([^ ]+)/.exec(window.navigator.userAgent); 176 177 return { 178 version: "1.2", 179 creator: { 180 name: "WebInspector", 181 version: webKitVersion ? webKitVersion[1] : "n/a" 182 }, 183 pages: this._buildPages(), 184 entries: Object.properties(WebInspector.resources).map(this._convertResource) 185 } 186 }, 187 188 _buildPages: function() 189 { 190 return [ 191 { 192 startedDateTime: new Date(WebInspector.mainResource.startTime * 1000), 193 id: WebInspector.mainResource.documentURL, 194 title: "", 195 pageTimings: this._buildMainResourceTimings() 196 } 197 ]; 198 }, 199 200 _buildMainResourceTimings: function() 201 { 202 var resourcesPanel = WebInspector.panels.resources; 203 var startTime = WebInspector.mainResource.startTime; 204 return { 205 onContentLoad: WebInspector.HAREntry._toMilliseconds(resourcesPanel.mainResourceDOMContentTime - startTime), 206 onLoad: WebInspector.HAREntry._toMilliseconds(resourcesPanel.mainResourceLoadTime - startTime), 207 } 208 }, 209 210 _convertResource: function(id) 211 { 212 return (new WebInspector.HAREntry(WebInspector.resources[id])).build(); 213 } 214 }; -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r66087 r67615 48 48 this.graphsTreeElement.children[0].select(); 49 49 this._resourceTrackingEnabled = false; 50 51 this.sidebarElement.addEventListener("contextmenu", this._contextMenu.bind(this), true); 50 52 } 51 53 … … 877 879 WebInspector.Panel.prototype.hide.call(this); 878 880 this._popoverHelper.hidePopup(); 881 }, 882 883 _contextMenu: function(event) 884 { 885 // createBlobURL is enabled conditionally, do not expose resource export if it's not available. 886 if (typeof window.createBlobURL !== "function" || !Preferences.resourceExportEnabled) 887 return; 888 889 var contextMenu = new WebInspector.ContextMenu(); 890 var resourceTreeItem = event.target.enclosingNodeOrSelfWithClass("resource-sidebar-tree-item"); 891 if (resourceTreeItem && resourceTreeItem.treeElement) { 892 var resource = resourceTreeItem.treeElement.representedObject; 893 contextMenu.appendItem(WebInspector.UIString("Export to HAR"), this._exportResource.bind(this, resource)); 894 } 895 contextMenu.appendItem(WebInspector.UIString("Export all to HAR"), this._exportAll.bind(this)); 896 contextMenu.show(event); 897 }, 898 899 _exportAll: function() 900 { 901 var harArchive = { 902 log: (new WebInspector.HARLog()).build() 903 } 904 offerFileForDownload(JSON.stringify(harArchive)); 905 }, 906 907 _exportResource: function(resource) 908 { 909 var har = (new WebInspector.HAREntry(resource)).build(); 910 offerFileForDownload(JSON.stringify(har)); 879 911 } 880 912 } -
trunk/WebCore/inspector/front-end/Settings.js
r67547 r67615 45 45 auditsPanelEnabled: true, 46 46 onlineDetectionEnabled: true, 47 domBreakpointsEnabled: false 47 domBreakpointsEnabled: false, 48 resourceExportEnabled: false 48 49 } 49 50 -
trunk/WebCore/inspector/front-end/utilities.js
r66477 r67615 985 985 return new RegExp(regex, "i"); 986 986 } 987 988 function offerFileForDownload(contents) 989 { 990 var builder = new BlobBuilder(); 991 builder.append(contents); 992 var blob = builder.getBlob("application/octet-stream"); 993 var url = window.createBlobURL(blob); 994 window.open(url); 995 }
Note: See TracChangeset
for help on using the changeset viewer.