Screenshot filename uses wrong day number (day# + 1 instead of day#)
Categories
(DevTools :: General, defect, P3)
Tracking
(firefox89 fixed)
Tracking | Status | |
---|---|---|
firefox89 | --- | fixed |
People
(Reporter: Makyen, Assigned: kajalsah107, Mentored)
References
Details
(Keywords: good-first-bug)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
Steps to reproduce:
I took a screenshot of a webpage using the screenshot capability in the DevTools.
Actual results:
The wrong day number was used in the screenshot's filename.
For example, on (local time) 2021-03-27 at 10:33:40, the filename was: "Screen Shot 2021-03-28 at 10.33.40-fullpage.png"
Note that the day that is used (28) is the number of the day in the month + 1 instead of the number of the day (27).
Expected results:
The screenshot filename should have been: "Screen Shot 2021-03-27 at 10.33.40-fullpage.png"
Note the day number in the filename (27) should match the current day of the month (27).
This is caused by a bug introduced when the getFilename
function in the capture-screenshot.js file was rewritten for Firefox 87.0.0. The issue did not exist in earlier versions of Firefox.
The line that is:
const dayString = (date.getDate() + 1).toString().padStart(2, "0");
should be:
const dayString = date.getDate().toString().padStart(2, "0");
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Firefox::Screenshots' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•3 years ago
|
||
We should probably be using more internationalization-friendly date methods here to make a sensible locale and timezone friendly filename.
I am interested in this bug since I just now attempted a similar bug #1673269. However, I am not able to find where this getFilename
function is located. All I could find using grep -r
is getfilename
in browser/extensions/screenshots/build/shot.js
.
Comment 4•3 years ago
|
||
I suggest you use searchfox, which is extremely convenient. You can search for the code mentioned in comment 0: https://searchfox.org/mozilla-central/search?q=date.getDate%28%29+%2B+1.
(In reply to Tom Schuster [:evilpie] from comment #4)
I suggest you use searchfox, which is extremely convenient. You can search for the code mentioned in comment 0: https://searchfox.org/mozilla-central/search?q=date.getDate%28%29+%2B+1.
This is helpful. Thanks. I will come up with a patch soon. Thanks!
Updated•3 years ago
|
Comment 7•3 years ago
|
||
Sorry I didn't spot this was using devtool's screenshot. Its probably still a good-first-bug, but I'll leave it to that team to decide if they want to mentor.
(In reply to Kajal Sah from comment #3)
I am interested in this bug since I just now attempted a similar bug #1673269. However, I am not able to find where this
getFilename
function is located. All I could find usinggrep -r
isgetfilename
inbrowser/extensions/screenshots/build/shot.js
.
So this screenshot function is distinct from the browser's screenshot tool. It looks like this is the getFilename you want: https://searchfox.org/mozilla-central/source/devtools/server/actors/utils/capture-screenshot.js#182
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1d185f9f0d20 Corrects screenshot filename. r=nchevobbe
Comment 9•3 years ago
|
||
bugherder |
Description
•