Title: [216564] trunk/Source/WebInspectorUI
Revision
216564
Author
commit-qu...@webkit.org
Date
2017-05-09 22:28:54 -0700 (Tue, 09 May 2017)

Log Message

Web Inspector: Provide resource load error reason text in details sidebar
https://bugs.webkit.org/show_bug.cgi?id=171901
<rdar://problem/29850995>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-05-09
Reviewed by Brian Burg.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Controllers/FrameResourceManager.js:
(WebInspector.FrameResourceManager.prototype.resourceRequestDidFailLoading):
* UserInterface/Models/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.get failureReasonText):
(WebInspector.Resource.prototype.markAsFailed):
* UserInterface/Protocol/NetworkObserver.js:
(WebInspector.NetworkObserver.prototype.loadingFailed):
Include the error text we got from the backend. In most cases this should
be a localized error description.

* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshErrorReason):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshRequestAndResponse):
Include an Error field alongside the status code section when there was an error.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (216563 => 216564)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-05-10 05:28:54 UTC (rev 216564)
@@ -1,3 +1,29 @@
+2017-05-09  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Provide resource load error reason text in details sidebar
+        https://bugs.webkit.org/show_bug.cgi?id=171901
+        <rdar://problem/29850995>
+
+        Reviewed by Brian Burg.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Controllers/FrameResourceManager.js:
+        (WebInspector.FrameResourceManager.prototype.resourceRequestDidFailLoading):
+        * UserInterface/Models/Resource.js:
+        (WebInspector.Resource):
+        (WebInspector.Resource.prototype.get failureReasonText):
+        (WebInspector.Resource.prototype.markAsFailed):
+        * UserInterface/Protocol/NetworkObserver.js:
+        (WebInspector.NetworkObserver.prototype.loadingFailed):
+        Include the error text we got from the backend. In most cases this should
+        be a localized error description.
+
+        * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+        (WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
+        (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshErrorReason):
+        (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshRequestAndResponse):
+        Include an Error field alongside the status code section when there was an error.
+
 2017-05-09  Fujii Hironori  <hironori.fu...@sony.com>
 
         [GTK][Win] Web Inspector: Cann't open "Quick Open" dialog by pressing Ctrl+Shift+O

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (216563 => 216564)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2017-05-10 05:28:54 UTC (rev 216564)
@@ -344,6 +344,7 @@
 localizedStrings["Enter the name of a Keyframe"] = "Enter the name of a Keyframe";
 localizedStrings["Enter value"] = "Enter value";
 localizedStrings["Entire Recording"] = "Entire Recording";
+localizedStrings["Error"] = "Error";
 localizedStrings["Error: "] = "Error: ";
 localizedStrings["Errors"] = "Errors";
 localizedStrings["Eval Code"] = "Eval Code";
@@ -362,6 +363,7 @@
 localizedStrings["Extra Scripts"] = "Extra Scripts";
 localizedStrings["Fade unexecuted code"] = "Fade unexecuted code";
 localizedStrings["Failed to upgrade"] = "Failed to upgrade";
+localizedStrings["Failure status code"] = "Failure status code";
 localizedStrings["Family"] = "Family";
 localizedStrings["Features"] = "Features";
 localizedStrings["Fetch"] = "Fetch";
@@ -497,6 +499,7 @@
 localizedStrings["Live"] = "Live";
 localizedStrings["Live Size"] = "Live Size";
 localizedStrings["Load \u2014 %s"] = "Load \u2014 %s";
+localizedStrings["Load cancelled"] = "Load cancelled";
 localizedStrings["Local File"] = "Local File";
 localizedStrings["Local Storage"] = "Local Storage";
 localizedStrings["Local Variables"] = "Local Variables";
@@ -873,6 +876,7 @@
 localizedStrings["Uncomment All Properties"] = "Uncomment All Properties";
 localizedStrings["Uncomment rule"] = "Uncomment rule";
 localizedStrings["Unique"] = "Unique";
+localizedStrings["Unknown error"] = "Unknown error";
 localizedStrings["Unknown node"] = "Unknown node";
 localizedStrings["Unsupported property ā€œ%sā€"] = "Unsupported property ā€œ%sā€";
 localizedStrings["Untitled"] = "Untitled";

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js (216563 => 216564)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js	2017-05-10 05:28:54 UTC (rev 216564)
@@ -440,7 +440,7 @@
         this._resourceRequestIdentifierMap.delete(requestIdentifier);
     }
 
