[webkit-reviews] review granted: [Bug 215852] Web Inspector fails to preview response from XHR requests : [Attachment 407888] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Sep 3 10:31:52 PDT 2020
Devin Rousso <drousso at apple.com> has granted Patrick Angle <pangle at apple.com>'s
request for review:
Bug 215852: Web Inspector fails to preview response from XHR requests
https://bugs.webkit.org/show_bug.cgi?id=215852
Attachment 407888: Patch
https://bugs.webkit.org/attachment.cgi?id=407888&action=review
--- Comment #20 from Devin Rousso <drousso at apple.com> ---
Comment on attachment 407888
--> https://bugs.webkit.org/attachment.cgi?id=407888
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=407888&action=review
r=me, I have some remaining comments and there are a few more issues with the
newly added code, but they're easy enough to resolve that I don't think it
necessitates another review pingpong :)
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:546
> + auto previousResourceData =
m_resourcesData->dataForURL(response.url().string());
> +
> + if (previousResourceData) {
NIT: you can combine these into a single like
```
if (auto previousResourceData =
m_resourcesData->dataForURL(response.url().string()))
```
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:553
> + } else
> + m_resourcesData->setResourceContent(requestId,
emptyString(), false);
Do we need this as well? If the `previousResourceData` doesn't have any
content or buffered data, we shouldn't show the `requestId` as having any
either.
> Source/WebInspectorUI/UserInterface/Models/Resource.js:1033
> + return this.requestContentFailure.bind(this)();
`bind` isn't necessary when the function is being invoked
> Source/WebInspectorUI/UserInterface/Models/Resource.js:1039
> + }).then(WI.SourceCode.prototype.requestContent.bind(this))
Drive-by: while you're at it I think we can change this to be
`super.requestContent.bind(this)`
> Source/WebInspectorUI/UserInterface/Models/Resource.js:1046
> + requestContentFailure(error)
since this isn't used outside this class, we should make it "private" by adding
a leading `_` and moving it below after the `// Private`
> Source/WebInspectorUI/UserInterface/Models/Resource.js:1051
> + return Promise.resolve({error: WI.UIString("An error occurred trying
to load the resource."), message:
this._failureReasonText}).then(this._processContent.bind(this));
Do we actually need the `_processContent` call? I don't think it would really
do anything since `parameters` doesn't have
`content`/`body`/`text`/`scriptSource`/`base64Encoded`/etc..
NIT: `_processContent` is a "private" method of the parent class
`WI.SourceCode`, so it's a layering violation to use it here.
> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:160
> - this.showMessage(WI.UIString("Resource has no content"));
> + this.showMessage(WI.UIString("Resource has no content."));
ooo nice catch!
> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:167
> + this.showMessage(WI.UIString("Resource has no cached content.",
"Resource has no cached content. @ Resource Preview", "An error message when
there is no cached content for a Not Modified resource."));
Grammar: "error message shown when there"
you might also want to say "HTTP 304 Not Modified" so that it's explicitly
clear what you're talking about :)
> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:224
> + if (parameters.sourceCode.statusCode == 304 &&
parameters.message === "Missing content of resource for given requestId")
> + this.showNoCachedContentMessage();
> + else
NIT: i'd make this into an `if (...) { ... return; }` instead of having the
`else`
More information about the webkit-reviews
mailing list