Diff
Modified: trunk/Source/WebCore/ChangeLog (216137 => 216138)
--- trunk/Source/WebCore/ChangeLog 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebCore/ChangeLog 2017-05-03 20:36:27 UTC (rev 216138)
@@ -1,3 +1,20 @@
+2017-05-03 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: 404 Image Load does not appear as a failure in Web Inspector
+ https://bugs.webkit.org/show_bug.cgi?id=171587
+ <rdar://problem/13222846>
+
+ Reviewed by Matt Baker.
+
+ * inspector/InspectorPageAgent.h:
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::cachedResourceContent):
+ (WebCore::prepareCachedResourceBuffer): Deleted.
+ Inline the function to make this less confusing.
+
+ (WebCore::InspectorPageAgent::buildObjectForFrameTree):
+ Treat a DecodeError as a failure.
+
2017-05-03 Said Abou-Hallawa <[email protected]>
Async image decoding should be disabled for snapshots, printing and preview
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (216137 => 216138)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2017-05-03 20:36:27 UTC (rev 216138)
@@ -97,21 +97,6 @@
return false;
}
-static bool prepareCachedResourceBuffer(CachedResource* cachedResource, bool* hasZeroSize)
-{
- *hasZeroSize = false;
- if (!cachedResource)
- return false;
-
- // Zero-sized resources don't have data at all -- so fake the empty buffer, instead of indicating error by returning 0.
- if (!cachedResource->encodedSize()) {
- *hasZeroSize = true;
- return true;
- }
-
- return true;
-}
-
static bool hasTextContent(CachedResource* cachedResource)
{
// FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
@@ -127,18 +112,16 @@
bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, String* result, bool* base64Encoded)
{
- // FIXME: result should be a String& and base64Encoded should be a bool&.
- bool hasZeroSize;
- bool prepared = prepareCachedResourceBuffer(cachedResource, &hasZeroSize);
- if (!prepared)
+ if (!cachedResource)
return false;
+ if (!cachedResource->encodedSize()) {
+ *result = String();
+ return true;
+ }
+
*base64Encoded = !hasTextContent(cachedResource);
if (*base64Encoded) {
- if (hasZeroSize) {
- *result = { };
- return true;
- }
if (auto* buffer = cachedResource->resourceBuffer()) {
*result = base64Encode(buffer->data(), buffer->size());
return true;
@@ -146,11 +129,6 @@
return false;
}
- if (hasZeroSize) {
- *result = emptyString();
- return true;
- }
-
if (cachedResource) {
switch (cachedResource->type()) {
case CachedResource::CSSStyleSheet:
@@ -904,7 +882,7 @@
.release();
if (cachedResource->wasCanceled())
resourceObject->setCanceled(true);
- else if (cachedResource->status() == CachedResource::LoadError)
+ else if (cachedResource->status() == CachedResource::LoadError || cachedResource->status() == CachedResource::DecodeError)
resourceObject->setFailed(true);
String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource);
if (!sourceMappingURL.isEmpty())
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (216137 => 216138)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.h 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h 2017-05-03 20:36:27 UTC (rev 216138)
@@ -74,7 +74,7 @@
XHRResource,
FetchResource,
WebSocketResource,
- OtherResource
+ OtherResource,
};
static bool cachedResourceContent(CachedResource*, String* result, bool* base64Encoded);
Modified: trunk/Source/WebInspectorUI/ChangeLog (216137 => 216138)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-05-03 20:36:27 UTC (rev 216138)
@@ -1,3 +1,40 @@
+2017-05-03 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: 404 Image Load does not appear as a failure in Web Inspector
+ https://bugs.webkit.org/show_bug.cgi?id=171587
+ <rdar://problem/13222846>
+
+ Reviewed by Matt Baker.
+
+ * UserInterface/Models/Resource.js:
+ (WebInspector.Resource.prototype.createObjectURL):
+ This may return null if the data is not a Blob. This can happen if we
+ loaded non-base64Encoded text content for an Image. Such as a 404 response.
+
+ (WebInspector.Resource.prototype.hadLoadingError):
+ Consistent way to check for any kind of loading error.
+
+ (WebInspector.Resource.prototype.getImageSize):
+ Handle failure to create an object URL.
+
+ * UserInterface/Views/FontResourceContentView.js:
+ (WebInspector.FontResourceContentView.prototype.contentAvailable):
+ * UserInterface/Views/ImageResourceContentView.js:
+ (WebInspector.ImageResourceContentView.prototype.contentAvailable):
+ Handle failure to create an object URL.
+:
+ * UserInterface/Views/ResourceContentView.js:
+ (WebInspector.ResourceContentView):
+ (WebInspector.ResourceContentView.prototype.showGenericErrorMessage):
+ (WebInspector.ResourceContentView.prototype._protocolError): Deleted.
+ Provide a way for subclasses to show a generic resource loading error.
+
+ * UserInterface/Views/ResourceTimelineDataGridNode.js:
+ (WebInspector.ResourceTimelineDataGridNode.prototype.createCellContent):
+ * UserInterface/Views/ResourceTreeElement.js:
+ (WebInspector.ResourceTreeElement.prototype._updateStatus):
+ Use the consistent helper for denoting loading errors.
+
2017-05-02 Fujii Hironori <[email protected]>
[GTK] Web Inspector: Remove GTK+ icon FontVariantSmallCaps.svg
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -347,13 +347,14 @@
{
// If content is not available, fallback to using original URL.
// The client may try to revoke it, but nothing will happen.
- if (!this.content)
+ let content = this.content;
+ if (!content)
return this._url;
- var content = this.content;
- console.assert(content instanceof Blob, content);
+ if (content instanceof Blob)
+ return URL.createObjectURL(content);
- return URL.createObjectURL(content);
+ return null;
}
isMainResource()
@@ -831,6 +832,11 @@
this.markAsCached();
}
+ hadLoadingError()
+ {
+ return this._failed || this._canceled || this._statusCode >= 400;
+ }
+
getImageSize(callback)
{
// Throw an error in the case this resource is not an image.
@@ -870,8 +876,10 @@
image.addEventListener("load", imageDidLoad.bind(this), false);
// Set the image source using an object URL once we've obtained its data.
- this.requestContent().then(function(content) {
+ this.requestContent().then((content) => {
objectURL = image.src = ""
+ if (!objectURL)
+ requestContentFailure.call(this);
}, requestContentFailure.bind(this));
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FontResourceContentView.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Views/FontResourceContentView.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FontResourceContentView.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -55,7 +55,11 @@
contentAvailable(content, base64Encoded)
{
- this.element.removeChildren();
+ this._fontObjectURL = this.resource.createObjectURL();
+ if (!this._fontObjectURL) {
+ this.showGenericErrorMessage();
+ return;
+ }
const uniqueFontName = "WebInspectorFontPreview" + (++WebInspector.FontResourceContentView._uniqueFontIdentifier);
@@ -68,7 +72,7 @@
if (this._styleElement && this._styleElement.parentNode)
this._styleElement.parentNode.removeChild(this._styleElement);
- this._fontObjectURL = this.resource.createObjectURL();
+ this.element.removeChildren();
this._styleElement = document.createElement("style");
this._styleElement.textContent = "@font-face { font-family: \"" + uniqueFontName + "\"; src: url(" + this._fontObjectURL + ")" + format + "; }";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -41,9 +41,14 @@
contentAvailable(content, base64Encoded)
{
+ let objectURL = this.resource.createObjectURL();
+ if (!objectURL) {
+ this.showGenericErrorMessage();
+ return;
+ }
+
this.element.removeChildren();
- var objectURL = this.resource.createObjectURL();
this._imageElement = document.createElement("img");
this._imageElement.addEventListener("load", function() { URL.revokeObjectURL(objectURL); });
this._imageElement.src = ""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -44,7 +44,7 @@
this.element.addEventListener("click", this._mouseWasClicked.bind(this), false);
// Request content last so the spinner will always be removed in case the content is immediately available.
- resource.requestContent().then(this._contentAvailable.bind(this)).catch(this._protocolError.bind(this));
+ resource.requestContent().then(this._contentAvailable.bind(this)).catch(this.showGenericErrorMessage.bind(this));
if (!this.managesOwnIssues) {
WebInspector.issueManager.addEventListener(WebInspector.IssueManager.Event.IssueWasAdded, this._issueWasAdded, this);
@@ -77,6 +77,11 @@
// Implemented by subclasses.
}
+ showGenericErrorMessage()
+ {
+ this._contentError(WebInspector.UIString("An error occurred trying to load the resource."));
+ }
+
addIssue(issue)
{
// This generically shows only the last issue, subclasses can override for better handling.
@@ -118,11 +123,6 @@
this.dispatchEventToListeners(WebInspector.ResourceContentView.Event.ContentError);
}
- _protocolError(error)
- {
- this._contentError(WebInspector.UIString("An error occurred trying to load the resource."));
- }
-
_hasContent()
{
return !this.element.querySelector(".indeterminate-progress-spinner");
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -96,7 +96,7 @@
{
let resource = this._resource;
- if (resource.failed || resource.canceled || resource.statusCode >= 400)
+ if (resource.hadLoadingError())
cell.classList.add("error");
let value = this.data[columnIdentifier];
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js (216137 => 216138)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js 2017-05-03 20:33:01 UTC (rev 216137)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js 2017-05-03 20:36:27 UTC (rev 216138)
@@ -170,7 +170,7 @@
_updateStatus()
{
- if (this._resource.failed)
+ if (this._resource.hadLoadingError())
this.addClassName(WebInspector.ResourceTreeElement.FailedStyleClassName);
else
this.removeClassName(WebInspector.ResourceTreeElement.FailedStyleClassName);
@@ -179,7 +179,7 @@
// Remove the spinner.
this.status = "";
} else {
- var spinner = new WebInspector.IndeterminateProgressSpinner;
+ let spinner = new WebInspector.IndeterminateProgressSpinner;
this.status = spinner.element;
}
}