Web Inspector: Charles Proxy errors opening har files exported from Safari (invalid...
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / NetworkTableContentView.js
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()