You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop own powerful feature, require active local video source.
Fixes#79.
The idea is that, based on the research on potential attacks on the Ambient
Light Sensor API, it is important to prompt users before allowing access to
illuminance readouts. This was already mandated by the main Generic Sensors
spec, as `Sensor.start()` runs the "Request sensor access" abstract
operation.
The challenge with the Ambient Light Sensor API is prompting users in a way
that they understand what they are being prompted for; the assumption is
that most users are not familiar with what an Ambient Light sensor is.
We have chosen to solve this issue by dropping our "ambient-light-sensor"
powerful feature name altogether and integrating with the Media Capture and
Streams specification instead: we consider an Ambient Light Sensor to be a
1x1 camera and require there to be at least one local video source that is
not muted or stopped in order for illuminance readouts to be provided.
Per the Media Capture and Streams specification, this is only possible if
script has called `MediaDevices.getUserMedia()` and granted the "camera"
permission. This also means the User Agent has at least indicated to the
user that a local video source has started being used.
In other words, an Ambient Light Sensor only provides readings if a local
video source (such as a camera) is currently active and being used in the
same window as the AmbientLightSensor instance, and when all local video
sources stop we also stop providing readouts and fire an "error" with a
NotReadableError exception.
The Use Cases section had to be shortened, as some items described there no
longer make much sense when a camera is required.
The goal of this model is to treat an Ambient Light Sensor as potentially as
325
+
invasive as an actual camera device and subject it to the same strict privacy
326
+
requirements together with the Generic Sensor mitigations described in
327
+
[[GENERIC-SENSOR#security-and-privacy]] and the other Ambient Light
328
+
Sensor-specific measures described in this section.
329
+
286
330
Model {#model}
287
331
=====
288
332
@@ -292,12 +336,12 @@ subclass is the {{AmbientLightSensor}} class.
292
336
The <a>Ambient Light Sensor</a> has a <a>default sensor</a>,
293
337
which is the device's main light detector.
294
338
295
-
The <a>Ambient Light Sensor</a> is a [=powerful feature=]that is identified by
296
-
the [=powerful feature/name=]"<dfn permission export>ambient-light-sensor</dfn>",
297
-
which is also its associated [=sensor permission name=]. Its
298
-
[=powerful feature/permission revocation algorithm=] is the result of calling
299
-
the [=generic sensor permission revocation algorithm=] with
300
-
"ambient-light-sensor".
339
+
The <a>Ambient Light Sensor</a>'s [=sensor permission names=] is an
340
+
[=set/empty=][=ordered set|set=].
341
+
342
+
Note: See [[#local-video-source-requirement]]. This specification relies on the
343
+
permission model specified in the [[MEDIACAPTURE-STREAMS]] specification
344
+
instead.
301
345
302
346
The <a>Ambient Light Sensor</a> is a [=policy-controlled feature=] identified by the string "ambient-light-sensor". Its [=default allowlist=] is `'self'`.
303
347
@@ -345,6 +389,35 @@ The {{AmbientLightSensor/illuminance}} getter steps are:
345
389
reading=] with [=this=] and "illuminance" as arguments.
346
390
1. Return |illuminance|.
347
391
392
+
### Media Capture and Streams integration ### {#media-capture-and-streams-integration}
393
+
394
+
As discussed in [[#local-video-source-requirement]], illuminance readouts are
395
+
provided only if the same {{Window}} with an {{AmbientLightSensor}} object has
396
+
at least one local video [=source=] that is not [=muted=] or [=stopped=].
397
+
398
+
The [=ambient light pre-activation checks algorithm=] is invoked by
399
+
{{Sensor/start()}} as specified in [[GENERIC-SENSOR]].
400
+
401
+
Furthermore, whenever an item is added to the {{Window}}.\[[devicesLiveMap]]
402
+
internal slot, or one of its items has its value changed, implementations MUST
403
+
run the following steps:
404
+
405
+
<div algorithm="deactivate sensors if necessary">
406
+
1. Let |global| be the {{Window}} object of the affected \[[devicesLiveMap]]
407
+
internal slot.
408
+
1. Let |result| be the result of invoking [=check for active local video sources=] with |global|.
409
+
1. If |result| is true, return.
410
+
1. For each {{AmbientLightSensor}} object |sensor| whose [=relevant global
411
+
object=] is |global|:
412
+
1. If |sensor|.{{[[state]]}} is "idle", then [=continue=].
413
+
1. Invoke [=deactivate a sensor object=] with |sensor|.
414
+
1. Let |e| be the result of [=created|creating=]
415
+
a "{{NotReadableError}}" {{DOMException}}.
416
+
1. [=Queue a global task=] on the [=sensor task source=] with |global| to
0 commit comments