Closed Bug 1701461 Opened 3 years ago Closed 3 years ago

Screenshot filename uses wrong day number (day# + 1 instead of day#)

Categories

(DevTools :: General, defect, P3)

Firefox 87
defect

Tracking

(firefox89 fixed)

RESOLVED FIXED
89 Branch
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");

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.

Component: Untriaged → Screenshots

We should probably be using more internationalization-friendly date methods here to make a sensible locale and timezone friendly filename.

Mentor: sfoster
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: good-first-bug
Priority: -- → P3

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.

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!

Assignee: nobody → kajalsah107
Status: NEW → ASSIGNED

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 using grep -r is getfilename in browser/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

Component: Screenshots → General
Product: Firefox → DevTools
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1d185f9f0d20
Corrects screenshot filename. r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: