Web Inspector: Charles Proxy errors opening har files exported from Safari (invalid...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 00:58:45 +0000 (00:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 00:58:45 +0000 (00:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192959
<rdar://problem/46863411>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2018-12-20
Reviewed by Brian Burg.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype.tableCellContextMenuClicked):
(WI.NetworkTableContentView.prototype._updateExportButton):
(WI.NetworkTableContentView.prototype._canExportHAR):
Disallow HAR export if we don't have load data, such as the requestSentDate for
the main resource or sub-resources.

(WI.NetworkTableContentView.prototype._HARResources):
Only export resources that have load data.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js

index b8b0a84..39dc6f9 100644 (file)
@@ -1,5 +1,23 @@
 2018-12-20  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Charles Proxy errors opening har files exported from Safari (invalid startedDateTime)
+        https://bugs.webkit.org/show_bug.cgi?id=192959
+        <rdar://problem/46863411>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView.prototype.tableCellContextMenuClicked):
+        (WI.NetworkTableContentView.prototype._updateExportButton):
+        (WI.NetworkTableContentView.prototype._canExportHAR):
+        Disallow HAR export if we don't have load data, such as the requestSentDate for
+        the main resource or sub-resources.
+
+        (WI.NetworkTableContentView.prototype._HARResources):
+        Only export resources that have load data.
+
+2018-12-20  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Autoformat doesn't work on icloud.com (javascript-packed.js)
         https://bugs.webkit.org/show_bug.cgi?id=192946
         <rdar://problem/42546126>
index 6af19bf..57ec8af 100644 (file)
@@ -147,7 +147,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         // triggers a MainResource change and then a MainFrame change. Page Transition
         // triggers a MainFrame change then a MainResource change.
         this._transitioningPageTarget = false;
-        
+
         WI.notifications.addEventListener(WI.Notification.TransitionPageTarget, this._transitionPageTarget, this);
     }
 
@@ -363,7 +363,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         WI.appendContextMenuItemsForSourceCode(contextMenu, entry.resource);
 
         contextMenu.appendSeparator();
-        contextMenu.appendItem(WI.UIString("Export HAR"), () => { this._exportHAR(); });
+        contextMenu.appendItem(WI.UIString("Export HAR"), () => { this._exportHAR(); }, !this._canExportHAR());
     }
 
     tableShouldSelectRow(table, cell, column, rowIndex)
@@ -1158,10 +1158,28 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         }
     }
 
+    _canExportHAR()
+    {
+        let mainFrame = WI.networkManager.mainFrame;
+        if (!mainFrame)
+            return false;
+
+        let mainResource = mainFrame.mainResource;
+        if (!mainResource)
+            return false;
+
+        if (!mainResource.requestSentDate)
+            return false;
+
+        if (!this._HARResources().length)
+            return false;
+
+        return true;
+    }
+
     _updateExportButton()
     {
-        let enabled = this._filteredEntries.length > 0;
-        this._harExportNavigationItem.enabled = enabled;
+        this._harExportNavigationItem.enabled = this._canExportHAR();
     }
 
     _processPendingEntries()
@@ -1871,7 +1889,15 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
     {
         let resources = this._filteredEntries.map((x) => x.resource);
         const supportedHARSchemes = new Set(["http", "https", "ws", "wss"]);
-        return resources.filter((resource) => resource.finished && supportedHARSchemes.has(resource.urlComponents.scheme));
+        return resources.filter((resource) => {
+            if (!resource.finished)
+                return false;
+            if (!resource.requestSentDate)
+                return false;
+            if (!supportedHARSchemes.has(resource.urlComponents.scheme))
+                return false;
+            return true;
+        });
     }
 
     _exportHAR()