Skip to content

Commit fb2fbf3

Browse files
authored
Merge pull request #48 from w3c/use_initialize_operation
Use newly introduced "initialize a sensor object" operation
2 parents dc8a795 + aa41971 commit fb2fbf3

File tree

2 files changed

+88
-19
lines changed

2 files changed

+88
-19
lines changed

index.bs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ urlPrefix: https://w3c.github.io/sensors; spec: GENERIC-SENSOR
3333
text: reporting mode; url: reporting-modes
3434
text: auto
3535
text: construct a sensor object; url: construct-sensor-object
36+
text: initialize a sensor object; url: initialize-a-sensor-object
3637
text: limit maximum sampling frequency; url: limit-max-frequency
3738
text: reduce accuracy; url: reduce-accuracy
3839
text: mitigation strategies; url: mitigation-strategies
3940
text: sampling frequency
4041
text: sensor type
4142
text: sensor readings
43+
text: check sensor policy-controlled features; url: check-sensor-policy-controlled-features
4244
</pre>
4345
<pre class=biblio>
4446
{
@@ -230,15 +232,37 @@ The AmbientLightSensor Interface {#ambient-light-sensor-interface}
230232
};
231233
</pre>
232234

233-
To <dfn>Construct an AmbientLightSensor Object</dfn> the user agent must invoke the
234-
<a>construct a Sensor object</a> abstract operation.
235+
To construct an {{AmbientLightSensor}} object the user agent must invoke the
236+
[=construct an ambient light sensor object=] abstract operation.
235237

236238
### The illuminance attribute ### {#ambient-light-sensor-reading-attribute}
237239

238240
The <a attribute for="AmbientLightSensor">illuminance</a> attribute of the {{AmbientLightSensor}}
239241
interface represents the [=current light level=] and returns the result of invoking
240242
[=get value from latest reading=] with `this` and "illuminance" as arguments.
241243

244+
Abstract Operations {#abstract-operations}
245+
===================
246+
247+
<h3 dfn export>Construct an ambient light sensor object</h3>
248+
249+
<div algorithm="construct an ambient light sensor object">
250+
251+
: input
252+
:: |options|, a {{SensorOptions}} object.
253+
: output
254+
:: An {{AmbientLightSensor}} object.
255+
256+
1. Let |allowed| be the result of invoking [=check sensor policy-controlled features=]
257+
with {{AmbientLightSensor}}.
258+
1. If |allowed| is false, then:
259+
1. [=Throw=] a {{SecurityError}} {{DOMException}}.
260+
1. Let |ambient_light_sensor| be the new {{AmbientLightSensor}} object.
261+
1. Invoke [=initialize a sensor object=] with |ambient_light_sensor| and |options|.
262+
1. Return |ambient_light_sensor|.
263+
</div>
264+
265+
242266
Use Cases and Requirements {#usecases-requirements}
243267
=========
244268

0 commit comments

Comments
 (0)