Rayquaza01 / HistoryCleaner

Firefox addon that deletes history older than a specified amount of days.
MIT License
85 stars 6 forks source link

wrong timezone used when showing the notifications (and some related notification issues) #19

Closed R-Adrian closed 3 years ago

R-Adrian commented 3 years ago

i decided to enable the notifications from this addon to see when it would clear old history... big mistake, so i disabled notifications again because of these:

(1) after the first cleanup of the day, the notifications that keep appearing every few minutes are mentioning the same 'before date' with the time as 00:00:00... what's the point of doing the same thing over and over? I'd understand this if the addon would also use the current time (hh:mm:ss) when calculating the reference timestamp to delete before of, but since it's ignoring the time and just rounding up to days why show the notification if it didn't clean anything?

(2) as a result of the issue above, i'm getting a TON of cleanup notifications when simply reading random articles online... maybe the default "idle length" is not long enough when the notifications option is enabled?

and (3) - the notifications that show up say that the cleanup action happened at a time that differs by a few hours from the current local time. Looks to me that the time reported in the notification is the UTC time instead of the local time.

Rayquaza01 commented 3 years ago

The notifications are mainly there for debugging purposes (also in an attempt to see if I can reproduce #5.) Because clearing history is done silently in the background, it's hard to tell exactly when (or if) it's working. The notifications make it much more obvious when the extension triggers. The notifications are disabled by default and require an optional permission because they are very intrusive for normal use.

The notification triggers every time it attempts to clear history, regardless of if anything was cleared. The extension can't tell if it cleared anything or how much it cleared because history.deleteRange() does not provide this information. It simply requests that the browser delete history, but gives no feedback on what was deleted.

The date shouldn't be displayed in UTC unless your device has UTC as local time. In deleteHistory(), the time is set using the local methods (e.g. Date.setHours() instead of Date.setUTCHours()) and the date string in the notification is made with Date.toLocaleString(), so the date in the notification should display in your locale.

R-Adrian commented 3 years ago

image

even though the timezone of my system is correctly set, Firefox Date.setHours() seems to report the timezone as UTC ... hmmmm...

i looked further into why is this happening ... and it seems to be caused by the browser preference privacy.resistFingerprinting being set to true. For testing, i set it to false and tried running that testing script again and this time it produced the expected result with timezone.

https://wiki.mozilla.org/Security/Fingerprinting and here it says Timezone is spoofed to 'UTC'

Since timezone info can be used for fingerprinting a browser/user i can see now why it returns UTC as timezone when the resistFingerprinting preference is set, so i'll close this ticket - getting UTC time is expected behaviour in this mode.