Skip to content

Commit 1e0e2c9

Browse files
author
Raphael Kubo da Costa
committed
Declare quantization and threshold check algorithms for extension to the spec.
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. The changes work as follows: * Concrete sensor types (i.e. extension specifications) may define a threshold check algorithm that compares two readings and returns whether they differ enough or not. * Concrete sensor types may define a reading quantization algorithm that is used to quantize readings returned by the "get value from latest reading" algorithm (which is used by attribute getters, for example). * Specifications may define one of the algorithms above, both, or none, but are encouraged to go with either none or both.
1 parent 9881fa8 commit 1e0e2c9

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

index.bs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,20 @@ 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+
519+
Implementations of concrete sensors may define a [=reading quantization
520+
algorithm=] to reduce the accuracy of the [=sensor readings=] received from a
521+
[=device sensor=].
522+
523+
Note: these two mitigation measures often complement each other. An
524+
implementation that only executes the [=threshold check algorithm=] might
525+
expose readings that are too precise, while an implementation that only rounds
526+
readings up may provide attackers with information about more precise readings
527+
when raw readings are rounded to different values.
528+
515529
Note: Inaccuracies will further increase for operations carried out on the
516530
[=sensor readings=], or time deltas calculated from the [=reading timestamp|timestamps=].
517531
So, this mitigation strategy can affect certain use cases.
@@ -803,11 +817,23 @@ A [=sensor type=] has a [=permission request algorithm=].
803817
A [=sensor type=] has a [=set/is empty|nonempty=] [=ordered set|set=] of associated
804818
[=policy-controlled feature=] tokens referred to as <dfn export>sensor feature names</dfn>.
805819

820+
A [=sensor type=] may have an associated <dfn export>threshold check
821+
algorithm</dfn>, which takes as arguments two separate [=sensor readings=] and
822+
determines if the difference between them is higher than an
823+
implementation-defined [=reading change threshold=].
824+
825+
A [=sensor type=] may have an associated <dfn export>reading quantization
826+
algorithm</dfn>, which takes a [=sensor reading=] and returns a less accurate
827+
[=sensor reading=].
828+
806829
<h3 id="model-sensor">Sensor</h3>
807830

808-
The current [=browsing context=]'s [=platform sensor=] has an associated [=ordered set|set=]
809-
of <dfn>activated sensor objects</dfn>, which is initially [=set/is empty|empty=] and an
810-
associated <dfn>latest reading</dfn> [=ordered map|map=], which holds the latest available [=sensor readings=].
831+
The current [=browsing context=]'s [=platform sensor=] must have:
832+
- An associated [=ordered set|set=] of <dfn>activated sensor objects</dfn>,
833+
which is initially [=set/is empty|empty=];
834+
- An associated <dfn>latest reading</dfn> [=ordered map|map=], which holds the
835+
latest available [=sensor readings=].
836+
- An associated [=sensor type=].
811837

812838
Note: User agents can share the [=latest reading=] [=ordered map|map=] and
813839
the [=activated sensor objects=] [=ordered set|set=] between different
@@ -1393,6 +1419,11 @@ to {{SensorErrorEventInit}}.
13931419
: output
13941420
:: None
13951421

1422+
1. Let |type| be |sensor|'s associated [=sensor type=].
1423+
1. If |type|'s [=threshold check algorithm=] is defined, then:
1424+
1. Let |result| be the result of invoking |type|'s [=threshold check algorithm=]
1425+
with |reading| and |latest reading|.
1426+
1. If |result| is false, then abort these steps.
13961427
1. [=map/For each=] |key| → <var ignore>value</var> of [=latest reading=].
13971428
1. [=map/Set=] [=latest reading=][|key|] to the corresponding
13981429
value of |reading|.
@@ -1514,6 +1545,9 @@ to {{SensorErrorEventInit}}.
15141545

15151546
1. If |sensor_instance|.{{[[state]]}} is "activated",
15161547
1. Let |readings| be the [=latest reading=] of |sensor_instance|'s related [=platform sensor=].
1548+
1. Let |type| be |sensor_instance|'s associated [=platform sensor=]'s associated [=sensor type=].
1549+
1. If |type|'s [=reading quantization algorithm=] is defined, then:
1550+
1. Set |readings| to the result of invoking |type|'s [=reading quantization algorithm=] with |readings|.
15171551
1. If the [=extension specification=] defines a [=local coordinate system=] for |sensor_instance|,
15181552
1. Remap (see [[COORDINATES-TRANSFORMATION]]) |readings| values to the
15191553
[=local coordinate system=].

0 commit comments

Comments
 (0)