From fd1f0d337866bb884235a41abd888ddb2daee33b Mon Sep 17 00:00:00 2001 From: Juha Vainio Date: Wed, 25 Oct 2023 10:01:27 +0300 Subject: [PATCH 1/2] Rewrite Automation section after w3c/sensors#470 The Automation section in the Generic Sensor API specification was rewritten and several terms and concepts have changed. This commit adapts the Geolocation Sensor spec to the changes: * Remove references to "mock sensor type", "mock sensor reading values" and the "MockSensorType" enum. * Define an entry in the per-type virtual sensor metadata map whose key is what used to be the "geolocation" entry in MockSensorType and an appropriate virtual sensor metadata entry. This is enough to integrate properly with the Generic Sensor spec and allow Geolocation virtual sensors to be created and used. Fixes #55. --- index.bs | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/index.bs b/index.bs index f59776e..e080e92 100644 --- a/index.bs +++ b/index.bs @@ -44,9 +44,6 @@ urlPrefix: https://w3c.github.io/sensors; spec: GENERIC-SENSOR text: security and privacy; url: security-and-privacy text: extensible; url: extensibility text: check sensor policy-controlled features; url: check-sensor-policy-controlled-features - text: automation - text: mock sensor type - text: mock sensor reading values urlPrefix: https://dom.spec.whatwg.org; spec: DOM type: dfn text: add the following abort steps; url: abortsignal-add @@ -318,27 +315,29 @@ Abstract Operations {#abstract-operations} Automation {#automation} ========== -This section extends the [=automation=] section defined in the Generic Sensor API [[GENERIC-SENSOR]] -to provide mocking information about the [=geolocation=] of the hosting device for the purposes of -testing a user agent's implementation of {{GeolocationSensor}} API. -

Mock Sensor Type

+This section extends [[GENERIC-SENSOR#automation]] by providing [=Geolocation Sensor=]-specific virtual sensor metadata. -The {{GeolocationSensor}} class has an associated [=mock sensor type=] which is -"geolocation", its [=mock sensor reading values=] -dictionary is defined as follows: +The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/entry=]: +: [=map/key=] +:: "`geolocation`" +: [=map/value=] +:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Geolocation Sensor=] and [=reading parsing algorithm=] is [=geolocation reading parsing algorithm=]. -
-  dictionary GeolocationReadingValues {
-    required double? latitude;
-    required double? longitude;
-    required double? altitude;
-    required double? accuracy;
-    required double? altitudeAccuracy;
-    required double? heading;
-    required double? speed;
-  };
-
+

Geolocation reading parsing algorithm

+
+ : input + :: |parameters|, a JSON {{Object}} + : output + :: A [=sensor reading=] or **undefined** + + 1. Let |reading| be a new [=sensor reading=]. + 1. Let |value| be a new [=sensor reading=]. + 1. [=map/For each=] |key| in latest geolocation reading → let |value| be the result of [=parse single-value number reading=] with |parameters| and |key|. + 1. If |value| is "undefined". + 1. Return "undefined". + 1. [=map/Set=] |reading|[|key|] to |value|. + 1. Return |reading|. Use Cases {#use-cases} ========= From c80e90090f305f6b5d701c9cee73648487ac8181 Mon Sep 17 00:00:00 2001 From: Juha Vainio Date: Thu, 26 Oct 2023 10:51:07 +0300 Subject: [PATCH 2/2] Fix tag issue. Remove not needed definition in code. Change map to list mode. Added closing tag for
. Typo fixes. Defined list for geolocation parameters. Changed handling of items to use list. --- index.bs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.bs b/index.bs index e080e92..884eac9 100644 --- a/index.bs +++ b/index.bs @@ -322,7 +322,7 @@ The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/e : [=map/key=] :: "`geolocation`" : [=map/value=] -:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Geolocation Sensor=] and [=reading parsing algorithm=] is [=geolocation reading parsing algorithm=]. +:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Geolocation Sensor=] and [=reading parsing algorithm=] is the [=geolocation reading parsing algorithm=].

Geolocation reading parsing algorithm

@@ -332,12 +332,14 @@ The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/e :: A [=sensor reading=] or **undefined** 1. Let |reading| be a new [=sensor reading=]. - 1. Let |value| be a new [=sensor reading=]. - 1. [=map/For each=] |key| in latest geolocation reading → let |value| be the result of [=parse single-value number reading=] with |parameters| and |key|. - 1. If |value| is "undefined". - 1. Return "undefined". - 1. [=map/Set=] |reading|[|key|] to |value|. + 1. Let |keys| be the [=/list=] « "`latitude`", "`longitude`", "`altitude`", "`accuracy`", "`altitudeAccuracy`", "`heading`", "`speed`" ». + 1. [=list/For each=] |key| of |keys| + 1. Let |value| be the result of invoking [=parse single-value number reading=] with |parameters| and |key|. + 1. If |value| is **undefined**. + 1. Return **undefined**. + 1. [=map/Set=] |reading|[|key|] to |value|[|key|]. 1. Return |reading|. +
Use Cases {#use-cases} =========