WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
140268
Web Inspector: ResourceContentView.js incorrectly contains call to WebInspector.UIString with a variable parameter
https://bugs.webkit.org/show_bug.cgi?id=140268
Summary
Web Inspector: ResourceContentView.js incorrectly contains call to WebInspect...
Jonathan Wells
Reported
2015-01-08 14:23:42 PST
UIString only takes in String literals. This is generating an error with update-webkit-localizable-strings.
Attachments
[PATCH] fix.
(1.49 KB, patch)
2015-01-08 14:40 PST
,
Jonathan Wells
joepeck
: review-
joepeck
: commit-queue-
Details
Formatted Diff
Diff
[PATCH] fix.
(7.80 KB, patch)
2015-01-09 16:48 PST
,
Jonathan Wells
timothy
: review-
Details
Formatted Diff
Diff
[PATCH] fix 2, with attempted localized strings addition.
(14.62 KB, patch)
2015-01-12 16:19 PST
,
Jonathan Wells
timothy
: review+
timothy
: commit-queue-
Details
Formatted Diff
Diff
[PATCH] separated out localized strings, reviewed patch.
(7.10 KB, patch)
2015-01-22 16:24 PST
,
Jonathan Wells
jonowells
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2015-01-08 14:23:55 PST
<
rdar://problem/19417623
>
Jonathan Wells
Comment 2
2015-01-08 14:40:45 PST
Created
attachment 244295
[details]
[PATCH] fix.
Joseph Pecoraro
Comment 3
2015-01-08 15:03:25 PST
Comment on
attachment 244295
[details]
[PATCH] fix. View in context:
https://bugs.webkit.org/attachment.cgi?id=244295&action=review
> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:102 > + this.element.appendChild(WebInspector.createMessageTextView(error.message, true));
While this is correct, I think there may be an actual bug here. This is called from: // 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._contentError.bind(this)); So it looks like the "error.message" here comes from a requestContent rejected promise: requestContent: function() { if (this._finished) return WebInspector.SourceCode.prototype.requestContent.call(this); if (this._failed) return Promise.reject(new Error("An error occurred trying to load the resource.")); ... } So, shouldn't that Error message be localized for this view to have a localized string? Promise.reject(new Error(WebInspector.UIString("An error occurred trying to load the resource."))); If that is the case, are there other error strings that may need to be localized?
Brian Burg
Comment 4
2015-01-08 16:00:02 PST
Comment on
attachment 244295
[details]
[PATCH] fix. View in context:
https://bugs.webkit.org/attachment.cgi?id=244295&action=review
>> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:102 >> + this.element.appendChild(WebInspector.createMessageTextView(error.message, true)); > > While this is correct, I think there may be an actual bug here. > > This is called from: > > // 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._contentError.bind(this)); > > So it looks like the "error.message" here comes from a requestContent rejected promise: > > requestContent: function() > { > if (this._finished) > return WebInspector.SourceCode.prototype.requestContent.call(this); > > if (this._failed) > return Promise.reject(new Error("An error occurred trying to load the resource.")); > ... > } > > So, shouldn't that Error message be localized for this view to have a localized string? > > Promise.reject(new Error(WebInspector.UIString("An error occurred trying to load the resource."))); > > If that is the case, are there other error strings that may need to be localized?
I would agree with Joe. We should localize any string passed to the Error constructor if it is thrown and possibly displayed to the user. However, I'm not sure that these exceptions would be shown to the user. Won't they instead appear in Inspector^2? If we don't plan to localize those strings (which exist mainly for our benefit and for testing) then this patch is good. In either case, the explanation should be added to the changelog and the WebInspectorUI style guide for future reference.
Jonathan Wells
Comment 5
2015-01-08 17:10:02 PST
Comment on
attachment 244295
[details]
[PATCH] fix. View in context:
https://bugs.webkit.org/attachment.cgi?id=244295&action=review
>>> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:102 >>> + this.element.appendChild(WebInspector.createMessageTextView(error.message, true)); >> >> While this is correct, I think there may be an actual bug here. >> >> This is called from: >> >> // 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._contentError.bind(this)); >> >> So it looks like the "error.message" here comes from a requestContent rejected promise: >> >> requestContent: function() >> { >> if (this._finished) >> return WebInspector.SourceCode.prototype.requestContent.call(this); >> >> if (this._failed) >> return Promise.reject(new Error("An error occurred trying to load the resource.")); >> ... >> } >> >> So, shouldn't that Error message be localized for this view to have a localized string? >> >> Promise.reject(new Error(WebInspector.UIString("An error occurred trying to load the resource."))); >> >> If that is the case, are there other error strings that may need to be localized? > > I would agree with Joe. We should localize any string passed to the Error constructor if it is thrown and possibly displayed to the user. > > However, I'm not sure that these exceptions would be shown to the user. Won't they instead appear in Inspector^2? If we don't plan to localize those strings (which exist mainly for our benefit and for testing) then this patch is good. > In either case, the explanation should be added to the changelog and the WebInspectorUI style guide for future reference.
These are shown to the user if you select a resource that had an error loading. For images, in English, this reads: "Failed to load the resource: The requested URL was not found on this server." For scripts, this is localized as this internal error is not available. Resource.js:682: return Promise.reject(new Error("An error occurred trying to load the resource.")); It is shown to the user in bright red text in both cases when the resource is selected. I can make them both have the localized message "An error occurred trying to load the resource." for consistency... though I do wish that this message was more specific about the nature of the issue.
Timothy Hatcher
Comment 6
2015-01-08 19:53:53 PST
Comment on
attachment 244295
[details]
[PATCH] fix. I think it is odd to use the Error class for a string that gets displayed. It should be something else, if not just a plain string.
Timothy Hatcher
Comment 7
2015-01-08 19:55:47 PST
Comment on
attachment 244295
[details]
[PATCH] fix. We likely should not reject for cases when the page failed to load a Resource. Those are page errors, not Inspector errors. Page errors likely should fulfill the Promise, not reject it.
Jonathan Wells
Comment 8
2015-01-09 16:48:28 PST
Created
attachment 244389
[details]
[PATCH] fix. Fix based on comments. Note that the localized strings files have not been updated. I haven't been able to properly configure my machine to diff those files despite many efforts.
Timothy Hatcher
Comment 9
2015-01-10 17:15:35 PST
Comment on
attachment 244389
[details]
[PATCH] fix. View in context:
https://bugs.webkit.org/attachment.cgi?id=244389&action=review
You don't need to post a readable diff for localizedString.js, webkit-patch or git format-patch will output a binary patch just fine. The trick to use iconv is just helpful for seeing the diff with git diff.
> Source/WebInspectorUI/UserInterface/Models/Script.js:119 > + return Promise.reject(new Error(WebInspector.UIString("There is no identifier to request content with.")));
No need to localize since this error should not be shown to the user.
> Source/WebInspectorUI/UserInterface/Models/SourceCode.js:186 > + var errorMessage = WebInspector.UIString("Needs to be implemented by a subclass."); > + console.error(errorMessage); > + return Promise.reject(new Error(errorMessage));
No need to be localized. Revert.
Jonathan Wells
Comment 10
2015-01-12 16:19:53 PST
Created
attachment 244477
[details]
[PATCH] fix 2, with attempted localized strings addition.
WebKit Commit Bot
Comment 11
2015-01-12 16:22:40 PST
Attachment 244477
[details]
did not pass style-queue: ERROR: Source/WebCore/ChangeLog:8: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Timothy Hatcher
Comment 12
2015-01-12 16:29:36 PST
Comment on
attachment 244477
[details]
[PATCH] fix 2, with attempted localized strings addition. View in context:
https://bugs.webkit.org/attachment.cgi?id=244477&action=review
> Source/WebCore/ChangeLog:10 > + * English.lproj/Localizable.strings:
You should split this script sorting out and land separately.
Jonathan Wells
Comment 13
2015-01-22 16:24:23 PST
Created
attachment 245179
[details]
[PATCH] separated out localized strings, reviewed patch. I'll submit the updated localized strings separately.
Joseph Pecoraro
Comment 14
2015-01-22 16:33:22 PST
(In reply to
comment #13
)
> Created
attachment 245179
[details]
> [PATCH] separated out localized strings, reviewed patch. > > I'll submit the updated localized strings separately.
Why? Can you just land manually?
Jonathan Wells
Comment 15
2015-01-22 16:35:46 PST
(In reply to
comment #14
)
> (In reply to
comment #13
) > > Created
attachment 245179
[details]
> > [PATCH] separated out localized strings, reviewed patch. > > > > I'll submit the updated localized strings separately. > > Why? Can you just land manually?
I suppose so.
Jonathan Wells
Comment 16
2015-01-22 16:44:39 PST
Committed
r178970
: <
http://trac.webkit.org/changeset/178970
>
Joseph Pecoraro
Comment 17
2015-01-22 17:08:15 PST
Comment on
attachment 245179
[details]
[PATCH] separated out localized strings, reviewed patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=245179&action=review
> Source/WebInspectorUI/UserInterface/Models/Resource.js:683 > + return Promise.resolve({ error: WebInspector.UIString("An error occurred trying to load the resource.") });
Style: Our style for object literals is {name: property}.
> Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:93 > + this._contentError({ message: parameters.error });
Style: ditto.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug