You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.bs
+252-6Lines changed: 252 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,12 @@ spec: html
127
127
spec: webidl
128
128
type: dfn
129
129
text: resolve
130
+
spec: webdriver
131
+
type: dfn
132
+
text: remote end steps
133
+
type: dfn
134
+
text: current browsing context
135
+
130
136
</pre>
131
137
132
138
<style>
@@ -1415,8 +1421,8 @@ steps:
1415
1421
devices, but for now it only ever returns a single one.
1416
1422
</div>
1417
1423
1418
-
1. Let |document| be [=this=]'s [=relevant global object=]'s
1419
-
[=associated Document=].
1424
+
1. Let |global| be the[=relevant global object=] for |storage|.
1425
+
1. Let |document| be |global|'s[=associated Document=].
1420
1426
1. If |document| is not [=allowed to use=] the [=policy-controlled feature=]
1421
1427
named "[=policy-controlled feature/bluetooth=]", throw a {{SecurityError}}
1422
1428
and abort these steps.
@@ -1476,8 +1482,8 @@ steps:
1476
1482
for example because there is no Bluetooth adapter with which to scan, or
1477
1483
because the filters can't be matched by any possible advertising packet, the
1478
1484
UA MAY return `[]` and abort these steps.
1479
-
1. <a>Scan for devices</a> with <var>requiredServiceUUIDs</var> as the <i>set of
1480
-
<a>Service</a> UUIDs</i>, and let <var>scanResult</var> be the result.
1485
+
1. Let |scanResult| be the result of invoking [=scan for devices=] with |global| and
1486
+
|requiredServiceUUIDs|.
1481
1487
1. If |filters| isn't `null`, do the following sub-steps:
1482
1488
1. Remove devices from <var>scanResult</var> if they do
1483
1489
not <a>match a filter</a> in <var>uuidFilters</var>.
@@ -1647,7 +1653,7 @@ returned from the following steps:
1647
1653
</div>
1648
1654
1649
1655
<div algorithm="scanning for Bluetooth devices">
1650
-
To <dfn>scan for devices</dfn> with an optional <var>set of <a>Service</a>
1656
+
To <dfn>scan for devices</dfn> with parameters <var>global</var> and an optional <var>set of <a>Service</a>
1651
1657
UUIDs</var>, defaulting to the set of all UUIDs, the UA MUST perform the
1652
1658
following steps:
1653
1659
1. If the UA has scanned for devices recently with a set of UUIDs that was a
@@ -1658,6 +1664,14 @@ following steps:
1658
1664
1. Let <var>nearbyDevices</var> be a set of <a>Bluetooth device</a>s, initially
1659
1665
equal to the set of devices that are connected (have an <a>ATT Bearer</a>)
1660
1666
to the UA.
1667
+
1. Let |topLevelTraversable| be the |global|'s [=Window/navigable=]'s
1668
+
[=navigable/top-level traversable=].
1669
+
1. Let |simulatedBluetoothDevices| be an empty <a spec="infra">list</a>.
1670
+
1. If |topLevelTraversable| has a [=simulated Bluetooth adapter=], let
1671
+
|simulatedBluetoothDevices| be the result of [=getting the values=] of its [=simulated Bluetooth device mapping=].
1672
+
1673
+
Issue: Support asynchronous device discovery.
1674
+
1661
1675
1. If the UA supports the LE transport, perform the <a>General Discovery
1662
1676
Procedure</a>, except that the UA may include devices that have no
1663
1677
<a>Discoverable Mode</a> flag set, and add the discovered <a>Bluetooth
@@ -1677,7 +1691,7 @@ following steps:
1677
1691
immutable device address.
1678
1692
1. Let <var>result</var> be a set of <a>Bluetooth device</a>s, initially empty.
1679
1693
1. For each <a>Bluetooth device</a><var>device</var> in
1680
-
<var>nearbyDevices</var>, do the following sub-steps:
1694
+
<var>nearbyDevices</var> and <var>simulatedBluetoothDevices</var>, do the following sub-steps:
1681
1695
1. If <var>device</var>'s <a>supported physical transports</a> include LE
1682
1696
and its <a>Bluetooth Device Name</a> is partial or absent, the UA SHOULD
1683
1697
perform the <a>Name Discovery Procedure</a> to acquire a complete name.
@@ -1988,6 +2002,14 @@ steps <a>in parallel</a>:
1988
2002
Note: If the Web Bluetooth permission has been blocked by the user, the UA
1989
2003
may <a>resolve</a> |promise| with `false`.
1990
2004
</div>
2005
+
2006
+
1. Let |simulatedBluetoothAdapter| be [=this=]'s [=Window/navigable=]'s
2007
+
[=navigable/top-level traversable=]'s <a>simulated Bluetooth adapter</a>.
2008
+
1. If |simulatedBluetoothAdapter| is not empty,
2009
+
1. If |simulatedBluetoothAdapter|'s [=adapter state=] is "absent", [=queue a task=] to [=resolve=] |promise| with `false`.
2010
+
1. Otherwise, [=queue a task=] to [=resolve=] |promise| with `true`.
2011
+
1. Abort these steps.
2012
+
1991
2013
1. If the UA is running on a system that has a Bluetooth radio <a>queue a
1992
2014
task</a> to <a>resolve</a> |promise| with `true` regardless of the powered
1993
2015
state of the Bluetooth radio.
@@ -4835,6 +4857,10 @@ if the following steps return `blocked`:
4835
4857
};
4836
4858
</xmp>
4837
4859
4860
+
Each {{Navigator}} has an <dfn>associated `Bluetooth`</dfn>, which is a {{Bluetooth}} object. Upon creation of the {{Navigator}} object, its <a>associated `Bluetooth`</a> must be set to a new {{Bluetooth}} object created in the {{Navigator}} object's [=relevant realm=].
4861
+
4862
+
{{Navigator}}'s <dfn attribute for="Navigator">bluetooth</dfn> getter steps are to return [=this=]'s <a>associated `Bluetooth`</a>.
4863
+
4838
4864
# Integrations # {#integrations}
4839
4865
4840
4866
## Permissions Policy ## {#permissions-policy}
@@ -4850,11 +4876,31 @@ The <a>default allowlist</a> for this feature is <code>["self"]</code>.
4850
4876
4851
4877
For the purposes of user-agent automation and application testing, this document defines extensions to the [[WebDriver-BiDi]] specification.
4852
4878
4879
+
The Web Bluetooth API and its extension specifications 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 document defines a number of WebDriver-BiDi extension commands that allow defining and controlling simulated peripherals and advertisements that behave like physical device peripherals and their advertisements. These simulated peripherals and advertisements represent devices with particular properties and whose readings can be entirely defined by users.
4880
+
4881
+
Each [=navigable/top-level traversable=] may have a <dfn>simulated Bluetooth adapter</dfn>, that is a software defined Bluetooth adapter that has a set of discovered <a>simulated Bluetooth devices</a> and can assume roles like <a>Central</a>.
4882
+
4883
+
Each <a>simulated Bluetooth adapter</a> has a <dfn>simulated Bluetooth device mapping</dfn>, which is an <a>ordered map</a> of Bluetooth address {{strings}} to <a>simulated Bluetooth devices</a>.
4884
+
4885
+
Each <a>simulated Bluetooth adapter</a> has an <dfn>adapter state</dfn> that is a string enumeration describing the current state of the adapter. The possible enumeration values are:
4886
+
* "powered-on"
4887
+
* "powered-off"
4888
+
* "absent"
4889
+
4890
+
A <dfn>simulated Bluetooth device</dfn> is a software defined [=Bluetooth device=] that behaves like a physical device, and may be attached to a <a>simulated Bluetooth adapter</a>, and may have associated properties like <a>Manufacturer Specific Data</a> and <a>Service UUIDs</a>.
4891
+
4853
4892
Issue: CDDL snippetes use the "text" type instead of
4854
4893
"browsingContext.BrowsingContext" to allow indepedent programmatic
4855
4894
processing of CDDL snippets. Currently, other modules cannot be
<div algorithm="remote end steps for bluetooth.simulateAdvertisement">
5211
+
The [=remote end steps=] with command parameters |params| are:
5212
+
5213
+
1. Let |contextId| be params["context"].
5214
+
1. Let |topLevelNavigable| be the result of [=trying=] to [=get a navigable=] with |contextId|.
5215
+
1. If |topLevelNavigable| is not a [=navigable/top-level traversable=], return [=error=] with [=error code=][=invalid argument=].
5216
+
1. Let |scanEntry| be |params|[`"scanEntry"`].
5217
+
1. Let |deviceAddress| be |scanEntry|[`"deviceAddress"`].
5218
+
1. Let |simulatedBluetoothAdapter| be |topLevelNavigable|'s <a>simulated Bluetooth adapter</a>.
5219
+
1. If |simulatedBluetoothAdapter| is empty, return [=error=] with [=error code=][=invalid argument=].
5220
+
1. Let |deviceMapping| be |simulatedBluetoothAdapter|'s <a>simulated Bluetooth device mapping</a>.
5221
+
1. If |deviceMapping|[|deviceAddress|][=map/exists=], let |simulatedDevice| be |deviceMapping|[|deviceAddress|]. Otherwise, let |simulatedDevice| be a new <a>simulated Bluetooth device</a> with |deviceAddress| and set |deviceMapping|[|deviceAddress|] to |simulatedDevice|.
5222
+
1. If |topLevelNavigable| is currently executing the [=scan for devices=] algorithm,
5223
+
insert <var>simulatedDevice</var> into
5224
+
the <em>simulatedBluetoothDevices</em> variable within that algorithm.
5225
+
5226
+
Issue: Inserting data into variables from another algorithm is not well defined. The <a>scan for devices</a> algorithm needs to define asynchronous device discovery in order to match implementations.
5227
+
1. Let |navigables| be the <a>inclusive descendant navigables</a> of |topLevelNavigable|'s <a>active document</a>.
5228
+
1. For each |navigable| of |navigables|:
5229
+
1. Let |document| be |navigable|'s <a>active document</a>.
5230
+
1. <a>Queue a task</a> on |document|'s <a>relevant settings object</a>'s <a>responsible event loop</a> to do the following sub-steps:
5231
+
1. Let |simulatedDeviceInstance| be the result of <a>get the <code>BluetoothDevice</code> representing</a> |simulatedDevice| inside |navigable|'s <a>active window</a>'s <a spec=HTML>associated <code>Navigator</code></a>'s [=associated Bluetooth=].
5232
+
1. If |simulatedDeviceInstance|.{{[[watchAdvertisementsState]]}} is `not-watching`, abort these sub-steps.
5233
+
1. <a>Fire an `advertisementreceived` event</a> for the advertising event represented by |scanEntry|[`"scanRecord"`], at |simulatedDeviceInstance|.
5234
+
1. Return [=success=] with data `null`.
5235
+
5236
+
</div>
5237
+
5238
+
<div class="example">
5239
+
A [=local end=] could simulate a device advertisement by sending the following message:
0 commit comments