Closed
Bug 1313799
Opened 9 years ago
Closed 8 years ago
Remove Date.prototype.toLocaleFormat uses in devtools/client/netmonitor/har
Categories
(DevTools :: Netmonitor, defect, P2)
DevTools
Netmonitor
Tracking
(firefox53 fixed)
RESOLVED
FIXED
Firefox 53
| Tracking | Status | |
|---|---|---|
| firefox53 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(1 file, 3 obsolete files)
|
4.31 KB,
patch
|
Honza
:
review+
|
Details | Diff | Splinter Review |
Date.prototype.toLocaleFormat is a non-standard API and we plan to warn when it's used (bug 1299900) and eventually want to remove it completely (bug 818634). As a first step we need to replace all Date.prototype.toLocaleFormat uses in Firefox with standardized APIs.
Date.prototype.toLocaleFormat is used in devtools/client/netmonitor/har/har-utils.js. Unfortunately har-utils.js uses a dynamic format string, so I had to write a custom strftime function to provide the different formatting options.
The Intl object isn't supported on all platforms (bug 1215247), that means toLocaleFormat is still used for Android. Nevertheless let's try to switch to the standardized APIs for those platforms which provide Intl support.
| Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8805729 -
Flags: review?(odvarko)
| Assignee | ||
Comment 2•9 years ago
|
||
Updated patch to cover more format specifiers and to improve compatibility with toLocaleFormat().
Attachment #8805729 -
Attachment is obsolete: true
Attachment #8805729 -
Flags: review?(odvarko)
Attachment #8805796 -
Flags: review?(odvarko)
Updated•8 years ago
|
Priority: -- → P2
Comment 3•8 years ago
|
||
As far as I know, har-utils.js only runs on Desktop (since it's a client file), I would only worry about compat with Mobile if the code was running on the actor side (which is not the case here).
It should be safe to Intl without any polyfill.
Flags: needinfo?(andrebargull)
| Assignee | ||
Comment 4•8 years ago
|
||
Sounds great! I'll update the patch to remove the non-Intl fallback paths.
Flags: needinfo?(andrebargull)
Comment 5•8 years ago
|
||
Wait, since we only need to generate a file name with the date, I feel like reimplementing toLocaleString() is a bit over-engineered for that purpose, maybe, something a bit more simple could do the job ?
| Assignee | ||
Comment 6•8 years ago
|
||
(In reply to Tim Nguyen :ntim (use needinfo?) from comment #5)
> Wait, since we only need to generate a file name with the date, I feel like
> reimplementing toLocaleString() is a bit over-engineered for that purpose,
> maybe, something a bit more simple could do the job ?
Sure, if it's okay to modify the "devtools.netmonitor.har.defaultFileName" preference [1] to remove the date format string part.
[1] https://dxr.mozilla.org/mozilla-central/rev/8103c612b79c2587ea4ca1b0a9f9f82db4b185b8/devtools/client/netmonitor/har/har-exporter.js#76
| Assignee | ||
Comment 7•8 years ago
|
||
Updated patch to remove the Intl fallback code paths per comment #5.
Attachment #8805796 -
Attachment is obsolete: true
Attachment #8805796 -
Flags: review?(odvarko)
Attachment #8817559 -
Flags: review?(odvarko)
Comment 9•8 years ago
|
||
(In reply to André Bargull from comment #8)
> Any thoughts on comment #6?
Just asked Honza on IRC, and he was ok with only supporting the formatting string %date in the pref.
Where %date is date.toLocaleString/toString() (whatever you think is the most appropriate).
Flags: needinfo?(ntim.bugs)
Comment 10•8 years ago
|
||
Yes, agree with comment #9
(please ping me again as soon as I should review the patch)
Thanks!
Honza
Comment 11•8 years ago
|
||
Comment on attachment 8817559 [details] [diff] [review]
bug1313799.patch
Review of attachment 8817559 [details] [diff] [review]:
-----------------------------------------------------------------
Just removing the review request from my queue for now.
Honza
Attachment #8817559 -
Flags: review?(odvarko)
| Assignee | ||
Comment 12•8 years ago
|
||
(In reply to Tim Nguyen :ntim from comment #9)
> Just asked Honza on IRC, and he was ok with only supporting the formatting
> string %date in the pref.
Great!
> Where %date is date.toLocaleString/toString() (whatever you think is the
> most appropriate).
I think it's best to use a custom formatter, because both, toString and toLocaleString, have some drawbacks when used in file names (e.g. when sorting the files lexicographically).
| Assignee | ||
Comment 13•8 years ago
|
||
New patch which removes toLocaleFormat() and only allows %date to output the current date/time.
Attachment #8817559 -
Attachment is obsolete: true
Attachment #8827856 -
Flags: review?(odvarko)
Comment 14•8 years ago
|
||
Comment on attachment 8827856 [details] [diff] [review]
bug1313799.patch
Review of attachment 8827856 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me, thanks for working on this!
R+m, assuming try is green.
Honza
Attachment #8827856 -
Flags: review?(odvarko) → review+
| Assignee | ||
Comment 15•8 years ago
|
||
(In reply to Jan Honza Odvarko [:Honza] from comment #14)
> Looks good to me, thanks for working on this!
>
> R+m, assuming try is green.
Thanks for the review!
Try looks good: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2252edfd306556c076fe4a210929b2b0747dd7dd
Keywords: checkin-needed
Comment 16•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/dc3f3764b1d5
Remove Date.prototype.toLocaleFormat uses in devtools/client/netmonitor/har. r=Honza
Keywords: checkin-needed
Comment 17•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox53:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 53
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•