-    resourceRequestDidFailLoading(requestIdentifier, canceled, timestamp)
+    resourceRequestDidFailLoading(requestIdentifier, canceled, timestamp, errorText)
     {
         // Called from WebInspector.NetworkObserver.
 
@@ -456,7 +456,7 @@
             return;
 
         let elapsedTime = WebInspector.timelineManager.computeElapsedTime(timestamp);
-        resource.markAsFailed(canceled, elapsedTime);
+        resource.markAsFailed(canceled, elapsedTime, errorText);
 
         if (resource === resource.parentFrame.provisionalMainResource)
             resource.parentFrame.clearProvisionalLoad();

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (216563 => 216564)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2017-05-10 05:28:54 UTC (rev 216564)
@@ -59,6 +59,9 @@
         this._statusCode = NaN;
         this._statusText = null;
         this._cached = false;
+        this._canceled = false;
+        this._failed = false;
+        this._failureReasonText = null;
         this._receivedNetworkLoadMetrics = false;
         this._responseSource = WebInspector.Resource.ResponseSource.Unknown;
         this._timingData = new WebInspector.ResourceTimingData(this);
@@ -392,6 +395,11 @@
         return this._canceled;
     }
 
+    get failureReasonText()
+    {
+        return this._failureReasonText;
+    }
+
     get requestDataContentType()
     {
         return this._requestHeaders.valueForCaseInsensitiveKey("Content-Type") || null;
@@ -790,7 +798,7 @@
         this.dispatchEventToListeners(WebInspector.Resource.Event.TimestampsDidChange);
     }
 
-    markAsFailed(canceled, elapsedTime)
+    markAsFailed(canceled, elapsedTime, errorText)
     {
         console.assert(!this._finished);
 
@@ -798,6 +806,9 @@
         this._canceled = canceled;
         this._finishedOrFailedTimestamp = elapsedTime || NaN;
 
+        if (!this._failureReasonText)
+            this._failureReasonText = errorText || null;
+
         this.dispatchEventToListeners(WebInspector.Resource.Event.LoadingDidFail);
         this.dispatchEventToListeners(WebInspector.Resource.Event.TimestampsDidChange);
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/NetworkObserver.js (216563 => 216564)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/NetworkObserver.js	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/NetworkObserver.js	2017-05-10 05:28:54 UTC (rev 216564)
@@ -55,7 +55,7 @@
 
     loadingFailed(requestId, timestamp, errorText, canceled)
     {
-        WebInspector.frameResourceManager.resourceRequestDidFailLoading(requestId, canceled, timestamp);
+        WebInspector.frameResourceManager.resourceRequestDidFailLoading(requestId, canceled, timestamp, errorText);
     }
 
     requestServedFromMemoryCache(requestId, frameId, loaderId, documentURL, timestamp, initiator, resource)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js (216563 => 216564)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js	2017-05-10 04:42:18 UTC (rev 216563)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js	2017-05-10 05:28:54 UTC (rev 216564)
@@ -51,8 +51,7 @@
         this._initiatedRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Initiated"));
 
         var firstGroup = [this._locationFullURLRow];
-        var secondGroup = [this._locationSchemeRow, this._locationHostRow, this._locationPortRow, this._locationPathRow,
-            this._locationQueryStringRow, this._locationFragmentRow, this._locationFilenameRow];
+        var secondGroup = [this._locationSchemeRow, this._locationHostRow, this._locationPortRow, this._locationPathRow, this._locationQueryStringRow, this._locationFragmentRow, this._locationFilenameRow];
         var thirdGroup = [this._initiatorRow, this._initiatedRow];
 
         this._fullURLGroup = new WebInspector.DetailsSectionGroup(firstGroup);
@@ -74,6 +73,7 @@
 
         this._statusTextRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Status"));
         this._statusCodeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Code"));
+        this._errorReasonRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Error"));
 
         this._remoteAddressRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("IP Address"));
         this._connectionIdentifierRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Connection ID"));
