From 33097dd0dd3c7c967a77f2d29be524af7a2894cc Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Sat, 28 Apr 2018 13:41:15 +0800 Subject: [PATCH 01/14] Introduce WebDriver extension API Fixed #363 This spec defines extension commands to the WebDriver spec for controlling mock sensor on the host that the user agent is running on for testing purposes. With these extension commands devices with particular properties can be created and their responses to requests are well defined. --- webdriver-extension/index.bs | 532 ++++++ webdriver-extension/index.html | 2872 ++++++++++++++++++++++++++++++++ 2 files changed, 3404 insertions(+) create mode 100644 webdriver-extension/index.bs create mode 100644 webdriver-extension/index.html diff --git a/webdriver-extension/index.bs b/webdriver-extension/index.bs new file mode 100644 index 0000000..948450d --- /dev/null +++ b/webdriver-extension/index.bs @@ -0,0 +1,532 @@ +
+Title: WebDriver Extension API for Generic Sensor
+Shortname: webdriver-extension
+Level: none
+Status: ED
+Group: dap
+ED: https://w3c.github.io/sensors/webdriver-extension
+Editor: Wanming Lin 91067, Intel Corporation, https://intel.com/
+Abstract: This document defines extension commands to the [[WebDriver]] specification for the purposes of testing a user agent’s implementation of Generic Sensor API [[GENERIC-SENSOR]] and its concrete Sensor APIs.
+Version History: https://github.com/w3c/sensors/commits/gh-pages/index.bs
+!Bug Reports: via the w3c/sensors repository on GitHub
+Indent: 2
+Repository: w3c/sensors
+Markup Shorthands: markdown on
+Inline Github Issues: true
+Boilerplate: omit issues-index, omit conformance
+
+ +
+urlPrefix: https://w3c.github.io/webdriver/webdriver-spec.html#; spec: WebDriver
+  type: dfn
+    text: current browsing context; url: dfn-current-browsing-context
+    text: WebDriver error; url: dfn-errors
+    text: WebDriver error code; url: dfn-error-code
+    text: extension commands; url: dfn-extension-command
+    text: remote end steps; url: dfn-remote-end-steps
+    text: extension command URI template; url: dfn-extension-command-uri-template
+    text: invalid argument; url: dfn-invalid-argument
+    text: local end; url: dfn-local-end
+    text: url variable; url: dfn-url-variables
+    text: session; url: dfn-session
+    text: success; url: dfn-success
+    text: handling errors
+    text: Object; url: dfn-object
+urlPrefix: https://w3c.github.io/sensors/; spec: GENERIC-SENSOR
+  type: dfn
+    text: platform sensor; url: concept-platform-sensor
+    text: sensor
+    text: sensor reading
+    text: sensor type
+    text: reading timestamp
+    text: latest reading
+    text: connect to sensor
+    text: sampling frequency
+    text: requested sampling frequency
+    text: can expose sensor readings
+    text: update latest reading
+urlPrefix: https://w3c.github.io/ambient-light; spec: AMBIENT-LIGHT
+  type: dfn
+    text: AmbientLightSensor; url: ambient-light-sensor-interface
+urlPrefix: https://w3c.github.io/accelerometer; spec: ACCELEROMETER
+  type: dfn
+    text: Accelerometer; url: accelerometer-interface
+    text: LinearAccelerationSensor; url: linearaccelerationsensor-interface
+    text: GravitySensor; url: gravitysensor-interface
+urlPrefix: https://w3c.github.io/gyroscope; spec: GYROSCOPE
+  type: dfn
+    text: Gyroscope; url: gyroscope-interface
+urlPrefix: https://w3c.github.io/magnetometer; spec: MAGNETOMETER
+  type: dfn
+    text: Magnetometer; url: magnetometer-interface
+    text: UncalibratedMagnetometer; url: uncalibrated-magnetometer-interface
+urlPrefix: https://w3c.github.io/orientation-sensor; spec: ORIENTATION-SENSOR
+  type: dfn
+    text: AbsoluteOrientationSensor; url: absoluteorientationsensor-interface
+    text: RelativeOrientationSensor; url: relativeorientationsensor-interface
+urlPrefix: https://wicg.github.io/geolocation-sensor/; spec: GEOLOCATION-SENSOR
+  type: dfn
+    text: GeolocationSensor; url: geolocationsensor-interface
+urlPrefix: https://w3c.github.io/proximity; spec: PROXIMITY
+  type: dfn
+    text: ProximitySensor; url: proximity-sensor-interface
+
+ +Introduction {#intro} +===================== + +Generic Sensor API [[GENERIC-SENSOR]] and its concrete Sensor APIs pose a challenge +to test authors because to fully exercise their interfaces requires physical hardware +devices that respond in predictable ways. To address this challenge this specification +defines extension commands to the [[WebDriver]] specification for controlling +[=mock sensor=] on the host that the user agent is running on. +With these extension commands devices with particular properties can be created +and their responses to requests are well defined. + +Mock Sensors {#mock-sensors} +===================== + +A mock sensor simulates the behavior of a platform sensor in controlled ways. + +A [=mock sensor=] reports corresponding mock sensor reading, which is a source of +mocking information about the environment, to the Sensor objects. + +Note: It's up to the user agent to expose what kinds of mock sensor reading to the Sensor objects. + +A [=mock sensor=] has an associated latest reading [=ordered map|map=], which holds the latest available [=mock sensor readings=]. + +A [=mock sensor=] has an associated requested sampling frequency which is initial set to null. + +A [=mock sensor=] has an associated sampling frequency with supported bounds, the default values of +supported bounds are freely defined by user agent. + +
+Note: The [=mock sensor=] defined in this specification is not intended be used by non-testing-related web content. +The UA MAY choose to expose [=mock sensor=] interface only when a runtime or compile-time flag has been set. +
+ +## MockSensorConfiguration dictionary ## {#dictionary-mocksensorconfiguration} + +
+  dictionary MockSensorConfiguration {
+    required MockSensorType mockSensorType;
+    boolean sensorShouldConnected = true;
+    double? maxSamplingFrequency;
+    double? minSamplingFrequency;
+  };
+
+ +The {{MockSensorConfiguration}} dictionary is used to [[#create-mock-sensor-command|create mock sensor]]. + +: {{MockSensorConfiguration/mockSensorType}} member +:: A {{MockSensorType}} that is used to set mock sensor type. + +: {{MockSensorConfiguration/sensorShouldConnected}} member +:: A boolean. When set to false the user agent should intecept the result of invoking connect to sensor + with associated Sensor instance as argument to false, otherwise true. + +: {{MockSensorConfiguration/maxSamplingFrequency}} member +:: A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated [=mock sensor=]. + +: {{MockSensorConfiguration/minSamplingFrequency}} member +:: A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated [=mock sensor=]. + +## MockSensor dictionary ## {#dictionary-mocksensor} +
+  dictionary MockSensor {
+    double maxSamplingFrequency;
+    double minSamplingFrequency;
+    double requestedSamplingFrequency;
+  };
+
+The {{MockSensor}} dictionary provides information of a mock sensor. + +: {{MockSensor/maxSamplingFrequency}} member +:: A double representing frequency in Hz that indicates the maximum supported sampling frequency of the associated [=mock sensor=]. + +: {{MockSensor/minSamplingFrequency}} member +:: A double representing frequency in Hz that indicates the minimum supported sampling frequency of the associated [=mock sensor=]. + +: {{MockSensor/requestedSamplingFrequency}} member +:: A double representing frequency in Hz that indicates the requested sampling frequency of the associated [=mock sensor=]. + +A serialized mock sensor is a JSON Object where a [=mock sensor=]'s fields listed in the {{MockSensor}} dictionary are mapped +using the |JSON Key| and the associated field’s value from the available [=mock sensor=] in current browsing context. + +## Mock sensor type ## {#section-mock-sensor-type} + +A mock sensor type is equivalent to a sensor type’s associated {{Sensor}} subclass. + +
+  enum MockSensorType {
+    "ambient-light",
+    "accelerometer",
+    "linear-acceleration",
+    "gravity",
+    "gyroscope",
+    "magnetometer",
+    "uncalibrated-magnetometer",
+    "absolute-orientation",
+    "relative-orientation",
+    "geolocation",
+    "proximity",
+  };
+
+ +Each enumeration value in the {{MockSensorType}} enum identifies a mock sensor type. +Each mock sensor type has the following mock sensor reading set: + +: A Mock Sensor Reading Set +:: {{MockSensorReadingSet}} dictionary represents a set of user specific mock sensor reading used for + [[#update-mock-sensor-reading-command|updating mock sensor reading]]. It must contains all members of a + mock sensor type's mock sensor reading but exclude the reading timestamp. Each [=mock sensor type=] + has a specific {{MockSensorReadingSet}}, which is defined in each section of [[#section-mock-sensor-type|mock senor type]]. +
+     dictionary MockSensorReadingSet {
+     };
+   
+ +### Ambient Light Sensor ### {#mock-ambient-light-sensor} +The "ambient-light" type is the mock sensor type +associated with the usage of the AmbientLightSensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary AmbientLightReadingSet {
+        required double? illuminance;
+      };
+    
+
+
+ +### Accelerometer ### {#mock-accelerometer} +The "accelerometer" type is the mock sensor type +associated with the usage of the Accelerometer interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary AccelerometerReadingSet {
+        required double? x;
+        required double? y;
+        required double? z;
+      };
+    
+
+
+ +### Linear Acceleration Sensor### {#mock-linear-acceleration-sensor} +The "linear-acceleration" type is the mock sensor type +associated with the usage of the LinearAccelerationSensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary LinearAccelerationReadingSet : AccelerometerReadingSet {
+      };
+    
+
+
+ +### Gravity Sensor### {#mock-gravity} +The "gravity" type is the mock sensor type +associated with the usage of the GravitySensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary GravityReadingSet : AccelerometerReadingSet {
+      };
+    
+
+
+ +### Gyroscope ### {#mock-gyroscope} +The "gyroscope" type is the mock sensor type +associated with the usage of the Gyroscope interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary GyroscopeReadingSet {
+        required double? x;
+        required double? y;
+        required double? z;
+      };
+    
+
+
+ +### Magnetometer ### {#mock-magnetometer} +The "magnetometer" type is the mock sensor type +associated with the usage of the Magnetometer interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary MagnetometerReadingSet {
+        required double? x;
+        required double? y;
+        required double? z;
+      };
+    
+
+
+ +### Uncalibrated Magnetometer ### {#mock-uncalibrated-magnetometer} +The "uncalibrated-magnetometer" type is the mock sensor type +associated with the usage of the UncalibratedMagnetometer interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary UncalibratedMagnetometerReadingSet {
+        required double? x;
+        required double? y;
+        required double? z;
+        required double? xBias;
+        required double? yBias;
+        required double? zBias;
+      };
+    
+
+
+ +### Absolute Orientation Sensor ### {#mock-absolute-orientation-sensor} +The "absolute-orientation" type is the mock sensor type +associated with the usage of the AbsoluteOrientationSensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary AbsoluteOrientationReadingSet {
+        required FrozenArray<double>? quaternion;
+      };
+    
+
+
+ +### Relative Orientation Sensor ### {#mock-relative-orientation-sensor} +The "relative-orientation" type is the mock sensor type +associated with the usage of the RelativeOrientationSensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary RelativeOrientationReadingSet : AbsoluteOrientationReadingSet {
+      };
+    
+
+
+ +### Geolocation Sensor ### {#mock-geolocation-sensor} +The "geolocation" type is the mock sensor type +associated with the usage of the GeolocationSensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary GeolocationReadingSet {
+        required double? latitude;
+        required double? longitude;
+        required double? altitude;
+        required double? accuracy;
+        required double? altitudeAccuracy;
+        required double? heading;
+        required double? speed;
+      };
+    
+
+
+ +### Proximity Sensor ### {#mock-proximity-sensor} +The "proximity" type is the mock sensor type +associated with the usage of the ProximitySensor interface. +
+
Mock Sensor Reading Set
+
+
+      dictionary ProximityReadingSet {
+        required double? distance;
+        required double? max;
+        required boolean? near;
+      };
+    
+
+
+ +Extensions {#webdriver-extensions} +===================== + +## Commands ## {#mock-sensor-commands} + +### Create mock sensor ### {#create-mock-sensor-command} + + + + + + + + + + + + +
HTTP MethodURI Template
POST/session/{session id}/sensor
+ +The Create mock sensor extension command simulates user +creation of a mock sensor. + +The remote end steps are: +1. Let |configuration| be the |configuration| argument, converted to an IDL value + of type {{MockSensorConfiguration}}. If this throws an exception, return a + WebDriver error with WebDriver error code invalid argument. +2. Let |type| be the |configuration|.{{MockSensorConfiguration/mockSensorType}}, if current browsing context + already exists this |type| of [=mock sensor=], return a WebDriver error with WebDriver error code + [=mock sensor already created=]. +3. Run these sub-steps [=in parallel=] to create a [=mock sensor=] in current browsing context: + 1. Set the [=mock sensor type|mock sensor's type=] to |type|. + 2. Let |connected| be the |configuration|.{{MockSensorConfiguration/sensorShouldConnected}}, + force the result of invoking connect to sensor with associated Sensor instance as argument to |connected|. + 3. If |configuration|.{{MockSensorConfiguration/maxSamplingFrequency}} is [=present=], then + 1. Set the [=mock sensor=]'s associated maximum supported sampling frequency to |configuration|.{{MockSensorConfiguration/maxSamplingFrequency}}. + 4. If |configuration|.{{MockSensorConfiguration/minSamplingFrequency}} is [=present=], then + 1. Set the [=mock sensor=]'s minimum supported sampling frequency to |configuration|.{{MockSensorConfiguration/minSamplingFrequency}}. +4. Return success with data `null`. + +
+ To create an "ambient-light" mock sensor of current browsing context of the session with ID 23, + the local end would POST to `/session/23/sensor/` with the body: +
+  {
+    "mockSensorType": "ambient-light",
+    "maxSamplingFrequency": 60,
+    "minSamplingFrequency": 5
+  }
+  
+
+ +### Get mock sensor ### {#get-mock-sensor-command} + + + + + + + + + + + + +
HTTP MethodURI Template
GET/session/{session id}/sensor/{type}
+ +The Get mock sensor extension command simulates user +getting information of a given type of mock sensor. + +The remote end steps are: +1. Let |type| be a url variable. +2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with + WebDriver error code invalid argument. +3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the + current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=]. +4. Return success with the serialized mock sensor as data. + +### Update mock sensor reading ### {#update-mock-sensor-reading-command} + + + + + + + + + + + + +
HTTP MethodURI Template
POST/session/{session id}/sensor/{type}
+ +The Update mock sensor reading extension command simulates user +updating of a given type of mock sensor's [=mock sensor reading|reading=]. + +The remote end steps are: +1. Let |type| be a url variable. +2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with + WebDriver error code invalid argument. +3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the + current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=]. +4. Let |readingSet| be the |readingSet| argument, converted to an IDL value of the |type|'s + associated {{MockSensorReadingSet}}. If this throws an exception, return a + WebDriver error with WebDriver error code invalid argument. +5. If the user agent can expose sensor readings to the current browsing context's active document, then + 1. Simulate invoking update latest reading with the |type| of [=mock sensor=] and the |readingSet| as arguments. + 2. Return success with data `null`. +6. Otherwise, return a WebDriver error with WebDriver error code [=unable to update mock sensor reading=]. + +### Delete mock sensor ### {#delete-mock-sensor-command} + + + + + + + + + + + + +
HTTP MethodURI Template
DELETE/session/{session id}/sensor/{type}
+ +The Delete mock sensor extension command simulates user +deletion of a given type of mock sensor. + +The remote end steps are: +1. Let |type| be a url variable. +2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with + WebDriver error code invalid argument. +3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the + current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=]. +4. Delete |type| of [=mock sensor=] in current browsing context. +5. Return success with data `null`. + +## Handling errors ## {#extension-handling-errors} + +This section extends the Handling Errors and defines extended WebDriver error codes +specific for [=mock sensor=] in following table. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Error CodeHTTP StatusJSON Error CodeDescription
no such mock sensor404|no such mock sensor|no mock sensor matching the given type was found.
mock sensor already created500|mock sensor already created| + A [[#mock-sensor-commands|command]] to create a mock sensor could not be satisfied because the given type of mock sensor is already existed. +
unable to update mock sensor reading500|unable to update mock sensor reading| + A [[#mock-sensor-commands|command]] to update mock sensor reading could not be satisfied. +
+ diff --git a/webdriver-extension/index.html b/webdriver-extension/index.html new file mode 100644 index 0000000..c6818ff --- /dev/null +++ b/webdriver-extension/index.html @@ -0,0 +1,2872 @@ + + + + + WebDriver Extension API for Generic Sensor + + + + + + + + + + + + + +
+

+

WebDriver Extension API for Generic Sensor

+

Editor’s Draft,

+
+
+
This version: +
https://w3c.github.io/sensors/webdriver-extension +
Version History: +
https://github.com/w3c/sensors/commits/gh-pages/index.bs +
Feedback: +
public-device-apis@w3.org with subject line “[webdriver-extension] … message topic …” (archives) +
Issue Tracking: +
GitHub +
Editor: +
Wanming Lin (Intel Corporation) +
Bug Reports: +
via the w3c/sensors repository on GitHub +
+
+
+ +
+
+
+

Abstract

+

This document defines extension commands to the [WebDriver] specification for the purposes of testing a user agent’s implementation of Generic Sensor API [GENERIC-SENSOR] and its concrete Sensor APIs.

+
+

Status of this document

+
+

This is a public copy of the editors’ draft. + It is provided for discussion only and may change at any moment. + Its publication here does not imply endorsement of its contents by W3C. + Don’t cite this document other than as work in progress.

+

If you wish to make comments regarding this document, please send them to public-device-apis@w3.org (subscribe, archives). + When sending e-mail, + please put the text “webdriver-extension” in the subject, + preferably like this: + “[webdriver-extension] …summary of comment…”. + All comments are welcome.

+

This document was produced by the Device and Sensors Working Group.

+

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 which 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 1 February 2018 W3C Process Document.

+

+
+
+ +
+

1. Introduction

+

Generic Sensor API [GENERIC-SENSOR] and its concrete Sensor APIs pose a challenge +to test authors because to fully exercise their interfaces requires physical hardware +devices that respond in predictable ways. To address this challenge this specification +defines extension commands to the [WebDriver] specification for controlling mock sensor on the host that the user agent is running on. +With these extension commands devices with particular properties can be created +and their responses to requests are well defined.

+

2. Mock Sensors

+

A mock sensor simulates the behavior of a platform sensor in controlled ways.

+

A mock sensor reports corresponding mock sensor reading, which is a source of +mocking information about the environment, to the Sensor objects.

+

Note: It’s up to the user agent to expose what kinds of mock sensor reading to the Sensor objects.

+

A mock sensor has an associated latest reading map, which holds the latest available mock sensor readings.

+

A mock sensor has an associated requested sampling frequency which is initial set to null.

+

A mock sensor has an associated sampling frequency with supported bounds, the default values of +supported bounds are freely defined by user agent.

+
Note: The mock sensor defined in this specification is not intended be used by non-testing-related web content. +The UA MAY choose to expose mock sensor interface only when a runtime or compile-time flag has been set.
+

2.1. MockSensorConfiguration dictionary

+
dictionary MockSensorConfiguration {
+  required MockSensorType mockSensorType;
+  boolean sensorShouldConnected = true;
+  double? maxSamplingFrequency;
+  double? minSamplingFrequency;
+};
+
+

The MockSensorConfiguration dictionary is used to create mock sensor.

+
+
mockSensorType member +
+

A MockSensorType that is used to set mock sensor type.

+
sensorShouldConnected member +
+

A boolean. When set to false the user agent should intecept the result of invoking connect to sensor with associated Sensor instance as argument to false, otherwise true.

+
maxSamplingFrequency member +
+

A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated mock sensor.

+
minSamplingFrequency member +
+

A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated mock sensor.

+
+

2.2. MockSensor dictionary

+
dictionary MockSensor {
+  double maxSamplingFrequency;
+  double minSamplingFrequency;
+  double requestedSamplingFrequency;
+};
+
+

The MockSensor dictionary provides information of a mock sensor.

+
+
maxSamplingFrequency member +
+

A double representing frequency in Hz that indicates the maximum supported sampling frequency of the associated mock sensor.

+
minSamplingFrequency member +
+

A double representing frequency in Hz that indicates the minimum supported sampling frequency of the associated mock sensor.

+
requestedSamplingFrequency member +
+

A double representing frequency in Hz that indicates the requested sampling frequency of the associated mock sensor.

+
+

A serialized mock sensor is a JSON Object where a mock sensor's fields listed in the MockSensor dictionary are mapped +using the JSON Key and the associated field’s value from the available mock sensor in current browsing context.

+

2.3. Mock sensor type

+

A mock sensor type is equivalent to a sensor type’s associated Sensor subclass.

+
enum MockSensorType {
+  "ambient-light",
+  "accelerometer",
+  "linear-acceleration",
+  "gravity",
+  "gyroscope",
+  "magnetometer",
+  "uncalibrated-magnetometer",
+  "absolute-orientation",
+  "relative-orientation",
+  "geolocation",
+  "proximity",
+};
+
+

Each enumeration value in the MockSensorType enum identifies a mock sensor type. +Each mock sensor type has the following mock sensor reading set:

+
+
A Mock Sensor Reading Set +
+

MockSensorReadingSet dictionary represents a set of user specific mock sensor reading used for updating mock sensor reading. It must contains all members of a mock sensor type’s mock sensor reading but exclude the reading timestamp. Each mock sensor type has a specific MockSensorReadingSet, which is defined in each section of mock senor type.

+
dictionary MockSensorReadingSet {
+};
+
+
+

2.3.1. Ambient Light Sensor

+ The "ambient-light" type is the mock sensor type +associated with the usage of the AmbientLightSensor interface. +
+
Mock Sensor Reading Set +
+
dictionary AmbientLightReadingSet {
+  required double? illuminance;
+};
+
+
+

2.3.2. Accelerometer

+ The "accelerometer" type is the mock sensor type +associated with the usage of the Accelerometer interface. +
+
Mock Sensor Reading Set +
+
dictionary AccelerometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+
+

2.3.3. Linear Acceleration Sensor

+ The "linear-acceleration" type is the mock sensor type +associated with the usage of the LinearAccelerationSensor interface. +
+
Mock Sensor Reading Set +
+
dictionary LinearAccelerationReadingSet : AccelerometerReadingSet {
+};
+
+
+

2.3.4. Gravity Sensor

+ The "gravity" type is the mock sensor type +associated with the usage of the GravitySensor interface. +
+
Mock Sensor Reading Set +
+
dictionary GravityReadingSet : AccelerometerReadingSet {
+};
+
+
+

2.3.5. Gyroscope

+ The "gyroscope" type is the mock sensor type +associated with the usage of the Gyroscope interface. +
+
Mock Sensor Reading Set +
+
dictionary GyroscopeReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+
+

2.3.6. Magnetometer

+ The "magnetometer" type is the mock sensor type +associated with the usage of the Magnetometer interface. +
+
Mock Sensor Reading Set +
+
dictionary MagnetometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+
+

2.3.7. Uncalibrated Magnetometer

+ The "uncalibrated-magnetometer" type is the mock sensor type +associated with the usage of the UncalibratedMagnetometer interface. +
+
Mock Sensor Reading Set +
+
dictionary UncalibratedMagnetometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+  required double? xBias;
+  required double? yBias;
+  required double? zBias;
+};
+
+
+

2.3.8. Absolute Orientation Sensor

+ The "absolute-orientation" type is the mock sensor type +associated with the usage of the AbsoluteOrientationSensor interface. +
+
Mock Sensor Reading Set +
+
dictionary AbsoluteOrientationReadingSet {
+  required FrozenArray<double>? quaternion;
+};
+
+
+

2.3.9. Relative Orientation Sensor

+ The "relative-orientation" type is the mock sensor type +associated with the usage of the RelativeOrientationSensor interface. +
+
Mock Sensor Reading Set +
+
dictionary RelativeOrientationReadingSet : AbsoluteOrientationReadingSet {
+};
+
+
+

2.3.10. Geolocation Sensor

+ The "geolocation" type is the mock sensor type +associated with the usage of the GeolocationSensor interface. +
+
Mock Sensor Reading Set +
+
dictionary GeolocationReadingSet {
+  required double? latitude;
+  required double? longitude;
+  required double? altitude;
+  required double? accuracy;
+  required double? altitudeAccuracy;
+  required double? heading;
+  required double? speed;
+};
+
+
+

2.3.11. Proximity Sensor

+ The "proximity" type is the mock sensor type +associated with the usage of the ProximitySensor interface. +
+
Mock Sensor Reading Set +
+
dictionary ProximityReadingSet {
+  required double? distance;
+  required double? max;
+  required boolean? near;
+};
+
+
+

3. Extensions

+

3.1. Commands

+

3.1.1. Create mock sensor

+ + + + +
HTTP Method + URI Template +
POST + /session/{session id}/sensor +
+

The Create mock sensor extension command simulates user +creation of a mock sensor.

+

The remote end steps are:

+
    +
  1. +

    Let configuration be the configuration argument, converted to an IDL value of type MockSensorConfiguration. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    +
  2. +

    Let type be the configuration.mockSensorType, if current browsing context already exists this type of mock sensor, return a WebDriver error with WebDriver error code mock sensor already created.

    +
  3. +

    Run these sub-steps in parallel to create a mock sensor in current browsing context:

    +
      +
    1. +

      Set the mock sensor’s type to type.

      +
    2. +

      Let connected be the configuration.sensorShouldConnected, + force the result of invoking connect to sensor with associated Sensor instance as argument to connected.

      +
    3. +

      If configuration.maxSamplingFrequency is present, then

      +
        +
      1. +

        Set the mock sensor's associated maximum supported sampling frequency to configuration.maxSamplingFrequency.

        +
      +
    4. +

      If configuration.minSamplingFrequency is present, then

      +
        +
      1. +

        Set the mock sensor's minimum supported sampling frequency to configuration.minSamplingFrequency.

        +
      +
    +
  4. +

    Return success with data null.

    +
+
+ To create an "ambient-light" mock sensor of current browsing context of the session with ID 23, + the local end would POST to /session/23/sensor/ with the body: +
{
+  "mockSensorType": "ambient-light",
+  "maxSamplingFrequency": 60,
+  "minSamplingFrequency": 5
+}
+
+
+

3.1.2. Get mock sensor

+ + + + +
HTTP Method + URI Template +
GET + /session/{session id}/sensor/{type} +
+

The Get mock sensor extension command simulates user +getting information of a given type of mock sensor.

+

The remote end steps are:

+
    +
  1. +

    Let type be a url variable.

    +
  2. +

    If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

    +
  3. +

    If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    +
  4. +

    Return success with the serialized mock sensor as data.

    +
+

3.1.3. Update mock sensor reading

+ + + + +
HTTP Method + URI Template +
POST + /session/{session id}/sensor/{type} +
+

The Update mock sensor reading extension command simulates user +updating of a given type of mock sensor’s reading.

+

The remote end steps are:

+
    +
  1. +

    Let type be a url variable.

    +
  2. +

    If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

    +
  3. +

    If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    +
  4. +

    Let readingSet be the readingSet argument, converted to an IDL value of the type’s + associated MockSensorReadingSet. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    +
  5. +

    If the user agent can expose sensor readings to the current browsing context’s active document, then

    +
      +
    1. +

      Simulate invoking update latest reading with the type of mock sensor and the readingSet as arguments.

      +
    2. +

      Return success with data null.

      +
    +
  6. +

    Otherwise, return a WebDriver error with WebDriver error code unable to update mock sensor reading.

    +
+

3.1.4. Delete mock sensor

+ + + + +
HTTP Method + URI Template +
DELETE + /session/{session id}/sensor/{type} +
+

The Delete mock sensor extension command simulates user +deletion of a given type of mock sensor.

+

The remote end steps are:

+
    +
  1. +

    Let type be a url variable.

    +
  2. +

    If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

    +
  3. +

    If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    +
  4. +

    Delete type of mock sensor in current browsing context.

    +
  5. +

    Return success with data null.

    +
+

3.2. Handling errors

+

This section extends the Handling Errors and defines extended WebDriver error codes specific for mock sensor in following table.

+ + + + + + + +
Error Code + HTTP Status + JSON Error Code + Description +
no such mock sensor + 404 + no such mock sensor + no mock sensor matching the given type was found. +
mock sensor already created + 500 + mock sensor already created + command to create a mock sensor could not be satisfied because the given type of mock sensor is already existed. +
unable to update mock sensor reading + 500 + unable to update mock sensor reading + command to update mock sensor reading could not be satisfied. +
+
+ +

Index

+

Terms defined by this specification

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Terms defined by reference

+ +

References

+

Normative References

+
+
[ACCELEROMETER] +
Anssi Kostiainen; Alexander Shalamov. Accelerometer. 20 March 2018. CR. URL: https://www.w3.org/TR/accelerometer/ +
[AMBIENT-LIGHT] +
Anssi Kostiainen. Ambient Light Sensor. 20 March 2018. CR. URL: https://www.w3.org/TR/ambient-light/ +
[GENERIC-SENSOR] +
Rick Waldron; Mikhail Pozdnyakov; Alexander Shalamov. Generic Sensor API. 20 March 2018. CR. URL: https://www.w3.org/TR/generic-sensor/ +
[GEOLOCATION-SENSOR] +
Geolocation Sensor. Living Standard. URL: https://wicg.github.io/geolocation-sensor/ +
[GYROSCOPE] +
Anssi Kostiainen; Mikhail Pozdnyakov. Gyroscope. 20 March 2018. CR. URL: https://www.w3.org/TR/gyroscope/ +
[HTML] +
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/ +
[INFRA] +
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/ +
[MAGNETOMETER] +
Anssi Kostiainen; Rijubrata Bhaumik. Magnetometer. 20 March 2018. CR. URL: https://www.w3.org/TR/magnetometer/ +
[ORIENTATION-SENSOR] +
Mikhail Pozdnyakov; et al. Orientation Sensor. 20 March 2018. CR. URL: https://www.w3.org/TR/orientation-sensor/ +
[PROXIMITY] +
Anssi Kostiainen; Rijubrata Bhaumik. Proximity Sensor. 19 July 2016. WD. URL: https://www.w3.org/TR/proximity/ +
[WebDriver] +
Simon Stewart; David Burns. WebDriver. 26 April 2018. PR. URL: https://www.w3.org/TR/webdriver1/ +
[WebIDL] +
Cameron McCormack; Boris Zbarsky; Tobie Langel. Web IDL. 15 December 2016. ED. URL: https://heycam.github.io/webidl/ +
+

IDL Index

+
dictionary MockSensorConfiguration {
+  required MockSensorType mockSensorType;
+  boolean sensorShouldConnected = true;
+  double? maxSamplingFrequency;
+  double? minSamplingFrequency;
+};
+
+dictionary MockSensor {
+  double maxSamplingFrequency;
+  double minSamplingFrequency;
+  double requestedSamplingFrequency;
+};
+
+enum MockSensorType {
+  "ambient-light",
+  "accelerometer",
+  "linear-acceleration",
+  "gravity",
+  "gyroscope",
+  "magnetometer",
+  "uncalibrated-magnetometer",
+  "absolute-orientation",
+  "relative-orientation",
+  "geolocation",
+  "proximity",
+};
+
+dictionary MockSensorReadingSet {
+};
+
+dictionary AmbientLightReadingSet {
+  required double? illuminance;
+};
+
+dictionary AccelerometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+dictionary LinearAccelerationReadingSet : AccelerometerReadingSet {
+};
+
+dictionary GravityReadingSet : AccelerometerReadingSet {
+};
+
+dictionary GyroscopeReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+dictionary MagnetometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+};
+
+dictionary UncalibratedMagnetometerReadingSet {
+  required double? x;
+  required double? y;
+  required double? z;
+  required double? xBias;
+  required double? yBias;
+  required double? zBias;
+};
+
+dictionary AbsoluteOrientationReadingSet {
+  required FrozenArray<double>? quaternion;
+};
+
+dictionary RelativeOrientationReadingSet : AbsoluteOrientationReadingSet {
+};
+
+dictionary GeolocationReadingSet {
+  required double? latitude;
+  required double? longitude;
+  required double? altitude;
+  required double? accuracy;
+  required double? altitudeAccuracy;
+  required double? heading;
+  required double? speed;
+};
+
+dictionary ProximityReadingSet {
+  required double? distance;
+  required double? max;
+  required boolean? near;
+};
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b2d1bcac7f0e4ddc803d58c5e02e2d5a245329e2 Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Fri, 17 Aug 2018 15:31:24 +0800 Subject: [PATCH 02/14] A couple of optimizations - Fix some editorial issues - Use "connected" to replace "sensorShouldConnected" - Comment what would happen if create mock sensor twice - Improve identification of MockSensorType type --- webdriver-extension/index.bs | 51 ++++++------ webdriver-extension/index.html | 145 ++++++++++++++++----------------- 2 files changed, 99 insertions(+), 97 deletions(-) diff --git a/webdriver-extension/index.bs b/webdriver-extension/index.bs index 948450d..1a97363 100644 --- a/webdriver-extension/index.bs +++ b/webdriver-extension/index.bs @@ -6,7 +6,7 @@ Status: ED Group: dap ED: https://w3c.github.io/sensors/webdriver-extension Editor: Wanming Lin 91067, Intel Corporation, https://intel.com/ -Abstract: This document defines extension commands to the [[WebDriver]] specification for the purposes of testing a user agent’s implementation of Generic Sensor API [[GENERIC-SENSOR]] and its concrete Sensor APIs. +Abstract: This document defines extension commands to the [[WebDriver|WebDriver specification]] for the purposes of testing a user agent’s implementation of [[GENERIC-SENSOR|Generic Sensor API]] and its concrete Sensor APIs. Version History: https://github.com/w3c/sensors/commits/gh-pages/index.bs !Bug Reports: via the w3c/sensors repository on GitHub Indent: 2 @@ -110,7 +110,7 @@ The UA MAY choose to expose [=mock sensor=] interface only when a runtime or com
   dictionary MockSensorConfiguration {
     required MockSensorType mockSensorType;
-    boolean sensorShouldConnected = true;
+    boolean connected = true;
     double? maxSamplingFrequency;
     double? minSamplingFrequency;
   };
@@ -121,7 +121,7 @@ The {{MockSensorConfiguration}} dictionary is used to [[#create-mock-sensor-comm
 : {{MockSensorConfiguration/mockSensorType}} member
 :: A {{MockSensorType}} that is used to set mock sensor type.
 
-: {{MockSensorConfiguration/sensorShouldConnected}} member
+: {{MockSensorConfiguration/connected}} member
 :: A boolean. When set to false the user agent should intecept the result of invoking connect to sensor
    with associated Sensor instance as argument to false, otherwise true.
 
@@ -376,23 +376,23 @@ Extensions {#webdriver-extensions}
   
 
 
-The Create mock sensor extension command simulates user
+The create mock sensor extension command simulates user
 creation of a mock sensor.
 
 The remote end steps are:
 1. Let |configuration| be the |configuration| argument, converted to an IDL value
    of type {{MockSensorConfiguration}}. If this throws an exception, return a
    WebDriver error with WebDriver error code invalid argument.
-2. Let |type| be the |configuration|.{{MockSensorConfiguration/mockSensorType}}, if current browsing context
-   already exists this |type| of [=mock sensor=], return a WebDriver error with WebDriver error code
+2. Let |type| be the |configuration|.{{MockSensorConfiguration/mockSensorType}}, if the current browsing context
+   already has this |type| of [=mock sensor=], return a WebDriver error with WebDriver error code
    [=mock sensor already created=].
 3. Run these sub-steps [=in parallel=] to create a [=mock sensor=] in current browsing context:
   1. Set the [=mock sensor type|mock sensor's type=] to |type|.
-  2. Let |connected| be the |configuration|.{{MockSensorConfiguration/sensorShouldConnected}},
+  2. Let |connected| be the |configuration|.{{MockSensorConfiguration/connected}},
      force the result of invoking connect to sensor with associated Sensor instance as argument to |connected|.
-  3. If |configuration|.{{MockSensorConfiguration/maxSamplingFrequency}} is [=present=], then
+  3. If |configuration|.{{MockSensorConfiguration/maxSamplingFrequency}} is [=present=], then:
     1. Set the [=mock sensor=]'s associated maximum supported sampling frequency to |configuration|.{{MockSensorConfiguration/maxSamplingFrequency}}.
-  4. If |configuration|.{{MockSensorConfiguration/minSamplingFrequency}} is [=present=], then
+  4. If |configuration|.{{MockSensorConfiguration/minSamplingFrequency}} is [=present=], then:
     1. Set the [=mock sensor=]'s minimum supported sampling frequency to |configuration|.{{MockSensorConfiguration/minSamplingFrequency}}.
 4. Return success with data `null`.
 
@@ -406,6 +406,9 @@ The remote end steps are:
     "minSamplingFrequency": 5
   }
   
+ Be aware that only one mock sensor of a given mock sensor type can be created in current browsing context, + otherwise a WebDriver error with WebDriver error code [=mock sensor already created=] will be thrown. + ### Get mock sensor ### {#get-mock-sensor-command} @@ -423,16 +426,16 @@ The remote end steps are: -The Get mock sensor extension command simulates user +The get mock sensor extension command simulates user getting information of a given type of mock sensor. The remote end steps are: -1. Let |type| be a url variable. -2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with - WebDriver error code invalid argument. -3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the +1. Let |type| be a url variable, converted to an IDL value of type {{MockSensorType}}. + If this throws an exception, return a WebDriver error with WebDriver error code + invalid argument. +2. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=]. -4. Return success with the serialized mock sensor as data. +3. Return success with the serialized mock sensor as data. ### Update mock sensor reading ### {#update-mock-sensor-reading-command} @@ -449,22 +452,22 @@ The remote end steps are: -The Update mock sensor reading extension command simulates user +The update mock sensor reading extension command simulates user updating of a given type of mock sensor's [=mock sensor reading|reading=]. The remote end steps are: -1. Let |type| be a url variable. -2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with - WebDriver error code invalid argument. -3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the +1. Let |type| be a url variable, converted to an IDL value of type {{MockSensorType}}. + If this throws an exception, return a WebDriver error with WebDriver error code + invalid argument. +2. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=]. -4. Let |readingSet| be the |readingSet| argument, converted to an IDL value of the |type|'s +3. Let |readingSet| be the |readingSet| argument, converted to an IDL value of the |type|'s associated {{MockSensorReadingSet}}. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument. -5. If the user agent can expose sensor readings to the current browsing context's active document, then +4. If the user agent can expose sensor readings to the current browsing context's active document, then: 1. Simulate invoking update latest reading with the |type| of [=mock sensor=] and the |readingSet| as arguments. 2. Return success with data `null`. -6. Otherwise, return a WebDriver error with WebDriver error code [=unable to update mock sensor reading=]. +5. Otherwise, return a WebDriver error with WebDriver error code [=unable to update mock sensor reading=]. ### Delete mock sensor ### {#delete-mock-sensor-command} @@ -481,7 +484,7 @@ The remote end steps are: -The Delete mock sensor extension command simulates user +The delete mock sensor extension command simulates user deletion of a given type of mock sensor. The remote end steps are: diff --git a/webdriver-extension/index.html b/webdriver-extension/index.html index c6818ff..80e589b 100644 --- a/webdriver-extension/index.html +++ b/webdriver-extension/index.html @@ -1220,7 +1220,7 @@ - + - + - + - + - + - + - + - + -

WebDriver Extension API for Generic Sensor

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -1475,7 +1475,7 @@

https://github.com/w3c/sensors/commits/gh-pages/index.bs
Feedback: -
public-device-apis@w3.org with subject line “[webdriver-extension] … message topic …” (archives) +
public-device-apis@w3.org with subject line “[webdriver-extension] … message topic …” (archives)
Issue Tracking:
GitHub
Editor: @@ -1504,7 +1504,7 @@

…summary of comment…”. All comments are welcome.

-

This document was produced by the Device and Sensors Working Group.

+

This document was produced by the Devices and Sensors Working Group.

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; @@ -1568,234 +1568,234 @@

Table of Contents

1. Introduction

-

Generic Sensor API [GENERIC-SENSOR] and its concrete Sensor APIs pose a challenge -to test authors because to fully exercise their interfaces requires physical hardware +

The Generic Sensor API [GENERIC-SENSOR] and its concrete Sensor APIs pose a challenge +to test authors, as fully exercising those interfaces requires physical hardware devices that respond in predictable ways. To address this challenge this specification defines extension commands to the [WebDriver] specification for controlling mock sensor on the host that the user agent is running on. -With these extension commands devices with particular properties can be created +With these extension commands, devices with particular properties can be created and their responses to requests are well defined.

2. Mock Sensors

-

A mock sensor simulates the behavior of a platform sensor in controlled ways.

-

A mock sensor reports corresponding mock sensor reading, which is a source of +

A mock sensor simulates the behavior of a platform sensor in controlled ways.

+

A mock sensor reports a corresponding mock sensor reading, which is a source of mocking information about the environment, to the Sensor objects.

The current browsing context’s mock sensor has an associated mock sensor reading map.

The mock sensor reading map contains an entry whose key is "timestamp" and whose value is a high resolution timestamp that estimates the time mock sensor reading sent to observers of the Sensor object, expressed in milliseconds since the time origin.

The other entries of the mock sensor reading map whose keys must match the dictionary members identifier defined by the mock sensor type's MockSensorReadingValues and whose initial values are implementation-dependent.

Note: The user agent must provide the mock sensor reading that are initially exposed to the Sensor objects.

-

A mock sensor has an associated requested sampling frequency, it’s default value is implementation-dependent -but must be set within mock sensor's associated sampling frequency bounds.

-

A mock sensor has an associated sampling frequency with supported bounds, the default values of +

A mock sensor has an associated requested sampling frequency. Its default value is implementation-dependent +but must be set within a mock sensor's associated sampling frequency bounds.

+

A mock sensor has an associated sampling frequency with supported bounds. The default values of supported bounds are implementation-dependent.

A mock sensor must report the mock sensor reading at the rate of its requested sampling frequency if the user agent can expose sensor readings to the current browsing context’s active document.

Note: The mock sensor defined in this specification is not intended be used by non-testing-related web content. The UA MAY choose to expose mock sensor interface only when a runtime or compile-time flag has been set.

2.1. MockSensorConfiguration dictionary

-
dictionary MockSensorConfiguration {
-  required MockSensorType mockSensorType;
-  boolean connected = true;
-  double? maxSamplingFrequency;
-  double? minSamplingFrequency;
+
dictionary MockSensorConfiguration {
+  required MockSensorType mockSensorType;
+  boolean connected = true;
+  double? maxSamplingFrequency;
+  double? minSamplingFrequency;
 };
 
-

The MockSensorConfiguration dictionary is used to create mock sensor.

+

The MockSensorConfiguration dictionary is used to create a mock sensor.

-
mockSensorType member -
+
mockSensorType member +

A MockSensorType that is used to set mock sensor type.

-
connected member -
-

A boolean that indicates a mock sensor's connection flag which is used for switching the connection +

connected member +
+

A boolean that indicates a mock sensor's connection flag which is used for switching the connection between Sensor object and mock sensor. When set to false the user agent must force the result of invoking connect to sensor with mock sensor's associated Sensor object as argument to false, otherwise true.

-
maxSamplingFrequency member -
+
maxSamplingFrequency member +

A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated mock sensor.

-
minSamplingFrequency member -
+
minSamplingFrequency member +

A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated mock sensor.

2.2. MockSensor dictionary

-
dictionary MockSensor {
-  double maxSamplingFrequency;
-  double minSamplingFrequency;
-  double requestedSamplingFrequency;
+
dictionary MockSensor {
+  double maxSamplingFrequency;
+  double minSamplingFrequency;
+  double requestedSamplingFrequency;
 };
 
-

The MockSensor dictionary provides information of a mock sensor.

+

The MockSensor dictionary provides information about a mock sensor.

-
maxSamplingFrequency member -
+
maxSamplingFrequency member +

A double representing frequency in Hz that indicates the maximum supported sampling frequency of the associated mock sensor.

-
minSamplingFrequency member -
+
minSamplingFrequency member +

A double representing frequency in Hz that indicates the minimum supported sampling frequency of the associated mock sensor.

-
requestedSamplingFrequency member -
+
requestedSamplingFrequency member +

A double representing frequency in Hz that indicates the requested sampling frequency of the associated mock sensor.

-

A serialized mock sensor is a JSON Object where a mock sensor's fields listed in the MockSensor dictionary are mapped +

A serialized mock sensor is a JSON Object where a mock sensor's fields listed in the MockSensor dictionary are mapped using the JSON Key and the associated field’s value from the available mock sensor in current browsing context.

2.3. Mock sensor type

-

A mock sensor type is equivalent to a sensor type’s associated Sensor subclass.

-
enum MockSensorType {
-  "ambient-light",
-  "accelerometer",
-  "linear-acceleration",
-  "gravity",
-  "gyroscope",
-  "magnetometer",
-  "uncalibrated-magnetometer",
-  "absolute-orientation",
-  "relative-orientation",
-  "geolocation",
-  "proximity",
+   

A mock sensor type is equivalent to a sensor type’s associated Sensor subclass.

+
enum MockSensorType {
+  "ambient-light",
+  "accelerometer",
+  "linear-acceleration",
+  "gravity",
+  "gyroscope",
+  "magnetometer",
+  "uncalibrated-magnetometer",
+  "absolute-orientation",
+  "relative-orientation",
+  "geolocation",
+  "proximity",
 };
 

Each enumeration value in the MockSensorType enum identifies a mock sensor type. Each mock sensor type has a mock sensor reading values dictionary:

-
Mock Sensor Reading Values dictionary -
-

MockSensorReadingValues dictionary represents user specified mock sensor reading used for updating mock sensor reading. Its members must match the attribute identifier defined by the sensor type’s - associated extension sensor interface. Each mock sensor type has a specific MockSensorReadingValues, which is defined in each section of mock senor type.

-
dictionary MockSensorReadingValues {
+    
Mock Sensor Reading Values dictionary +
+

MockSensorReadingValues dictionary represents a user-specified mock sensor reading used for updating a mock sensor reading. Its members must match the attribute identifier defined by the sensor type’s + associated extension sensor interface. Each mock sensor type has a specific MockSensorReadingValues, which is defined in each section of mock sensor type.

+
dictionary MockSensorReadingValues {
 };
 

2.3.1. Ambient Light Sensor

- The "ambient-light" type is the mock sensor type + The "ambient-light" type is the mock sensor type associated with the usage of the AmbientLightSensor interface.
Mock Sensor Reading Values
-
dictionary AmbientLightReadingValues {
-  required double? illuminance;
+
dictionary AmbientLightReadingValues {
+  required double? illuminance;
 };
 

2.3.2. Accelerometer

- The "accelerometer" type is the mock sensor type + The "accelerometer" type is the mock sensor type associated with the usage of the Accelerometer interface.
Mock Sensor Reading Values
-
dictionary AccelerometerReadingValues {
-  required double? x;
-  required double? y;
-  required double? z;
+
dictionary AccelerometerReadingValues {
+  required double? x;
+  required double? y;
+  required double? z;
 };
 

2.3.3. Linear Acceleration Sensor

- The "linear-acceleration" type is the mock sensor type + The "linear-acceleration" type is the mock sensor type associated with the usage of the LinearAccelerationSensor interface.
Mock Sensor Reading Values
-
dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
+
dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
 };
 

2.3.4. Gravity Sensor

- The "gravity" type is the mock sensor type + The "gravity" type is the mock sensor type associated with the usage of the GravitySensor interface.
Mock Sensor Reading Values
-
dictionary GravityReadingValues : AccelerometerReadingValues {
+
dictionary GravityReadingValues : AccelerometerReadingValues {
 };
 

2.3.5. Gyroscope

- The "gyroscope" type is the mock sensor type + The "gyroscope" type is the mock sensor type associated with the usage of the Gyroscope interface.
Mock Sensor Reading Values
-
dictionary GyroscopeReadingValues {
-  required double? x;
-  required double? y;
-  required double? z;
+
dictionary GyroscopeReadingValues {
+  required double? x;
+  required double? y;
+  required double? z;
 };
 

2.3.6. Magnetometer

- The "magnetometer" type is the mock sensor type + The "magnetometer" type is the mock sensor type associated with the usage of the Magnetometer interface.
Mock Sensor Reading Values
-
dictionary MagnetometerReadingValues {
-  required double? x;
-  required double? y;
-  required double? z;
+
dictionary MagnetometerReadingValues {
+  required double? x;
+  required double? y;
+  required double? z;
 };
 

2.3.7. Uncalibrated Magnetometer

- The "uncalibrated-magnetometer" type is the mock sensor type + The "uncalibrated-magnetometer" type is the mock sensor type associated with the usage of the UncalibratedMagnetometer interface.
Mock Sensor Reading Values
-
dictionary UncalibratedMagnetometerReadingValues {
-  required double? x;
-  required double? y;
-  required double? z;
-  required double? xBias;
-  required double? yBias;
-  required double? zBias;
+
dictionary UncalibratedMagnetometerReadingValues {
+  required double? x;
+  required double? y;
+  required double? z;
+  required double? xBias;
+  required double? yBias;
+  required double? zBias;
 };
 

2.3.8. Absolute Orientation Sensor

- The "absolute-orientation" type is the mock sensor type + The "absolute-orientation" type is the mock sensor type associated with the usage of the AbsoluteOrientationSensor interface.
Mock Sensor Reading Values
-
dictionary AbsoluteOrientationReadingValues {
-  required FrozenArray<double>? quaternion;
+
dictionary AbsoluteOrientationReadingValues {
+  required FrozenArray<double>? quaternion;
 };
 

2.3.9. Relative Orientation Sensor

- The "relative-orientation" type is the mock sensor type + The "relative-orientation" type is the mock sensor type associated with the usage of the RelativeOrientationSensor interface.
Mock Sensor Reading Values
-
dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
+
dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
 };
 

2.3.10. Geolocation Sensor

- The "geolocation" type is the mock sensor type + The "geolocation" type is the mock sensor type associated with the usage of the GeolocationSensor interface.
Mock Sensor Reading Values
-
dictionary GeolocationReadingValues {
-  required double? latitude;
-  required double? longitude;
-  required double? altitude;
-  required double? accuracy;
-  required double? altitudeAccuracy;
-  required double? heading;
-  required double? speed;
+
dictionary GeolocationReadingValues {
+  required double? latitude;
+  required double? longitude;
+  required double? altitude;
+  required double? accuracy;
+  required double? altitudeAccuracy;
+  required double? heading;
+  required double? speed;
 };
 

2.3.11. Proximity Sensor

- The "proximity" type is the mock sensor type + The "proximity" type is the mock sensor type associated with the usage of the ProximitySensor interface.
Mock Sensor Reading Values
-
dictionary ProximityReadingValues {
-  required double? distance;
-  required double? max;
-  required boolean? near;
+
dictionary ProximityReadingValues {
+  required double? distance;
+  required double? max;
+  required boolean? near;
 };
 
@@ -1811,49 +1811,49 @@

< POST /session/{session id}/sensor -

The create mock sensor extension command simulates user -creation of a mock sensor.

+

The create mock sensor extension command creates a +new mock sensor.

The remote end steps are:

    -
  1. +
  2. Let configuration be the configuration argument, converted to an IDL value of type MockSensorConfiguration. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    -
  3. -

    Let type be the configuration.mockSensorType, if the current browsing context already has this type of mock sensor, return a WebDriver error with WebDriver error code mock sensor already created.

    -
  4. -

    Run these sub-steps in parallel to create a mock sensor in current browsing context:

    +
  5. +

    Let type be the configuration.mockSensorType. If the current browsing context already has this type of mock sensor, return a WebDriver error with WebDriver error code mock sensor already created.

    +
  6. +

    Run these sub-steps in parallel to create a mock sensor in the current browsing context:

      -
    1. +
    2. Let mock be a new mock sensor.

      -
    3. +
    4. Set mock’s mock sensor type to type.

      -
    5. +
    6. Let connected be the configuration.connected, set mock’s associated connection flag to connected.

      -
    7. +
    8. If configuration.maxSamplingFrequency is present, then:

        -
      1. +
      2. Set mock’s maximum supported sampling frequency to configuration.maxSamplingFrequency.

      -
    9. +
    10. If configuration.minSamplingFrequency is present, then:

        -
      1. +
      2. Set mock’s minimum supported sampling frequency to configuration.minSamplingFrequency.

      -
    11. +
    12. Let sensor_instance be a type of Sensor object, set sensor_instance’s associated platform sensor to mock.

    -
  7. +
  8. Return success with data null.

-
- To create an "ambient-light" mock sensor of current browsing context of the session with ID 23, +
+ To create an "ambient-light" mock sensor in the current browsing context of the session with ID 23, the local end would POST to /session/23/sensor/ with the body: -
{
-  "mockSensorType": "ambient-light",
-  "maxSamplingFrequency": 60,
-  "minSamplingFrequency": 5
-}
+
{
+  "mockSensorType": "ambient-light",
+  "maxSamplingFrequency": 60,
+  "minSamplingFrequency": 5
+}
 

Be aware that only one mock sensor of a given mock sensor type can be created in current browsing context, otherwise a WebDriver error with WebDriver error code mock sensor already created will be thrown.

@@ -1868,16 +1868,16 @@

GET /session/{session id}/sensor/{type} -

The get mock sensor extension command simulates user -getting information of a given type of mock sensor.

+

The get mock sensor extension command retrieves +information about a given type of mock sensor.

The remote end steps are:

    -
  1. +
  2. Let type be a url variable, converted to an IDL value of type MockSensorType. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    -
  3. +
  4. If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    -
  5. +
  6. Return success with the serialized mock sensor as data.

3.1.3. Update mock sensor reading

@@ -1890,25 +1890,25 @@

update mock sensor reading extension command simulates user -updating of a given type of mock sensor's reading.

+

The update mock sensor reading extension command updates +a given type of mock sensor's reading.

The remote end steps are:

    -
  1. +
  2. Let type be a url variable, converted to an IDL value of type MockSensorType. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    -
  3. +
  4. If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    -
  5. +
  6. Let reading be the reading argument, converted to an IDL value of the type’s associated MockSensorReadingValues. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

    -
  7. +
  8. For each keyvalue of reading.

      -
    1. +
    2. Set mock sensor reading[key] to the corresponding value of reading.

    -
  9. +
  10. Return success with data null.

3.1.4. Delete mock sensor

@@ -1921,19 +1921,19 @@

< DELETE /session/{session id}/sensor/{type} -

The delete mock sensor extension command simulates user -deletion of a given type of mock sensor.

+

The delete mock sensor extension command deletes +a given type of mock sensor.

The remote end steps are:

    -
  1. +
  2. Let type be a url variable.

    -
  3. +
  4. If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

    -
  5. +
  6. If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

    -
  7. +
  8. Delete type of mock sensor in current browsing context.

    -
  9. +
  10. Return success with data null.

3.2. Handling errors

@@ -1947,12 +1947,12 @@

Description - no such mock sensor + no such mock sensor 404 no such mock sensor no mock sensor matching the given type was found. - mock sensor already created + mock sensor already created 500 mock sensor already createdcommand to create a mock sensor could not be satisfied because the given type of mock sensor is already existed. @@ -2443,7 +2443,7 @@

sensor type
  • - [GEOLOCATION-SENSOR] defines the following terms: + [geolocation-sensor] defines the following terms:
    • geolocationsensor
    @@ -2530,7 +2530,7 @@

    N
    [GENERIC-SENSOR]
    Rick Waldron; Mikhail Pozdnyakov; Alexander Shalamov. Generic Sensor API. 20 March 2018. CR. URL: https://www.w3.org/TR/generic-sensor/
    [GEOLOCATION-SENSOR] -
    Geolocation Sensor. Living Standard. URL: https://wicg.github.io/geolocation-sensor/ +
    Anssi Kostiainen. Geolocation Sensor. 21 August 2018. WD. URL: https://www.w3.org/TR/geolocation-sensor/
    [GYROSCOPE]
    Anssi Kostiainen; Mikhail Pozdnyakov. Gyroscope. 20 March 2018. CR. URL: https://www.w3.org/TR/gyroscope/
    [HR-TIME-2] @@ -2546,99 +2546,99 @@

    N
    [PROXIMITY]
    Anssi Kostiainen; Rijubrata Bhaumik. Proximity Sensor. 19 July 2016. WD. URL: https://www.w3.org/TR/proximity/
    [WebDriver] -
    Simon Stewart; David Burns. WebDriver. 26 April 2018. PR. URL: https://www.w3.org/TR/webdriver1/ +
    Simon Stewart; David Burns. WebDriver. 5 June 2018. REC. URL: https://www.w3.org/TR/webdriver1/
    [WebIDL]
    Cameron McCormack; Boris Zbarsky; Tobie Langel. Web IDL. 15 December 2016. ED. URL: https://heycam.github.io/webidl/

  • IDL Index

    -
    dictionary MockSensorConfiguration {
    -  required MockSensorType mockSensorType;
    -  boolean connected = true;
    -  double? maxSamplingFrequency;
    -  double? minSamplingFrequency;
    +
    dictionary MockSensorConfiguration {
    +  required MockSensorType mockSensorType;
    +  boolean connected = true;
    +  double? maxSamplingFrequency;
    +  double? minSamplingFrequency;
     };
     
    -dictionary MockSensor {
    -  double maxSamplingFrequency;
    -  double minSamplingFrequency;
    -  double requestedSamplingFrequency;
    +dictionary MockSensor {
    +  double maxSamplingFrequency;
    +  double minSamplingFrequency;
    +  double requestedSamplingFrequency;
     };
     
    -enum MockSensorType {
    -  "ambient-light",
    -  "accelerometer",
    -  "linear-acceleration",
    -  "gravity",
    -  "gyroscope",
    -  "magnetometer",
    -  "uncalibrated-magnetometer",
    -  "absolute-orientation",
    -  "relative-orientation",
    -  "geolocation",
    -  "proximity",
    +enum MockSensorType {
    +  "ambient-light",
    +  "accelerometer",
    +  "linear-acceleration",
    +  "gravity",
    +  "gyroscope",
    +  "magnetometer",
    +  "uncalibrated-magnetometer",
    +  "absolute-orientation",
    +  "relative-orientation",
    +  "geolocation",
    +  "proximity",
     };
     
    -dictionary MockSensorReadingValues {
    +dictionary MockSensorReadingValues {
     };
     
    -dictionary AmbientLightReadingValues {
    -  required double? illuminance;
    +dictionary AmbientLightReadingValues {
    +  required double? illuminance;
     };
     
    -dictionary AccelerometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +dictionary AccelerometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     
    -dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
    +dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
     };
     
    -dictionary GravityReadingValues : AccelerometerReadingValues {
    +dictionary GravityReadingValues : AccelerometerReadingValues {
     };
     
    -dictionary GyroscopeReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +dictionary GyroscopeReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     
    -dictionary MagnetometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +dictionary MagnetometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     
    -dictionary UncalibratedMagnetometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    -  required double? xBias;
    -  required double? yBias;
    -  required double? zBias;
    +dictionary UncalibratedMagnetometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
    +  required double? xBias;
    +  required double? yBias;
    +  required double? zBias;
     };
     
    -dictionary AbsoluteOrientationReadingValues {
    -  required FrozenArray<double>? quaternion;
    +dictionary AbsoluteOrientationReadingValues {
    +  required FrozenArray<double>? quaternion;
     };
     
    -dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
    +dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
     };
     
    -dictionary GeolocationReadingValues {
    -  required double? latitude;
    -  required double? longitude;
    -  required double? altitude;
    -  required double? accuracy;
    -  required double? altitudeAccuracy;
    -  required double? heading;
    -  required double? speed;
    +dictionary GeolocationReadingValues {
    +  required double? latitude;
    +  required double? longitude;
    +  required double? altitude;
    +  required double? accuracy;
    +  required double? altitudeAccuracy;
    +  required double? heading;
    +  required double? speed;
     };
     
    -dictionary ProximityReadingValues {
    -  required double? distance;
    -  required double? max;
    -  required boolean? near;
    +dictionary ProximityReadingValues {
    +  required double? distance;
    +  required double? max;
    +  required boolean? near;
     };
     
     
    From 246e17b5e0e616ec3da1dc06b4f47d115e47242a Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Fri, 23 Nov 2018 12:08:08 +0800 Subject: [PATCH 14/14] Address @JohnChen0's comments - Remove trailing `\` in WebDriver endpoint URL - s/argument/parameter - Add two more steps to check if browsing context is still open and handle user prompts --- webdriver-extension/explainer.md | 10 +- webdriver-extension/index.bs | 41 ++- webdriver-extension/index.html | 598 +++++++++++++++++-------------- 3 files changed, 355 insertions(+), 294 deletions(-) diff --git a/webdriver-extension/explainer.md b/webdriver-extension/explainer.md index 7717697..9d841a5 100644 --- a/webdriver-extension/explainer.md +++ b/webdriver-extension/explainer.md @@ -46,7 +46,7 @@ Tests could be written in any languages, as long as they wrap the WebDriver HTTP ### Create mock sensor - To create an "accelerometer" mock sensor with session ID 21, the local end would send a `POST` request to `/session/21/sensor/` with the body: + To create an "accelerometer" mock sensor with session ID 21, the local end would send a `POST` request to `/session/21/sensor` with the body: ``` { "mockSensorType": "accelerometer", @@ -65,7 +65,7 @@ Once a mock sensor instance is presented, the user agent must force the same sen ### Get mock sensor -To get an "accelerometer" mock sensor with session ID 22, the local end would send a `GET` request to `/session/22/sensor/accelerometer/` without body. On success, the remote end would respond with the serialized mock sensor as data: +To get an "accelerometer" mock sensor with session ID 22, the local end would send a `GET` request to `/session/22/sensor/accelerometer` without body. On success, the remote end would respond with the serialized mock sensor as data: ``` { "maxSamplingFrequency": 60, @@ -76,7 +76,7 @@ To get an "accelerometer" mock sensor with session ID 22, the local end would se ### Update mock sensor reading -To update the mock sensor reading of an "accelerometer" mock sensor with session ID 23, the local end would send a `POST` request to `/session/23/sensor/accelerometer/` with body: +To update the mock sensor reading of an "accelerometer" mock sensor with session ID 23, the local end would send a `POST` request to `/session/23/sensor/accelerometer` with body: ``` { "x": 1.12345, @@ -93,11 +93,11 @@ A user agent must provide the mock sensor readings that are initially exposed to ### Delete mock sensor -To delete an "accelerometer" mock sensor with session ID 24, the local end would send a `DELETE` request to `/session/24/sensor/accelerometer/` without body. +To delete an "accelerometer" mock sensor with session ID 24, the local end would send a `DELETE` request to `/session/24/sensor/accelerometer` without body. ## References & acknowledgements - Discussion on public-test-infra mailing list: [UserAgent-specific files in Web Platform Tests](https://www.w3.org/Search/Mail/Public/search?keywords=&hdr-1-name=subject&hdr-1-query=%22UserAgent-specific+files+in+Web+Platform+Tests%22&index-grp=Public_FULL&index-type=g&type-index=) - [Generic Sesnor API](https://w3c.github.io/sensors/#sensor) -Many thanks to Anssi Kostiainen, Raphael Kubo da Costa, Alexander Shalamov, Tobie Langel, Philip Jägenstedt, Jonathon Kereliuk, and Mike Pennisi for their comments and contributions to the discussions that have informed it. +Many thanks to Anssi Kostiainen, Raphael Kubo da Costa, Alexander Shalamov, Tobie Langel, Philip Jägenstedt, Jonathon Kereliuk, John Chen, and Mike Pennisi for their comments and contributions to the discussions that have informed it. diff --git a/webdriver-extension/index.bs b/webdriver-extension/index.bs index 53048fa..717cd16 100644 --- a/webdriver-extension/index.bs +++ b/webdriver-extension/index.bs @@ -32,6 +32,9 @@ urlPrefix: https://w3c.github.io/webdriver/webdriver-spec.html#; spec: WebDriver text: success; url: dfn-success text: handling errors text: Object; url: dfn-object + text: no longer open; url: dfn-no-longer-open + text: no such window; url: dfn-no-such-window + text: Handle any user prompts; url: dfn-handle-any-user-prompts urlPrefix: https://w3c.github.io/sensors/; spec: GENERIC-SENSOR type: dfn text: platform sensor; url: concept-platform-sensor @@ -405,13 +408,16 @@ The create mock sensor extension command creates a new [=mock sensor=]. The remote end steps are: -1. Let |configuration| be the |configuration| argument, converted to an IDL value +1. Let |configuration| be the |configuration| parameter, converted to an IDL value of type {{MockSensorConfiguration}}. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument. 2. Let |type| be the |configuration|.{{MockSensorConfiguration/mockSensorType}}. If the current browsing context already has this |type| of [=mock sensor=], return a WebDriver error with WebDriver error code [=mock sensor already created=]. -3. Run these sub-steps [=in parallel=] to create a [=mock sensor=] in the current browsing context: +3. If the current browsing context is no longer open, return a WebDriver error with + WebDriver error code no such window. +4. Handle any user prompts, and return its value if it is a WebDriver error. +5. Run these sub-steps [=in parallel=] to create a [=mock sensor=] in the current browsing context: 1. Let |mock| be a new [=mock sensor=]. 2. Set |mock|'s [=mock sensor type=] to |type|. 3. Let |connected| be the |configuration|.{{MockSensorConfiguration/connected}}, set |mock|'s associated @@ -421,11 +427,11 @@ The remote end steps are: 5. If |configuration|.{{MockSensorConfiguration/minSamplingFrequency}} is [=present=], then: 1. Set |mock|'s minimum supported sampling frequency to |configuration|.{{MockSensorConfiguration/minSamplingFrequency}}. 6. Let |sensor_instance| be a |type| of Sensor object, set |sensor_instance|'s associated platform sensor to |mock|. -4. Return success with data `null`. +6. Return success with data `null`.
    To create an "ambient-light" mock sensor in the current browsing context of the session with ID 23, - the local end would POST to `/session/23/sensor/` with the body: + the local end would POST to `/session/23/sensor` with the body:
       {
         "mockSensorType": "ambient-light",
    @@ -459,9 +465,12 @@ The remote end steps are:
     1. Let |type| be a url variable, converted to an IDL value of type {{MockSensorType}}.
        If this throws an exception, return a WebDriver error with WebDriver error code
        invalid argument.
    -2. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
    +2. If the current browsing context is no longer open, return a WebDriver error with
    +   WebDriver error code no such window.
    +3. Handle any user prompts, and return its value if it is a WebDriver error.
    +4. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
        current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=].
    -3. Return success with the serialized mock sensor as data.
    +5. Return success with the serialized mock sensor as data.
     
     ### Update mock sensor reading ### {#update-mock-sensor-reading-command}
     
    @@ -485,14 +494,17 @@ The remote end steps are:
     1. Let |type| be a url variable, converted to an IDL value of type {{MockSensorType}}.
        If this throws an exception, return a WebDriver error with WebDriver error code
        invalid argument.
    -2. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
    +2. If the current browsing context is no longer open, return a WebDriver error with
    +   WebDriver error code no such window.
    +3. Handle any user prompts, and return its value if it is a WebDriver error.
    +4. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
        current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=].
    -3. Let |reading| be the |reading| argument, converted to an IDL value of the |type|'s
    +5. Let |reading| be the |reading| argument, converted to an IDL value of the |type|'s
        associated {{MockSensorReadingValues}}. If this throws an exception, return a
        WebDriver error with WebDriver error code invalid argument.
    -4. [=map/For each=] |key| → value of |reading|.
    +6. [=map/For each=] |key| → value of |reading|.
       1.  [=map/Set=] [=mock sensor reading=][|key|] to the corresponding value of |reading|.
    -5. Return success with data `null`.
    +7. Return success with data `null`.
     
     ### Delete mock sensor ### {#delete-mock-sensor-command}
     
    @@ -516,10 +528,13 @@ The remote end steps are:
     1. Let |type| be a url variable.
     2. If {{MockSensorType}} [=set/contains|does not contain=] |type|, return a WebDriver error with
        WebDriver error code invalid argument.
    -3. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
    +3. If the current browsing context is no longer open, return a WebDriver error with
    +   WebDriver error code no such window.
    +4. Handle any user prompts, and return its value if it is a WebDriver error.
    +5. If |type| does not match a [=mock sensor type=] amongst all associated [=mock sensors=] of the
        current browsing context, return a WebDriver error with WebDriver error code [=no such mock sensor=].
    -4. Delete |type| of [=mock sensor=] in current browsing context.
    -5. Return success with data `null`.
    +6. Delete |type| of [=mock sensor=] in current browsing context.
    +7. Return success with data `null`.
     
     ## Handling errors ## {#extension-handling-errors}
     
    diff --git a/webdriver-extension/index.html b/webdriver-extension/index.html
    index 31328ba..3f4b136 100644
    --- a/webdriver-extension/index.html
    +++ b/webdriver-extension/index.html
    @@ -1059,10 +1059,9 @@
     			   comprising the first items of each top-level section. */
     			margin-top: 1.1rem;
     		}
    -		#toc#toc .secno { /* Ugh, need more specificity to override base.css */
    +		#toc .secno {
     			grid-column: 1;
     			width: auto;
    -			margin-left: 0;
     		}
     		#toc .content {
     			grid-column: 2;
    @@ -1219,8 +1218,9 @@
           background-attachment: fixed;
         }
       
    -  
    +  
       
    +  
     
      
       

    WebDriver Extension API for Generic Sensor

    -

    Editor’s Draft,

    +

    Editor’s Draft,

    This version: @@ -1475,7 +1475,7 @@

    https://github.com/w3c/sensors/commits/gh-pages/index.bs
    Feedback: -
    public-device-apis@w3.org with subject line “[webdriver-extension] … message topic …” (archives) +
    public-device-apis@w3.org with subject line “[webdriver-extension] … message topic …” (archives)
    Issue Tracking:
    GitHub
    Editor: @@ -1504,7 +1504,7 @@

    …summary of comment…”. All comments are welcome.

    -

    This document was produced by the Devices and Sensors Working Group.

    +

    This document was produced by the Device and Sensors Working Group.

    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; @@ -1575,8 +1575,8 @@

    1. extension commands, devices with particular properties can be created and their responses to requests are well defined.

    2. Mock Sensors

    -

    A mock sensor simulates the behavior of a platform sensor in controlled ways.

    -

    A mock sensor reports a corresponding mock sensor reading, which is a source of +

    A mock sensor simulates the behavior of a platform sensor in controlled ways.

    +

    A mock sensor reports a corresponding mock sensor reading, which is a source of mocking information about the environment, to the Sensor objects.

    The current browsing context’s mock sensor has an associated mock sensor reading map.

    The mock sensor reading map contains an entry whose key is @@ -1591,211 +1591,211 @@

    Note: The mock sensor defined in this specification is not intended be used by non-testing-related web content. The UA MAY choose to expose mock sensor interface only when a runtime or compile-time flag has been set.

    2.1. MockSensorConfiguration dictionary

    -
    dictionary MockSensorConfiguration {
    -  required MockSensorType mockSensorType;
    -  boolean connected = true;
    -  double? maxSamplingFrequency;
    -  double? minSamplingFrequency;
    +
    dictionary MockSensorConfiguration {
    +  required MockSensorType mockSensorType;
    +  boolean connected = true;
    +  double? maxSamplingFrequency;
    +  double? minSamplingFrequency;
     };
     

    The MockSensorConfiguration dictionary is used to create a mock sensor.

    -
    mockSensorType member -
    +
    mockSensorType member +

    A MockSensorType that is used to set mock sensor type.

    -
    connected member -
    -

    A boolean that indicates a mock sensor's connection flag which is used for switching the connection +

    connected member +
    +

    A boolean that indicates a mock sensor's connection flag which is used for switching the connection between Sensor object and mock sensor. When set to false the user agent must force the result of invoking connect to sensor with mock sensor's associated Sensor object as argument to false, otherwise true.

    -
    maxSamplingFrequency member -
    +
    maxSamplingFrequency member +

    A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated mock sensor.

    -
    minSamplingFrequency member -
    +
    minSamplingFrequency member +

    A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated mock sensor.

    2.2. MockSensor dictionary

    -
    dictionary MockSensor {
    -  double maxSamplingFrequency;
    -  double minSamplingFrequency;
    -  double requestedSamplingFrequency;
    +
    dictionary MockSensor {
    +  double maxSamplingFrequency;
    +  double minSamplingFrequency;
    +  double requestedSamplingFrequency;
     };
     

    The MockSensor dictionary provides information about a mock sensor.

    -
    maxSamplingFrequency member -
    +
    maxSamplingFrequency member +

    A double representing frequency in Hz that indicates the maximum supported sampling frequency of the associated mock sensor.

    -
    minSamplingFrequency member -
    +
    minSamplingFrequency member +

    A double representing frequency in Hz that indicates the minimum supported sampling frequency of the associated mock sensor.

    -
    requestedSamplingFrequency member -
    +
    requestedSamplingFrequency member +

    A double representing frequency in Hz that indicates the requested sampling frequency of the associated mock sensor.

    -

    A serialized mock sensor is a JSON Object where a mock sensor's fields listed in the MockSensor dictionary are mapped +

    A serialized mock sensor is a JSON Object where a mock sensor's fields listed in the MockSensor dictionary are mapped using the JSON Key and the associated field’s value from the available mock sensor in current browsing context.

    2.3. Mock sensor type

    -

    A mock sensor type is equivalent to a sensor type’s associated Sensor subclass.

    -
    enum MockSensorType {
    -  "ambient-light",
    -  "accelerometer",
    -  "linear-acceleration",
    -  "gravity",
    -  "gyroscope",
    -  "magnetometer",
    -  "uncalibrated-magnetometer",
    -  "absolute-orientation",
    -  "relative-orientation",
    -  "geolocation",
    -  "proximity",
    +   

    A mock sensor type is equivalent to a sensor type’s associated Sensor subclass.

    +
    enum MockSensorType {
    +  "ambient-light",
    +  "accelerometer",
    +  "linear-acceleration",
    +  "gravity",
    +  "gyroscope",
    +  "magnetometer",
    +  "uncalibrated-magnetometer",
    +  "absolute-orientation",
    +  "relative-orientation",
    +  "geolocation",
    +  "proximity",
     };
     

    Each enumeration value in the MockSensorType enum identifies a mock sensor type. Each mock sensor type has a mock sensor reading values dictionary:

    -
    Mock Sensor Reading Values dictionary -
    +
    Mock Sensor Reading Values dictionary +

    MockSensorReadingValues dictionary represents a user-specified mock sensor reading used for updating a mock sensor reading. Its members must match the attribute identifier defined by the sensor type’s associated extension sensor interface. Each mock sensor type has a specific MockSensorReadingValues, which is defined in each section of mock sensor type.

    -
    dictionary MockSensorReadingValues {
    +
    dictionary MockSensorReadingValues {
     };
     

    2.3.1. Ambient Light Sensor

    - The "ambient-light" type is the mock sensor type + The "ambient-light" type is the mock sensor type associated with the usage of the AmbientLightSensor interface.
    Mock Sensor Reading Values
    -
    dictionary AmbientLightReadingValues {
    -  required double? illuminance;
    +
    dictionary AmbientLightReadingValues {
    +  required double? illuminance;
     };
     

    2.3.2. Accelerometer

    - The "accelerometer" type is the mock sensor type + The "accelerometer" type is the mock sensor type associated with the usage of the Accelerometer interface.
    Mock Sensor Reading Values
    -
    dictionary AccelerometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +
    dictionary AccelerometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     

    2.3.3. Linear Acceleration Sensor

    - The "linear-acceleration" type is the mock sensor type + The "linear-acceleration" type is the mock sensor type associated with the usage of the LinearAccelerationSensor interface.
    Mock Sensor Reading Values
    -
    dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
    +
    dictionary LinearAccelerationReadingValues : AccelerometerReadingValues {
     };
     

    2.3.4. Gravity Sensor

    - The "gravity" type is the mock sensor type + The "gravity" type is the mock sensor type associated with the usage of the GravitySensor interface.
    Mock Sensor Reading Values
    -
    dictionary GravityReadingValues : AccelerometerReadingValues {
    +
    dictionary GravityReadingValues : AccelerometerReadingValues {
     };
     

    2.3.5. Gyroscope

    - The "gyroscope" type is the mock sensor type + The "gyroscope" type is the mock sensor type associated with the usage of the Gyroscope interface.
    Mock Sensor Reading Values
    -
    dictionary GyroscopeReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +
    dictionary GyroscopeReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     

    2.3.6. Magnetometer

    - The "magnetometer" type is the mock sensor type + The "magnetometer" type is the mock sensor type associated with the usage of the Magnetometer interface.
    Mock Sensor Reading Values
    -
    dictionary MagnetometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    +
    dictionary MagnetometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
     };
     

    2.3.7. Uncalibrated Magnetometer

    - The "uncalibrated-magnetometer" type is the mock sensor type + The "uncalibrated-magnetometer" type is the mock sensor type associated with the usage of the UncalibratedMagnetometer interface.
    Mock Sensor Reading Values
    -
    dictionary UncalibratedMagnetometerReadingValues {
    -  required double? x;
    -  required double? y;
    -  required double? z;
    -  required double? xBias;
    -  required double? yBias;
    -  required double? zBias;
    +
    dictionary UncalibratedMagnetometerReadingValues {
    +  required double? x;
    +  required double? y;
    +  required double? z;
    +  required double? xBias;
    +  required double? yBias;
    +  required double? zBias;
     };
     

    2.3.8. Absolute Orientation Sensor

    - The "absolute-orientation" type is the mock sensor type + The "absolute-orientation" type is the mock sensor type associated with the usage of the AbsoluteOrientationSensor interface.
    Mock Sensor Reading Values
    -
    dictionary AbsoluteOrientationReadingValues {
    -  required FrozenArray<double>? quaternion;
    +
    dictionary AbsoluteOrientationReadingValues {
    +  required FrozenArray<double>? quaternion;
     };
     

    2.3.9. Relative Orientation Sensor

    - The "relative-orientation" type is the mock sensor type + The "relative-orientation" type is the mock sensor type associated with the usage of the RelativeOrientationSensor interface.
    Mock Sensor Reading Values
    -
    dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
    +
    dictionary RelativeOrientationReadingValues : AbsoluteOrientationReadingValues {
     };
     

    2.3.10. Geolocation Sensor

    - The "geolocation" type is the mock sensor type + The "geolocation" type is the mock sensor type associated with the usage of the GeolocationSensor interface.
    Mock Sensor Reading Values
    -
    dictionary GeolocationReadingValues {
    -  required double? latitude;
    -  required double? longitude;
    -  required double? altitude;
    -  required double? accuracy;
    -  required double? altitudeAccuracy;
    -  required double? heading;
    -  required double? speed;
    +
    dictionary GeolocationReadingValues {
    +  required double? latitude;
    +  required double? longitude;
    +  required double? altitude;
    +  required double? accuracy;
    +  required double? altitudeAccuracy;
    +  required double? heading;
    +  required double? speed;
     };
     

    2.3.11. Proximity Sensor

    - The "proximity" type is the mock sensor type + The "proximity" type is the mock sensor type associated with the usage of the ProximitySensor interface.
    Mock Sensor Reading Values
    -
    dictionary ProximityReadingValues {
    -  required double? distance;
    -  required double? max;
    -  required boolean? near;
    +
    dictionary ProximityReadingValues {
    +  required double? distance;
    +  required double? max;
    +  required boolean? near;
     };
     
    @@ -1811,52 +1811,56 @@

    < POST /session/{session id}/sensor -

    The create mock sensor extension command creates a +

    The create mock sensor extension command creates a new mock sensor.

    The remote end steps are:

      -
    1. -

      Let configuration be the configuration argument, converted to an IDL value of type MockSensorConfiguration. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      -
    2. +
    3. +

      Let configuration be the configuration parameter, converted to an IDL value of type MockSensorConfiguration. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      +
    4. Let type be the configuration.mockSensorType. If the current browsing context already has this type of mock sensor, return a WebDriver error with WebDriver error code mock sensor already created.

      -
    5. -

      Run these sub-steps in parallel to create a mock sensor in the current browsing context:

      +
    6. +

      If the current browsing context is no longer open, return a WebDriver error with WebDriver error code no such window.

      +
    7. +

      Handle any user prompts, and return its value if it is a WebDriver error.

      +
    8. +

      Run these sub-steps in parallel to create a mock sensor in the current browsing context:

        -
      1. +
      2. Let mock be a new mock sensor.

        -
      3. +
      4. Set mock’s mock sensor type to type.

        -
      5. +
      6. Let connected be the configuration.connected, set mock’s associated connection flag to connected.

        -
      7. +
      8. If configuration.maxSamplingFrequency is present, then:

          -
        1. +
        2. Set mock’s maximum supported sampling frequency to configuration.maxSamplingFrequency.

        -
      9. +
      10. If configuration.minSamplingFrequency is present, then:

          -
        1. +
        2. Set mock’s minimum supported sampling frequency to configuration.minSamplingFrequency.

        -
      11. +
      12. Let sensor_instance be a type of Sensor object, set sensor_instance’s associated platform sensor to mock.

      -
    9. +
    10. Return success with data null.

    -
    - To create an "ambient-light" mock sensor in the current browsing context of the session with ID 23, - the local end would POST to /session/23/sensor/ with the body: -
    {
    -  "mockSensorType": "ambient-light",
    -  "maxSamplingFrequency": 60,
    -  "minSamplingFrequency": 5
    -}
    +   
    + To create an "ambient-light" mock sensor in the current browsing context of the session with ID 23, + the local end would POST to /session/23/sensor with the body: +
    {
    +  "mockSensorType": "ambient-light",
    +  "maxSamplingFrequency": 60,
    +  "minSamplingFrequency": 5
    +}
     
    -

    Be aware that only one mock sensor of a given mock sensor type can be created in current browsing context, - otherwise a WebDriver error with WebDriver error code mock sensor already created will be thrown.

    +

    Be aware that only one mock sensor of a given mock sensor type can be created in current browsing context, + otherwise a WebDriver error with WebDriver error code mock sensor already created will be thrown.

    3.1.2. Get mock sensor

    @@ -1868,16 +1872,20 @@

    GET

    /session/{session id}/sensor/{type}
    -

    The get mock sensor extension command retrieves +

    The get mock sensor extension command retrieves information about a given type of mock sensor.

    The remote end steps are:

      -
    1. +
    2. Let type be a url variable, converted to an IDL value of type MockSensorType. - If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      -
    3. -

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      -
    4. + If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      +
    5. +

      If the current browsing context is no longer open, return a WebDriver error with WebDriver error code no such window.

      +
    6. +

      Handle any user prompts, and return its value if it is a WebDriver error.

      +
    7. +

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      +
    8. Return success with the serialized mock sensor as data.

    3.1.3. Update mock sensor reading

    @@ -1890,25 +1898,29 @@

    update mock sensor reading extension command updates +

    The update mock sensor reading extension command updates a given type of mock sensor's reading.

    The remote end steps are:

      -
    1. +
    2. Let type be a url variable, converted to an IDL value of type MockSensorType. - If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      -
    3. -

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      -
    4. + If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      +
    5. +

      If the current browsing context is no longer open, return a WebDriver error with WebDriver error code no such window.

      +
    6. +

      Handle any user prompts, and return its value if it is a WebDriver error.

      +
    7. +

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      +
    8. Let reading be the reading argument, converted to an IDL value of the type’s - associated MockSensorReadingValues. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      -
    9. + associated MockSensorReadingValues. If this throws an exception, return a WebDriver error with WebDriver error code invalid argument.

      +
    10. For each keyvalue of reading.

        -
      1. +
      2. Set mock sensor reading[key] to the corresponding value of reading.

      -
    11. +
    12. Return success with data null.

    3.1.4. Delete mock sensor

    @@ -1921,23 +1933,27 @@

    < DELETE /session/{session id}/sensor/{type} -

    The delete mock sensor extension command deletes +

    The delete mock sensor extension command deletes a given type of mock sensor.

    The remote end steps are:

      -
    1. +
    2. Let type be a url variable.

      -
    3. -

      If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

      -
    4. -

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      -
    5. -

      Delete type of mock sensor in current browsing context.

      -
    6. +
    7. +

      If MockSensorType does not contain type, return a WebDriver error with WebDriver error code invalid argument.

      +
    8. +

      If the current browsing context is no longer open, return a WebDriver error with WebDriver error code no such window.

      +
    9. +

      Handle any user prompts, and return its value if it is a WebDriver error.

      +
    10. +

      If type does not match a mock sensor type amongst all associated mock sensors of the current browsing context, return a WebDriver error with WebDriver error code no such mock sensor.

      +
    11. +

      Delete type of mock sensor in current browsing context.

      +
    12. Return success with data null.

    3.2. Handling errors

    -

    This section extends the Handling Errors and defines extended WebDriver error codes specific for mock sensor in following table.

    +

    This section extends the Handling Errors and defines extended WebDriver error codes specific for mock sensor in following table.

    @@ -1947,12 +1963,12 @@

    Description

    - -
    no such mock sensor + no such mock sensor 404 no such mock sensor no mock sensor matching the given type was found.
    mock sensor already created + mock sensor already created 500 mock sensor already created command to create a mock sensor could not be satisfied because the given type of mock sensor is already existed. @@ -2256,10 +2272,10 @@

    2. Mock Sensors (2)
  • 2.2. MockSensor dictionary -
  • 3.1.1. Create mock sensor (2) (3) (4) -
  • 3.1.2. Get mock sensor -
  • 3.1.3. Update mock sensor reading -
  • 3.1.4. Delete mock sensor (2) +
  • 3.1.1. Create mock sensor (2) (3) (4) (5) +
  • 3.1.2. Get mock sensor (2) +
  • 3.1.3. Update mock sensor reading (2) +
  • 3.1.4. Delete mock sensor (2) (3) + + +