The following changes have been made since the W3C Candidate Recommendation 01 October 2013 (diff):
LightLevelEvent
interface to align with
implementations.
The functionality described in this specification was initially specified as part of the Sensor API but has been extracted in order to be more straightforward to implement, and in order to produce a specification that could be implemented on its own merits without interference with other features.
The DeviceLightEvent interface provides information about the ambient light levels, as detected by the device's light detector, in terms of lux units.
The 'light-level' media feature [[mediaqueries4]] provides more granular, less precise, information about the ambient light level.
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
Implementations that use ECMAScript to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.
The
EventHandler
interface represents a callback function used for event
handlers as defined in [[!HTML5]].
The concepts queue a task, fires a simple event, and top-level browsing context are defined in [[!HTML5]].
The terms event handlers and event handler event types are defined in [[!HTML5]].
Event constructor behavior is defined in constructing events chapter in [[!DOM4]].
The concepts create an event and fire an event are defined in [[!DOM4]].
The current light level is a value that represents the ambient light levels around the hosting device in lux units.
Privacy risks can arise when this specification is used in combination with other functionality or when used over time, specifically with the risk of correlation of data and user identification through fingerprinting. Web application developers using these JavaScript APIs should consider how this information might be correlated with other information and the privacy risks that might be created. The potential risks of collection of such data over a longer period of time should also be considered.
Variations in implementation light level values as well as event firing rates offer the possibility of fingerprinting to identify users. Browser implementations may reduce the risk by limiting event rates available to web application developers.
If the same JavaScript code using the API can be used simultaneously in different window contexts on the same device it may be possible for that code to correlate the user across those two contexts, creating unanticipated tracking mechanisms.
Browser implementations should consider providing the user an indication of when the sensor is used and allowing the user to disable sensing.
Web application developers that use this specification should perform a privacy assessment of their application taking all aspects of their application into consideration.
The event defined in this specification is only fired in the top-level browsing context to avoid the privacy risk of sharing the information defined in this specification with contexts unfamiliar to the user. For example, a mobile device will only fire the event on the active tab, and not on the background tabs or within iframes.
The HTML5 specification [[!HTML5]] defines a Window interface, which this specification extends:
The ondevicelight
event handler and its corresponding
event handler event type devicelight
MUST be supported
as an IDL attribute by all objects implementing the Window
interface.
The value
attribute of the DeviceLightEvent
interface MUST return the value it was initialized to. When the
object is created, this attribute MUST be initialized to positive
Infinity. It represents the current light level.
When a user agent is required to fire a device light event, the user agent MUST run the following steps:
devicelight
, which
bubbles, is not cancelable, and has no default action, that also
meets the following conditions:
value
attribute to positive Infinity, otherwise initialize the
attribute to the current light level.
When the current light level changes, the user agent MUST queue a task to fire a device light event at the top-level browsing context's Window object.
The following are the event handlers (and their corresponding event handler event types) that MUST be supported as attributes by the Window object:
event handler | event handler event type |
---|---|
ondevicelight |
devicelight |
Doug Turner for the initial prototype and Marcos Caceres for the test suite.