-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.bs
271 lines (219 loc) · 10.6 KB
/
index.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<pre class="metadata">
Title: Gyroscope
Status: ED
Level: none
ED: https://w3c.github.io/gyroscope/
Shortname: gyroscope
TR: https://www.w3.org/TR/gyroscope/
Editor: Anssi Kostiainen 41974, Intel Corporation, http://intel.com/
Former Editor: Mikhail Pozdnyakov 78325, Intel Corporation, http://intel.com/
Group: dap
Abstract:
This specification defines a concrete sensor interface to monitor
the rate of rotation around the device's local three primary axes.
Version History: https://github.com/w3c/gyroscope/commits/main/index.bs
Issue Tracking: Gyroscope Issues Repository https://github.com/w3c/gyroscope/issues
Indent: 2
Repository: w3c/gyroscope
Markup Shorthands: markdown on
Inline Github Issues: true
!Test Suite: <a href="https://github.com/web-platform-tests/wpt/tree/main/gyroscope">web-platform-tests on GitHub</a>
Boilerplate: omit issues-index, omit conformance, repository-issue-tracking no
Include MDN Panels: if possible
Implementation Report: https://www.w3.org/wiki/DAS/Implementations
Default Biblio Status: current
Status Text: This document is maintained and updated at any time. Some parts of this document are work in progress.
</pre>
<pre class="anchors">
urlPrefix: https://w3c.github.io/sensors/; spec: GENERIC-SENSOR
type: dfn
text: high-level
text: latest reading
text: default sensor
text: sensor type
text: local coordinate system
text: location tracking; url: location-tracking
text: keylogging; url: keystroke-monitoring
text: fingerprinting; url: device-fingerprinting
text: user identifying; url: user-identifying
text: eavesdropping; url: eavesdropping
text: generic mitigations; url: mitigation-strategies
text: supported sensor options
urlPrefix: https://w3c.github.io/accelerometer/; spec: ACCELEROMETER
type: dfn
text: device coordinate system
text: screen coordinate system
</pre>
<pre class=biblio>
{
"KEYSTROKEDEFENSE": {
"authors": [
"Song, Yihang, et al"
],
"id": "KEYSTROKEDEFENSE",
"href": "https://arxiv.org/abs/1410.7746",
"title": "Two novel defenses against motion-based keystroke inference attacks",
"date": "2014",
"status": "Informational",
"publisher": "arXiv"
},
"TOUCHSIGNATURES": {
"authors": [
"Mehrnezhad, Maryam, et al"
],
"id": "TOUCHSIGNATURES",
"href": "https://arxiv.org/abs/1602.04115",
"title": "Touchsignatures: identification of user touch actions and pins based on mobile sensor data via javascript",
"date": "2016",
"status": "Informational",
"publisher": "Journal of Information Security and Applications"
}
}
</pre>
Introduction {#intro}
============
The Gyroscope API extends the Generic Sensor API [[GENERIC-SENSOR]]
to provide information about the angular velocity around the device's local X, Y and Z axis
in terms of radian per seconds units.
Use Cases and Requirements {#usecases-requirements}
==============================
The use cases and requirements are addressed in the <cite><a href="https://w3c.github.io/motion-sensors/#usecases-and-requirements">
Motion Sensors Explainer</a></cite> document.
Examples {#examples}
========
<div class="example">
<pre highlight="js">
let sensor = new Gyroscope();
sensor.start();
sensor.onreading = () => {
console.log("Angular velocity around the X-axis " + sensor.x);
console.log("Angular velocity around the Y-axis " + sensor.y);
console.log("Angular velocity around the Z-axis " + sensor.z);
};
sensor.onerror = event => console.log(event.error.name, event.error.message);
</pre>
</div>
Security and Privacy Considerations {#security-and-privacy}
===================================
[=Sensor readings=] provided by inertial sensors, such as gyroscope, could be used by adversaries
to exploit various security threats, for example, [=keylogging=], [=location tracking=],
[=fingerprinting=], [=user identifying=] and even [=eavesdropping=].
Research papers published by security community, for instance, [[KEYSTROKEDEFENSE]], indicate that
by throttling the frequency, risks of successful attacks are not fully eliminated, while throttling
may greatly affect usefulness of a web application with legitimate reasons to use the sensors.
The [[TOUCHSIGNATURES]] research paper proposes that implementations can provide visual indication when
inertial sensors are in use and/or require explicit user consent to access [=sensor readings=].
These mitigation strategies complement the [=generic mitigations=] defined
in the Generic Sensor API [[!GENERIC-SENSOR]].
Permissions Policy integration {#permissions-policy-integration}
==============================
This specification utilizes the [=policy-controlled feature=] identified by the string "<code><a permission>gyroscope</a></code>" defined in [[DEVICE-ORIENTATION]].
Model {#model}
=====
The <dfn id="gyroscope-sensor-type">Gyroscope</dfn> <a>sensor type</a> has the following associated data:
: [=Extension sensor interface=]
:: {{Gyroscope}}
: [=Sensor permission names=]
:: "<code><a permission>gyroscope</a></code>"
: [=Sensor feature names=]
:: <a permission>"gyroscope"</a>
: [=powerful feature/Permission revocation algorithm=]
:: Invoke the [=generic sensor permission revocation algorithm=] with "<code><a permission>gyroscope</a></code>".
: [=Default sensor=]
:: The device's main gyroscope sensor.
: [=Virtual sensor type=]
:: "<code><a data-lt="gyroscope virtual sensor type">gyroscope</a></code>"
A [=latest reading=] of a {{Sensor}} of <a>Gyroscope</a> <a>sensor type</a> includes three [=map/entries=]
whose [=map/keys=] are "x", "y", "z" and whose [=map/values=] contain current <a>angular
velocity</a> about the corresponding axes.
The <dfn>angular velocity</dfn> is the rate at which the device rotates
about a specified axis in a [=local coordinate system=] defined by the device.
Its unit is the radian per second (rad/s) [[SI]].
The sign of the current <a>angular velocity</a> depends on the rotation direction and
it must be according to the right-hand convention in a [=local coordinate system=]
defined by the device, such that positive rotation around an axis is clockwise when
viewed along the positive direction of the axis (see figure below).
<img src="images/gyroscope_sensor_coordinate_system.png" srcset="images/gyroscope_sensor_coordinate_system.svg" alt="Device's local coordinate system and rotation.">
Reference Frame {#reference-frame}
----------------
The [=local coordinate system=] represents the reference frame for the
{{Gyroscope}} [=sensor readings|readings=]. It can be either
the [=device coordinate system=] or the [=screen coordinate system=].
API {#api}
===
The Gyroscope Interface {#gyroscope-interface}
------------------------
<pre class="idl">
[SecureContext, Exposed=Window]
interface Gyroscope : Sensor {
constructor(optional GyroscopeSensorOptions sensorOptions = {});
readonly attribute double? x;
readonly attribute double? y;
readonly attribute double? z;
};
enum GyroscopeLocalCoordinateSystem { "device", "screen" };
dictionary GyroscopeSensorOptions : SensorOptions {
GyroscopeLocalCoordinateSystem referenceFrame = "device";
};
</pre>
<div algorithm>
The <dfn constructor for="Gyroscope" lt="Gyroscope(sensorOptions)"><code>new Gyroscope(|sensorOptions|)</code></dfn> constructor steps are to invoke the [=construct a gyroscope object=] abstract operation with [=this=] and |sensorOptions|.
</div>
[=Supported sensor options=] for {{Gyroscope}} are
"frequency" and "referenceFrame".
### Gyroscope.x ### {#gyroscope-x}
The {{Gyroscope/x!!attribute}} attribute of the {{Gyroscope}}
interface represents the current <a>angular velocity</a> around X-axis.
In other words, this attribute returns the result of invoking
[=get value from latest reading=] with <emu-val>this</emu-val>
and "x" as arguments.
### Gyroscope.y ### {#gyroscope-y}
The {{Gyroscope/y!!attribute}} attribute of the {{Gyroscope}}
interface represents the current <a>angular velocity</a> around Y-axis.
In other words, this attribute returns the result of invoking
[=get value from latest reading=] with <emu-val>this</emu-val>
and "y" as arguments.
### Gyroscope.z ### {#gyroscope-z}
The {{Gyroscope/z!!attribute}} attribute of the {{Gyroscope}}
interface represents the current <a>angular velocity</a> around Z-axis.
In other words, this attribute returns the result of invoking
[=get value from latest reading=] with <emu-val>this</emu-val>
and "z" as arguments.
Abstract Operations {#abstract-operations}
===================
<h3 dfn export>Construct a Gyroscope object</h3>
<div algorithm="construct a gyroscope object">
: input
:: |object|, a {{Gyroscope}} object.
:: |options|, a {{GyroscopeSensorOptions}} object.
1. Let |allowed| be the result of invoking [=check sensor policy-controlled features=]
with |object|'s [=sensor type=].
1. If |allowed| is false, then:
1. [=Throw=] a {{SecurityError}} {{DOMException}}.
1. Invoke [=initialize a sensor object=] with |object| and |options|.
1. If |options|.{{referenceFrame!!dict-member}} is "screen", then:
1. Set |object|'s [=local coordinate system=] to the [=screen coordinate system=].
1. Otherwise, define |object|'s [=local coordinate system=] to the [=device coordinate system=].
</div>
Automation {#automation}
==========
This section extends [[GENERIC-SENSOR#automation]] by providing [=Gyroscope=]-specific virtual sensor metadata.
The [=gyroscope virtual sensor type=] and its corresponding entry in the [=per-type virtual sensor metadata=] [=map=] are defined in [[DEVICE-ORIENTATION#automation]].
Acknowledgements {#acknowledgements}
================
Tobie Langel for the work on Generic Sensor API.
Conformance {#conformance}
===========
Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words "MUST",
"MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [[!RFC2119]]
A <dfn>conformant user agent</dfn> must implement all the requirements
listed in this specification that are applicable to user agents.
The IDL fragments in this specification must be interpreted as required for
conforming IDL fragments, as described in the Web IDL specification. [[!WEBIDL]]