@@ -86,12 +86,13 @@
         this._compressionRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Compression"));
 
         let requestGroup = new WebInspector.DetailsSectionGroup([this._requestMethodRow, this._protocolRow, this._priorityRow, this._cachedRow]);
-        let statusGroup = new WebInspector.DetailsSectionGroup([this._statusTextRow, this._statusCodeRow]);
+        let statusGroup = new WebInspector.DetailsSectionGroup([this._statusTextRow, this._statusCodeRow, this._errorReasonRow]);
         let connectionGroup = new WebInspector.DetailsSectionGroup([this._remoteAddressRow, this._connectionIdentifierRow]);
         let sizeGroup = new WebInspector.DetailsSectionGroup([this._encodedSizeRow, this._decodedSizeRow, this._transferSizeRow]);
         let compressionGroup = new WebInspector.DetailsSectionGroup([this._compressedRow, this._compressionRow]);
 
-        this._requestAndResponseSection = new WebInspector.DetailsSection("resource-request-response", WebInspector.UIString("Request & Response"), [requestGroup, statusGroup, connectionGroup, sizeGroup, compressionGroup]);
+        this._requestAndResponseSection = new WebInspector.DetailsSection("resource-request-response", WebInspector.UIString("Request & Response"));
+        this._requestAndResponseSection.groups = [requestGroup, statusGroup, connectionGroup, sizeGroup, compressionGroup];
 
         this._requestHeadersRow = new WebInspector.DetailsSectionDataGridRow(null, WebInspector.UIString("No Request Headers"));
         this._requestHeadersSection = new WebInspector.DetailsSection("resource-request-headers", WebInspector.UIString("Request Headers"));
@@ -165,6 +166,7 @@
             this._resource.removeEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
             this._resource.removeEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
             this._resource.removeEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
             this._resource.removeEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
             this._resource.removeEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
             this._resource.removeEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
@@ -179,6 +181,7 @@
             this._resource.addEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
             this._resource.addEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
             this._resource.addEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
+            this._resource.addEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
             this._resource.addEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
             this._resource.addEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
             this._resource.addEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
@@ -311,6 +314,26 @@
         this._typeMIMETypeRow.value = this._resource.mimeType;
     }
 
+    _refreshErrorReason()
+    {
+        if (!this._resource)
+            return;
+
+        if (!this._resource.hadLoadingError()) {
+            this._errorReasonRow.value = null;
+            return;
+        }
+
+        if (this._resource.failureReasonText)
+            this._errorReasonRow.value = this._resource.failureReasonText;
+        else if (this._resource.statusCode >= 400)
+            this._errorReasonRow.value = WebInspector.UIString("Failure status code");
+        else if (this._resource.canceled)
+            this._errorReasonRow.value = WebInspector.UIString("Load cancelled");
+        else
+            this._errorReasonRow.value = WebInspector.UIString("Unknown error");
+    }
+
     _refreshRequestAndResponse()
     {
         if (!this._resource)
@@ -335,6 +358,7 @@
 
         this._statusCodeRow.value = this._resource.statusCode || emDash;
         this._statusTextRow.value = this._resource.statusText || emDash;
+        this._refreshErrorReason();
 
         this._refreshResponseHeaders();
         this._refreshCompressed();
@@ -462,9 +486,7 @@
             return;
 
         function hideImageSection() {
-            let imageSectionElement = this._imageSizeSection.element;
-            if (imageSectionElement.parentNode)
-                this.contentView.element.removeChild(imageSectionElement);
+            this._imageSizeSection.element.remove();
         }
 
         // Hide the section if we're not dealing with an image or if the load failed.
@@ -513,7 +535,6 @@
     _refreshRequestDataSection()
     {
         var resource = this._resource;
-
         if (!resource)
             return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to