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
Editorial: 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 goal of this model is to treat an Ambient Light Sensor as potentially as
324
+
invasive as an actual camera device and subject it to the same strict privacy
325
+
requirements together with the Generic Sensor mitigations described in
326
+
[[GENERIC-SENSOR#security-and-privacy]] and the other Ambient Light
327
+
Sensor-specific measures described in this section.
328
+
286
329
Model {#model}
287
330
=====
288
331
@@ -292,12 +335,12 @@ subclass is the {{AmbientLightSensor}} class.
292
335
The <a>Ambient Light Sensor</a> has a <a>default sensor</a>,
293
336
which is the device's main light detector.
294
337
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".
338
+
The <a>Ambient Light Sensor</a>'s [=sensor permission names=] is an
339
+
[=set/empty=][=ordered set|set=].
340
+
341
+
Note: See [[#local-video-source-requirement]]. This specification relies on the
342
+
permission model specified in the [[MEDIACAPTURE-STREAMS]] specification
343
+
instead.
301
344
302
345
The <a>Ambient Light Sensor</a> is a [=policy-controlled feature=] identified by the string "ambient-light-sensor". Its [=default allowlist=] is `'self'`.
303
346
@@ -345,6 +388,35 @@ The {{AmbientLightSensor/illuminance}} getter steps are:
345
388
reading=] with [=this=] and "illuminance" as arguments.
346
389
1. Return |illuminance|.
347
390
391
+
### Media Capture and Streams integration ### {#media-capture-and-streams-integration}
392
+
393
+
As discussed in [[#local-video-source-requirement]], illuminance readouts are
394
+
provided only if the same {{Window}} with an {{AmbientLightSensor}} object has
395
+
at least one local video [=source=] that is not [=muted=] or [=stopped=].
396
+
397
+
The [=ambient light pre-activation checks algorithm=] is invoked by
398
+
{{Sensor/start()}} as specified in [[GENERIC-SENSOR]].
399
+
400
+
Furthermore, whenever an item is added to the {{Window}}.\[[devicesLiveMap]]
401
+
internal slot, or one of its items has its value changed, implementations MUST
402
+
run the following steps:
403
+
404
+
<div algorithm="deactivate sensors if necessary">
405
+
1. Let |global| be the {{Window}} object of the affected \[[devicesLiveMap]]
406
+
internal slot.
407
+
1. Let |result| be the result of invoking [=check for active local video sources=] with |global|.
408
+
1. If |result| is true, return.
409
+
1. For each {{AmbientLightSensor}} object |sensor| whose [=relevant global
410
+
object=] is |global|:
411
+
1. If |sensor|.{{[[state]]}} is "idle", then [=continue=].
412
+
1. Invoke [=deactivate a sensor object=] with |sensor|.
413
+
1. Let |e| be the result of [=created|creating=]
414
+
a "{{NotReadableError}}" {{DOMException}}.
415
+
1. [=Queue a global task=] on the [=sensor task source=] with |global| to
0 commit comments