Round Off Navigator Battery Level on Linux

RESOLVED FIXED in mozilla38

Status

()

Core
Hardware Abstraction Layer (HAL)
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: Lukasz, Assigned: Gijs)

Tracking

({privacy})

35 Branch
mozilla38
x86
Linux
privacy
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20150112203157

Steps to reproduce:

On Linux, open the developer console and check navigator.battery.level



Actual results:

The battery level is reported with 16 decimal places (e.g. 0.1600730371272063)



Expected results:

The battery level should be rounded to two decimal places (e.g. 0.16) as it’s on Windows and Mac.

On Mac and Windows, Firefox reports the battery level with 2 decimal places (e.g. 0.16). On Linux, Firefox reads the battery level from D-Bus, and make it available to Web platform without rounding it off (e.g. 0.1600730371272063).

By using the high-precision battery level readouts from the Battery API (navigator.battery.level), one can detect the battery capacity and use it as a short-term tracking identifier. This is done by solving a linear system of equations and exploiting floating point quirks, thanks to the double precision reading exposed to the Web platform.

The battery capacity may not be a fingerprinting method with severe consequences, since it’s very short-lived -- the battery capacity may be updated when the battery is fully charged. But it’s rather unexpected, the extra precision serves no purpose, and there is a mismatch between Firefox’s behavior on Linux vs. Mac & Win.
(Reporter)

Updated

3 years ago
Keywords: privacy
Priority: -- → P1
(Assignee)

Updated

3 years ago
Component: Untriaged → DOM
Product: Firefox → Core
(Assignee)

Comment 1

3 years ago
FWIW, I can't reproduce this; I guess the number reported by dbus is hardware/kernel/whatever-dependent (I'm testing in a vmware fusion vm on a mac).
Component: DOM → Hardware Abstraction Layer (HAL)
Priority: P1 → --
(Assignee)

Comment 2

3 years ago
Created attachment 8552454 [details] [diff] [review]
round power percentage to whole number before passing on,

Mounir, does this make sense? You seem to have written most of this.
Attachment #8552454 - Flags: review?(mounir)
(Assignee)

Updated

3 years ago
Assignee: nobody → gijskruitbosch+bugs
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Assignee)

Comment 3

3 years ago
Comment on attachment 8552454 [details] [diff] [review]
round power percentage to whole number before passing on,

I hear Mounir left. Gabriele, can you review this or find someone who can?
Attachment #8552454 - Flags: review?(mounir) → review?(gsvelto)
(In reply to :Gijs Kruitbosch from comment #3)
> I hear Mounir left. Gabriele, can you review this or find someone who can?

Sure, for reviews of HAL patches it's either :dhylands who is the component owner or me, the sole peer ATM.
Comment on attachment 8552454 [details] [diff] [review]
round power percentage to whole number before passing on,

Review of attachment 8552454 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM with a minuscule nit.

::: hal/linux/UPowerClient.cpp
@@ +431,2 @@
>    /*
>     * The battery level might be very close to 100% (like 99.xxxx%) without

nit: This comment suggests that a reading might have four decimal places, better to update it too to avoid confusion.
Attachment #8552454 - Flags: review?(gsvelto) → review+
(Assignee)

Comment 6

3 years ago
w/ nit:

https://hg.mozilla.org/integration/mozilla-inbound/rev/7d8d4ff84ddb
https://hg.mozilla.org/mozilla-central/rev/7d8d4ff84ddb
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.