ConceptioArchiveW3C TR
W3C TRopen access

proximity

W3C · w3c_tr
W3C TR · Standards · License: Open Access
Open Source ↗
w3c, standard

Proximity Sensor W3C Working Draft , 14 May 2026 More details about this document This version: https://www.w3.org/TR/2026/WD-proximity-20260514/ Latest published version: https://www.w3.org/TR/proximity/ Editor's Draft: https://w3c.github.io/proximity/ Previous Versions: https://www.w3.org/TR/2025/WD-proximity-20250212/ History: https://www.w3.org/standards/history/proximity/ Feedback: [email protected] with subject line “ [proximity] … message topic … ” ( archives ) GitHub Editors: Anssi Kostiainen ( Intel Corporation ) Rijubrata Bhaumik ( Intel Corporation ) Former Editor: Dzung D Tran ( Intel Corporation ) Bug Reports: via the w3c/proximity repository on GitHub Issue Tracking: Issues Test Suite: web-platform-tests on GitHub Copyright © 2026 World Wide Web Consortium . W3C ® liability , trademark and permissive document license rules apply. Abstract This specification defines a concrete sensor interface to monitor the presence of nearby physical objects without physical contact. Status of this document This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index. This document was published by the Devices and Sensors Working Group as a Working Draft using the Recommendation track . This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to [email protected] ( subscribe , archives ). When sending e-mail, please put the text “proximity” in the subject, preferably like this: “[proximity] …summary of comment… ”. All comments are welcome. Publication as a Working Draft does not imply endorsement by W3C and its Members. This is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. This document was produced by a group operating under the W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy . This document is governed by the 18 August 2025 W3C Process Document . This specification is not implemented in any browser engine. It is not expected to advance to W3C Recommendation in its current form. The Devices and Sensors Working Group will perform a round of self-review and revisions on the security and privacy aspects of the API before requesting horizontal review. Existing security and privacy issues are available. Table of Contents 1 Introduction 2 Examples 3 Security and Privacy Considerations 4 Permissions Policy integration 5 Model 6 API 6.1 The ProximitySensor Interface 6.1.1 The distance attribute 6.1.2 The max attribute 6.1.3 The near attribute 7 Abstract Operations 7.1 Construct a proximity sensor object 8 Automation 8.1 Proximity reading parsing algorithm 9 Limitations of Proximity Sensors 10 Acknowledgements 11 Conformance Index Terms defined by this specification Terms defined by reference References Normative References IDL Index 1. Introduction The Proximity Sensor extends the Generic Sensor API [GENERIC-SENSOR] to provide information about proximity level, as detected by the device’s primary proximity sensor. The proximity level is reported as the distance (in centimeter) from the sensor to the closest visible surface. § 9 Limitations of Proximity Sensors describes more about the potential limitations, why the precise distance value reported by different devices can be different, due to differences in detection method, sensor construction, etc. Moreover some proximity sensors might be only able to provide just a boolean to indicate if there is a physical object which is near, more like presence detection, than an absolute value for the distance. 2. Examples let sensor = new ProximitySensor (); sensor . start (); sensor . onreading = () => console . log ( sensor . distance ); sensor . onerror = event => console . log ( event . error . name , event . error . message ); 3. Security and Privacy Considerations Proximity sensor provides information about closeness of the sensor to nearby objects, thus, may expose privacy sensitive information for user identifying and/or fingerprinting attacks. To mitigate these, user agents should use one or both of the following mitigation strategies : reduce accuracy of a sensor reading limit maximum sampling frequency These mitigation strategies complement the generic mitigations defined in the Generic Sensor API [GENERIC-SENSOR] . 4. Permissions Policy integration This specification defines a policy-controlled feature identified by the string " proximity-sensor ". Its default allowlist is " self ". 5. Model The Proximity Sensor sensor type has the following associated data: Extension sensor interface ProximitySensor Sensor permission names " proximity " Sensor feature names " proximity-sensor " Permission revocation algorithm Invoke the generic sensor permission revocation algorithm with " proximity ". Default sensor The device’s main proximity detector. Virtual sensor type " proximity " A latest reading for a Sensor of Proximity Sensor sensor type includes three entries whose keys are "distance", "max", "near" and whose values contain distance , max and near values. The distance is a value that represents the distance between a device and the closest visible surface of the physical object within the sensing range . Its unit is the centimeter (cm). The max is a value that represents the maximum sensing range of the main proximity detector, in centimeters. The near is a value that represent the presence of a visible surface in the vicinity of the main proximity detector. 6. API 6.1. The ProximitySensor Interface [ SecureContext , Exposed = Window ] interface ProximitySensor : Sensor { constructor ( optional SensorOptions sensorOptions = {}); readonly attribute double ? distance ; readonly attribute double ? max ; readonly attribute boolean ? near ; }; To construct a ProximitySensor object the user agent must invoke the construct a proximity sensor object abstract operation. 6.1.1. The distance attribute The distance attribute of the ProximitySensor interface returns the result of invoking get value from latest reading with this and "distance" as arguments. If the physical object is outside the sensing range , the attribute must return null. 6.1.2. The max attribute The max attribute of the ProximitySensor interface returns the result of invoking get value from latest reading with this and "max" as arguments. 6.1.3. The near attribute The near attribute of the ProximitySensor interface returns the result of invoking get value from latest reading with this and "near" as arguments. If the physical object is outside the sensing range , the attribute must return null. Note: If the implementation is unable to provide the near value, it could infer the near value from the value of distance . For example, if distance is not equal to max , it could imply there is a physical object in the sensing range . 7. Abstract Operations 7.1. Construct a proximity sensor object input options , a SensorOptions object. output A ProximitySensor object. Let allowed be the result of invoking check sensor policy-controlled features with ProximitySensor . If allowed is false, then: Throw a SecurityError DOMException . Let proximity_sensor be the new ProximitySensor object. Invoke initialize a sensor object with proximity_sensor and options . Return proximity_sensor . 8. Automation This section extends Generic Sensor API § 9 Automation by providing Proximity Sensor -specific virtual sensor metadata. The per-type virtual sensor metadata map must have the following entry : key " proximity " value A virtual sensor metadata whose reading parsing algorithm is the proximity reading parsing algorithm . 8.1. Proximity reading parsing algorithm input parameters , a JSON Object output A sensor reading or undefined Let reading be a new sensor reading . Let keys be the list « " distance ", " max " ». For each key of keys Let value be the result of invoking parse single-value number reading with parameters and key . If value is undefined . Return undefined . Set reading [ key ] to value [ key ]. Let near be the result of invoking get a property from parameters with " near ". If near ’s type is not Boolean Return undefined . Set reading [" near "] to near . Return reading . 9. Limitations of Proximity Sensors Since most proximity sensors detect electromagnetic radiation (e.g., an infrared light or a magnetic field), certain material properties can interfere with the sensor’s ability to sense the presence of a physical object. Things that can interfere with a sensor include, but are not limited to, the material’s translucency, reflectiveness, color, temperature, chemical composition, and even the angle at which the physical object is reflecting the radiation back at the sensor. As such, proximity sensors should not be relied on as a means to measure distance. The only thing that can be deduced from a proximity sensor is that a physical object is somewhere in the distance between the minimum sensing distance and the maximum sensing distance with some degree of certainty. 10. Acknowledgements Tobie Langel for the work on Generic Sensor API and inputs on this specification. Doug Turner for the initial prototype and Marcos Caceres for the test suite. 11. 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 conformant user agent 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] Index Terms defined by this specification conformant user agent , in § 11 Construct a proximity sensor object , in § 7 constructor() , in § 6.1 constructor(sensorOptions) , in § 6.1 distance attribute for ProximitySensor , in § 6.1 definition of , in § 5 max attribute for ProximitySensor , in § 6.1 definition of , in § 5 near attribute for ProximitySensor , in § 6.1 definition of , in § 5 proximity , in § 5 Proximity reading parsing algorithm , in § 8 Proximity Sensor , in § 5 ProximitySensor , in § 6.1 ProximitySensor() , in § 6.1 proximity-sensor-feature , in § 4 ProximitySensor(sensorOptions) , in § 6.1 proximity virtual sensor type , in § 5 sensing range , in § 5 Terms defined by reference [ECMASCRIPT] defines the following terms: Object [GENERIC-SENSOR] defines the following terms: Sensor SensorOptions check sensor policy-controlled features default sensor extension sensor interface fingerprinting Generic Sensor permission revocation algorithm get value from latest reading initialize a sensor object latest reading mitigation strategies parse single-value number reading per-type virtual sensor metadata reading parsing algorithm sensor feature names sensor permission names sensor reading sensor type user identifying virtual sensor metadata virtual sensor type [INFRA] defines the following terms: entry for each key keys list map set value values [PERMISSIONS] defines the following terms: permission revocation algorithm [PERMISSIONS-POLICY-1] defines the following terms: default allowlist policy-controlled feature [WEBDRIVER2] defines the following terms: get a property [WEBIDL] defines the following terms: DOMException Exposed SecureContext SecurityError boolean double throw References Normative References [ECMASCRIPT] ECMAScript Language Specification . URL: https://tc39.es/ecma262/multipage/ [GENERIC-SENSOR] Rick Waldron. Generic Sensor API . URL: https://w3c.github.io/sensors/ [INFRA] Anne van Kesteren; Domenic Denicola. Infra Standard . Living Standard. URL: https://infra.spec.whatwg.org/ [PERMISSIONS] Marcos Caceres; Mike Taylor. Permissions . URL: https://w3c.github.io/permissions/ [PERMISSIONS-POLICY-1] Ian Clelland. Permissions Policy . URL: https://w3c.github.io/webappsec-permissions-policy/ [RFC2119] S. Bradner. Key words for use in RFCs to Indicate Requirement Levels . March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119 [WEBDRIVER2] Simon Stewart; David Burns. WebDriver . URL: https://w3c.github.io/webdriver/ [WEBIDL] Edgar Chen; Timothy Gu. Web IDL Standard . Living Standard. URL: https://webidl.spec.whatwg.org/ IDL Index [ SecureContext , Exposed = Window ] interface ProximitySensor : Sensor { constructor ( optional SensorOptions sensorOptions = {}); readonly attribute double ? distance ; readonly attribute double ? max ; readonly attribute boolean ? near ; };

Related documents

Record · ID 182918 · SHA-256 f35218bfff0735d6
Conceptio Open Knowledge Archive — every document is proof-bundled with source, license, and retrieval metadata.