Skip to content

Commit 2eb7baa

Browse files
author
Raphael Kubo da Costa
committed
Define and use a "threshold check algorithm" that concrete sensors can use.
Related to w3c/ambient-light#63, which says the granularity of the data exposed by Ambient Light Sensors should be specified normatively. This commit goes a bit further and lays out some of the scaffolding necessary to specify the anti-fingerprinting measures currently implemented by Chrome -- namely, not only are illuminance values rounded but there's also a threshold value check to avoid storing values that are too close to the latest reading. A new algorithm, the threshold check algorithm, can be defined by concrete sensors and is associated with a sensor type. It is invoked by the "update sensor reading" abstract operation when defined, and if it returns false, "update sensor reading" will abort and not update the `latest reading` map. A few other parts also had to be adjusted to make this work possible: - A platform sensor is now explicitly associated with a sensor type. - Extension sensor attribute getters are no longer normatively required to simply return the value of invoking "get value from latest readings", as `AmbientLightSensor.illuminance`'s getter needs to do extra work. We only require that the attributes be read-only now.
1 parent 1919432 commit 2eb7baa

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

index.bs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,10 @@ might also help mitigate certain threats,
512512
thus user agents should not provide
513513
unnecessarily verbose readouts of sensors data.
514514

515+
Implementations of concrete sensors may define a [=threshold check algorithm=]
516+
so that new readings that do not meet the [=reading change threshold=] when
517+
compared to the [=latest readings=] are discarded.
518+
515519
Note: Inaccuracies will further increase for operations carried out on the
516520
[=sensor readings=], or time deltas calculated from the [=reading timestamp|timestamps=].
517521
So, this mitigation strategy can affect certain use cases.
@@ -806,11 +810,19 @@ A [=sensor type=] has a [=permission request algorithm=].
806810
A [=sensor type=] has a [=set/is empty|nonempty=] [=ordered set|set=] of associated
807811
[=policy-controlled feature=] tokens referred to as <dfn export>sensor feature names</dfn>.
808812

813+
A [=sensor type=] may have an associated <dfn export>threshold check
814+
algorithm</dfn>, which takes as arguments two separate [=sensor readings=] and
815+
determines if the difference between them is higher than an
816+
implementation-defined [=reading change threshold=].
817+
809818
<h3 id="model-sensor">Sensor</h3>
810819

811-
The current [=browsing context=]'s [=platform sensor=] has an associated [=ordered set|set=]
812-
of <dfn>activated sensor objects</dfn>, which is initially [=set/is empty|empty=] and an
813-
associated <dfn>latest reading</dfn> [=ordered map|map=], which holds the latest available [=sensor readings=].
820+
The current [=browsing context=]'s [=platform sensor=] must have:
821+
- An associated [=ordered set|set=] of <dfn>activated sensor objects</dfn>,
822+
which is initially [=set/is empty|empty=];
823+
- An associated <dfn>latest reading</dfn> [=ordered map|map=], which holds the
824+
latest available [=sensor readings=].
825+
- An associated [=sensor type=].
814826

815827
Note: User agents can share the [=latest reading=] [=ordered map|map=] and
816828
the [=activated sensor objects=] [=ordered set|set=] between different
@@ -1396,6 +1408,11 @@ It represents the {{DOMException}} object passed to {{SensorErrorEventInit}}.
13961408
: output
13971409
:: None
13981410

1411+
1. Let |type| be |sensor|'s associated [=sensor type=].
1412+
1. If |type|'s [=threshold check algorithm=] is defined, then:
1413+
1. Let |result| be the result of invoking |type|'s [=threshold check algorithm=]
1414+
with |reading| and |latest reading|.
1415+
1. If |result| is false, then abort these steps.
13991416
1. [=map/For each=] |key| → <var ignore>value</var> of [=latest reading=].
14001417
1. [=map/Set=] [=latest reading=][|key|] to the corresponding
14011418
value of |reading|.
@@ -2041,10 +2058,8 @@ each [=sensor type=] in [=extension specifications=]:
20412058
[=extension sensor interface=] if it cannot support the corresponding sensor
20422059
options.
20432060

2044-
The [=extension sensor interface=] [=attributes=] which expose [=sensor readings=] are
2045-
[=read only=] and their getters must return the result of invoking
2046-
[=get value from latest reading=] with <strong>this</strong> and
2047-
[=attribute=] [=identifier=] as arguments.
2061+
The [=extension sensor interface=] [=attributes=] which expose [=sensor readings=]
2062+
must be [=read only=].
20482063

20492064
- A [=powerful feature/name=], if the [=sensor type=] is not representing
20502065
[=sensor fusion=] (otherwise, [=powerful feature/names=]

0 commit comments

Comments
 (0)