data: [=contributing
- factors=] obtained from the underlying hardware or operating system.
+ factors=] obtained from the underlying hardware or operating system or,
+ in the case of a [=virtual pressure source=], a {{PressureState}}.
timestamp: the
@@ -307,6 +308,12 @@
Sampling and Reporting Rate
For this specification's purposes, [=platform collectors=] are scoped to a
[=global object=] via the [=platform collector mapping=].
+
+ For automation purposes, a [=platform collector=] must have the ability to
+ connect to [=virtual pressure sources=] and use their simulated [=pressure
+ source sample/data=] as [=pressure states=] rather than raw platform data
+ that must be transformed into an [=adjusted pressure state=].
+
As collecting telemetry data often means polling hardware counters, it is not a free operation and thus,
it should not happen if there are no one observing the data. See [[[#life-cycle]]] for more information.
@@ -670,13 +677,43 @@
The observe() method
[=platform collector/associated pressure source=] is null.
- Let |pressureSource| be an [=implementation-defined=]
- [=pressure source=] that provides telemetry data about
- |source|, or null if none exists.
+ Let |virtualPressureSource:virtual pressure source or null|
+ be the result of invoking [=get a virtual pressure source=]
+ with |source| and |relevantGlobal|.
- Set |newCollector|'s [=platform collector/associated pressure
- source=] to |pressureSource|.
+ If |virtualPressureSource| is not null:
+
+
+ If |virtualPressureSource|'s [=virtual pressure
+ source/can provide samples=] is true:
+
+
+ Set |newCollector|'s [=platform collector/associated
+ pressure source=] to |virtualPressureSource|.
+
+ Let |realPressureSource| be an [=implementation-defined=]
+ [=pressure source=] that provides telemetry data about
+ |source|, or null if none exists.
+
+
+ Set |newCollector|'s [=platform collector/associated
+ pressure source=] to |realPressureSource|.
+
+
If |newCollector|'s [=platform collector/associated
@@ -1203,6 +1240,59 @@
Supporting algorithms
+
+ To get a virtual pressure source, given a [=source type=]
+ |source| and |relevantGlobal|, perform the following steps. They return a
+ [=virtual pressure source=] or null.
+
+
Let |topLevelTraversable| be null.
+
+ If |relevantGlobal| is a {{Window}} object:
+
+
+ Set |topLevelTraversable| to |relevantGlobal|'s [=Window/navigable=]'s [=top-level traversable=].
+
+
+
+
+ If |relevantGlobal| is a {{DedicatedWorkerGlobalScope}} object:
+
+
+ Let |owningDocuments| be |relevantGlobal|'s [=owning document set=].
+
+
+ If |owningDocuments| is [=set/empty=], return null.
+
+
+ [=Assert=]: |owningDocuments|'s [=set/size=] is 1.
+
+
+ Set |topLevelTraversable| to |owningDocuments|[0]'s [=node navigable=]'s [=top-level traversable=].
+
+
+
+
+ If |topLevelTraversable| is null, return null.
+
+
+ Let |topLevelVirtualPressureSourceMapping| be the |topLevelTraversable|'s [=virtual pressure source mapping=].
+
+
+ Let |virtualPressureSource| be null.
+
+
+ If |topLevelVirtualPressureSourceMapping| [=map/contains=] |source|:
+
+
+ Set |virtualPressureSource| to |topLevelVirtualPressureSourceMapping|[|source|].
+
+
+
+
+ Return |virtualPressureSource|.
+
+
+
Data Collection and Delivery
@@ -1265,7 +1355,18 @@
Data Collection and Delivery
Set |platformCollector|'s [=platform collector/activated=] to false.
- Perform any [=implementation-defined=] steps to signal to
+ If |platformCollector|'s [=platform collector/associated pressure
+ source=] is a [=virtual pressure source=]:
+
+
+ [=set/Remove=] |platformCollector| from its [=platform
+ collector/associated pressure source=]'s [=virtual pressure
+ source/connected platform collectors=].
+
+
+
+
+ Otherwise, perform any [=implementation-defined=] steps to signal to
|platformCollector|'s [=platform collector/associated pressure source=]
to stop retrieving telemetry data.
@@ -1288,17 +1389,33 @@
Data Collection and Delivery
If |sample| is null, abort these steps.
- Let |state| be an [=adjusted pressure state=] calculated from
- |source| and |sample|'s [=pressure source sample/data=].
-
+ Let |state:PressureState| be null.
+
+
+ If |pressureSource| is a [=virtual pressure source=]:
+
+
+ Set |state| to |sample|'s [=pressure source sample/data=].
+
+
+
+
+ Otherwise:
+
+
+ Set |state| to an [=adjusted pressure state=] calculated from
+ |source| and |sample|'s [=pressure source sample/data=].
+
+
+
[=Assert=]: |state| is not null.
@@ -1824,6 +1941,374 @@
+
+
+ Automation
+
+
+ The Compute Pressure API poses a challenge to test authors, as fully
+ exercising interface requires physical hardware devices that respond in
+ predictable ways.
+
+
+ To address this challenge this document defines a [[!WEBDRIVER2]] [=extension
+ commands=] that allows defining and controlling virtual pressure sources that behave
+ like real ones and which can have particular properties and whose readings can be
+ entirely defined by users.
+
+
+ Virtual Pressure Source
+
+
+ A virtual pressure source is a [=pressure source=] that
+ simulates the behavior of a real one in controlled ways. It reports
+ pressure changes to zero or more [=platform collectors=] connected to it.
+
+
+ Contrary to a real [=pressure source=], however, it reports [=pressure
+ state=] values directly instead of [=implementation-defined=] values that
+ must be processed into [=pressure states=] by a [=platform collector=]. In
+ other words, a [=virtual pressure source=]'s [=pressure source sample=]'s
+ [=pressure source sample/data=] is a {{PressureState}}.
+
+
+ In addition to the data associated with all [=pressure sources=] (such as
+ [=pressure source sample=]), each [=virtual pressure source=] has:
+
+
+ a can provide samples
+ boolean.
+
+
+ a connected platform
+ collectors [=set=] of [=platform collectors=].
+
+
+
+
+ Each [=top-level traversable=] has a virtual pressure source mapping, which is an [=ordered map=] of
+ [=source types=] to [=virtual pressure source=].
+
+
+
+
+ Extension Commands
+
+
+ Create virtual pressure source
+
+
+
+
+ HTTP Method
+
+
+ [=extension command URI Template|URI Template=]
+
+
+
+
+ POST
+
+
+ /session/{session id}/pressuresource
+
+
+
+
+ This [=extension command=] creates a new [=virtual pressure source=] of a specified
+ [=source type=]. Calls to {{PressureObserver/observe()}} from {{PressureObserver}} instances
+ of the same [=source type=] will cause this [=virtual pressure source=] to be used as their
+ backing [=pressure source=] until [[[#delete-virtual-pressure-source]]] is run.
+
+
+
+ Properties of the parameters argument used by this algorithm
+
+
+
+ Parameter name
+
+
+ Value type
+
+
+ Required
+
+
+
+
+ type
+
+
+ String
+
+
+ yes
+
+
+
+
+ supported
+
+
+ Boolean
+
+
+ no
+
+
+
+
+ The [=remote end steps=] given |session|, |URL variables| and |parameters| are:
+
+
+
+ Let |virtualPressureSourceType| be the result of invoking
+ get a property "type" from |parameters|.
+
+
+ If the [=user agent=]'s [=supported source types=] does not
+ [=list/contain=] |virtualPressureSourceType|, return [=error=] with
+ [=error code|WebDriver error code=] [=invalid argument=].
+
+
+ Let |topLevelTraversable| be the current browsing
+ context's [=browsing context/top-level traversable=].
+
+
+ Let |topLevelVirtualPressureSourceMapping| be the |topLevelTraversable|'s [=virtual pressure source mapping=].
+
+
+ If |topLevelVirtualPressureSourceMapping| contains |virtualPressureSourceType|, return [=error=] with
+ [=error code|WebDriver error code=] [=invalid argument=].
+
+
+ Let |supported| be the result of invoking get a
+ property with default
+ with "supported" and true from |parameters|.
+
+
+ Let |virtualPressureSource| be a new [=virtual pressure source=].
+
+
+ Set |virtualPressureSource|'s [=virtual pressure source/can provide
+ samples=] to |supported|.
+
+
+ Set |topLevelVirtualPressureSourceMapping|[|virtualPressureSourceType|] to |virtualPressureSource|.
+
+
+ Return [=success=] with data null.
+
+
+
+ Delete virtual pressure source
+
+
+
+
+ HTTP Method
+
+
+ [=extension command URI Template|URI Template=]
+
+
+
+
+ DELETE
+
+
+ /session/{session id}/pressuresource/{type}
+
+
+
+
+ This [=extension command=] deletes a given [=virtual pressure source=], meaning that,
+ if available, data for the given [=source type=] will be delivered the regular way, by non-virtual means.
+
+
+ The [=remote end steps=] given |session|, |URL variables| and |parameters| are:
+
+
+
+ Let |virtualPressureSourceType| be the value of the |URL variables|["type"].
+
+
+ If the [=user agent=]'s [=supported source types=] does not
+ [=list/contain=] |virtualPressureSourceType|, return [=error=] with
+ [=error code|WebDriver error code=] [=invalid argument=].
+
+
+ Let |topLevelTraversable| be the current browsing
+ context's [=browsing context/top-level traversable=].
+
+
+ Let |topLevelVirtualPressureSourceMapping| be the |topLevelTraversable|'s [=virtual pressure source mapping=].
+
+
+ Let |pressureSource| be |topLevelVirtualPressureSourceMapping|[|virtualPressureSourceType|].
+
+ [=extension command URI Template|URI Template=]
+
+
+
+
+ POST
+
+
+ /session/{session id}/pressuresource/{type}
+
+
+
+
+ This [=extension command=] allows updating the state of a [=virtual pressure source=] by pushing
+ a new [=pressure source sample=].
+
+
+
+
+ Properties of the parameters argument used by this algorithm
+
+
+
+ Parameter name
+
+
+ Value type
+
+
+ Required
+
+
+
+
+ sample
+
+
+ {{PressureState}}
+
+
+ yes
+
+
+
+
+ The [=remote end steps=] given |session|, |URL variables| and |parameters| are:
+
+
+
+ Let |virtualPressureSourceType| be the value of the |URL variables|["type"].
+
+
+ If the [=user agent=]'s [=supported source types=] does not
+ [=list/contain=] |virtualPressureSourceType|, return [=error=] with
+ [=error code|WebDriver error code=] [=invalid argument=].
+
+
+ Let |topLevelTraversable| be the current browsing
+ context's [=browsing context/top-level traversable=].
+
+
+ Let |topLevelVirtualPressureSourceMapping| be the |topLevelTraversable|'s [=virtual pressure source mapping=].
+
+
+ If |topLevelVirtualPressureSourceMapping| does not [=map/contain=] |virtualPressureSource|,
+ return [=error=] with [=error code|WebDriver error code=]
+ unsupported operation.
+
+
+ Let |virtualPressureSource| be |topLevelVirtualPressureSourceMapping|[|virtualPressureSourceType|].
+
+
+ Let |sample| be the result of invoking
+ get a property "sample" from |parameters|.
+
+
+ If |sample| is not of type {{PressureState}}, return [=error=] with [=error code|WebDriver error code=] [=invalid argument=].
+
+
+ Set |virtualPressureSource|'s [=pressure source/latest sample=] to a new
+ [=pressure source sample=] whose [=pressure source sample/data=] is
+ |sample| and [=pressure source sample/timestamp=] is the [=unsafe shared
+ current time=].
+
+
+ In an [=implementation-defined=] way, make |virtualPressureSource|'s
+ [=pressure source/latest sample=] available to |virtualPressureSource|'s
+ [=virtual pressure source/connected platform collectors=].
+