|
82 | 82 | * `bluetooth <https://webbluetoothcg.github.io/web-bluetooth>`_ module. |
83 | 83 | */ |
84 | 84 | bluetooth: { |
| 85 | + /** |
| 86 | + * Handle a bluetooth device prompt with the given params. Matches the |
| 87 | + * `bluetooth.handleRequestDevicePrompt |
| 88 | + * <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-handlerequestdeviceprompt-command>`_ |
| 89 | + * WebDriver BiDi command. |
| 90 | + * |
| 91 | + * @example |
| 92 | + * await test_driver.bidi.bluetooth.handleRequestDevicePrompt({ |
| 93 | + * prompt: "pmt-e0a234b", |
| 94 | + * accept: true, |
| 95 | + * device: "dvc-9b3b872" |
| 96 | + * }); |
| 97 | + * |
| 98 | + * @param {object} params - Parameters for the command. |
| 99 | + * @param {string} params.prompt - The id of a bluetooth device prompt. |
| 100 | + * Matches the |
| 101 | + * `bluetooth.HandleRequestDevicePromptParameters:prompt <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-handlerequestdeviceprompt-command>`_ |
| 102 | + * value. |
| 103 | + * @param {bool} params.accept - Whether to accept a bluetooth device prompt. |
| 104 | + * Matches the |
| 105 | + * `bluetooth.HandleRequestDevicePromptAcceptParameters:accept <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-handlerequestdeviceprompt-command>`_ |
| 106 | + * value. |
| 107 | + * @param {string} params.device - The device id from a bluetooth device |
| 108 | + * prompt to be accepted. Matches the |
| 109 | + * `bluetooth.HandleRequestDevicePromptAcceptParameters:device <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-handlerequestdeviceprompt-command>`_ |
| 110 | + * value. |
| 111 | + * @param {Context} [params.context] The optional context parameter specifies in |
| 112 | + * which browsing context the bluetooth device prompt should be handled. If not |
| 113 | + * provided, the current browsing context is used. |
| 114 | + * @returns {Promise} fulfilled after the bluetooth device prompt |
| 115 | + * is handled, or rejected if the operation fails. |
| 116 | + */ |
| 117 | + handle_request_device_prompt: function(params) { |
| 118 | + return window.test_driver_internal.bidi.bluetooth |
| 119 | + .handle_request_device_prompt(params); |
| 120 | + }, |
85 | 121 | /** |
86 | 122 | * Creates a simulated bluetooth adapter with the given params. Matches the |
87 | 123 | * `bluetooth.simulateAdapter <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateAdapter-command>`_ |
|
105 | 141 | */ |
106 | 142 | simulate_adapter: function (params) { |
107 | 143 | return window.test_driver_internal.bidi.bluetooth.simulate_adapter(params); |
| 144 | + }, |
| 145 | + /** |
| 146 | + * Creates a simulated bluetooth peripheral with the given params. |
| 147 | + * Matches the |
| 148 | + * `bluetooth.simulatePreconnectedPeripheral <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command>`_ |
| 149 | + * WebDriver BiDi command. |
| 150 | + * |
| 151 | + * @example |
| 152 | + * await test_driver.bidi.bluetooth.simulatePreconnectedPeripheral({ |
| 153 | + * "address": "09:09:09:09:09:09", |
| 154 | + * "name": "Some Device", |
| 155 | + * "manufacturerData": [{key: 17, data: "AP8BAX8="}], |
| 156 | + * "knownServiceUuids": [ |
| 157 | + * "12345678-1234-5678-9abc-def123456789", |
| 158 | + * ], |
| 159 | + * }); |
| 160 | + * |
| 161 | + * @param {object} params - Parameters for the command. |
| 162 | + * @param {string} params.address - The address of the simulated |
| 163 | + * bluetooth peripheral. Matches the |
| 164 | + * `bluetooth.SimulatePreconnectedPeripheralParameters:address <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command>`_ |
| 165 | + * value. |
| 166 | + * @param {string} params.name - The name of the simulated bluetooth |
| 167 | + * peripheral. Matches the |
| 168 | + * `bluetooth.SimulatePreconnectedPeripheralParameters:name <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command>`_ |
| 169 | + * value. |
| 170 | + * @param {Array.ManufacturerData} params.manufacturerData - The manufacturerData of the |
| 171 | + * simulated bluetooth peripheral. Matches the |
| 172 | + * `bluetooth.SimulatePreconnectedPeripheralParameters:manufacturerData <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command>`_ |
| 173 | + * value. |
| 174 | + * @param {string} params.knownServiceUuids - The knownServiceUuids of |
| 175 | + * the simulated bluetooth peripheral. Matches the |
| 176 | + * `bluetooth.SimulatePreconnectedPeripheralParameters:knownServiceUuids <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command>`_ |
| 177 | + * value. |
| 178 | + * @param {Context} [params.context] The optional context parameter |
| 179 | + * specifies in which browsing context the simulated bluetooth peripheral should be |
| 180 | + * set. If not provided, the current browsing context is used. |
| 181 | + * @returns {Promise} fulfilled after the simulated bluetooth peripheral is created |
| 182 | + * and set, or rejected if the operation fails. |
| 183 | + */ |
| 184 | + simulate_preconnected_peripheral: function(params) { |
| 185 | + return window.test_driver_internal.bidi.bluetooth |
| 186 | + .simulate_preconnected_peripheral(params); |
| 187 | + }, |
| 188 | + /** |
| 189 | + * `bluetooth.RequestDevicePromptUpdatedParameters <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-requestdevicepromptupdated-event>`_ |
| 190 | + * event. |
| 191 | + */ |
| 192 | + request_device_prompt_updated: { |
| 193 | + /** |
| 194 | + * @typedef {object} RequestDevicePromptUpdated |
| 195 | + * `bluetooth.RequestDevicePromptUpdatedParameters <https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-requestdevicepromptupdated-event>`_ |
| 196 | + * event. |
| 197 | + */ |
| 198 | + |
| 199 | + /** |
| 200 | + * Subscribes to the event. Events will be emitted only if |
| 201 | + * there is a subscription for the event. This method does |
| 202 | + * not add actual listeners. To listen to the event, use the |
| 203 | + * `on` or `once` methods. The buffered events will be |
| 204 | + * emitted before the command promise is resolved. |
| 205 | + * |
| 206 | + * @param {object} [params] Parameters for the subscription. |
| 207 | + * @param {null|Array.<(Context)>} [params.contexts] The |
| 208 | + * optional contexts parameter specifies which browsing |
| 209 | + * contexts to subscribe to the event on. It should be |
| 210 | + * either an array of Context objects, or null. If null, the |
| 211 | + * event will be subscribed to globally. If omitted, the |
| 212 | + * event will be subscribed to on the current browsing |
| 213 | + * context. |
| 214 | + * @returns {Promise<void>} Resolves when the subscription |
| 215 | + * is successfully done. |
| 216 | + */ |
| 217 | + subscribe: async function(params = {}) { |
| 218 | + assertBidiIsEnabled(); |
| 219 | + return window.test_driver_internal.bidi.bluetooth |
| 220 | + .request_device_prompt_updated.subscribe(params); |
| 221 | + }, |
| 222 | + /** |
| 223 | + * Adds an event listener for the event. |
| 224 | + * |
| 225 | + * @param {function(RequestDevicePromptUpdated): void} callback The |
| 226 | + * callback to be called when the event is emitted. The |
| 227 | + * callback is called with the event object as a parameter. |
| 228 | + * @returns {function(): void} A function that removes the |
| 229 | + * added event listener when called. |
| 230 | + */ |
| 231 | + on: function(callback) { |
| 232 | + assertBidiIsEnabled(); |
| 233 | + return window.test_driver_internal.bidi.bluetooth |
| 234 | + .request_device_prompt_updated.on(callback); |
| 235 | + }, |
| 236 | + /** |
| 237 | + * Adds an event listener for the event that is only called |
| 238 | + * once and removed afterward. |
| 239 | + * |
| 240 | + * @return {Promise<RequestDevicePromptUpdated>} The promise which |
| 241 | + * is resolved with the event object when the event is emitted. |
| 242 | + */ |
| 243 | + once: function() { |
| 244 | + assertBidiIsEnabled(); |
| 245 | + return new Promise(resolve => { |
| 246 | + const remove_handler = |
| 247 | + window.test_driver_internal.bidi.bluetooth |
| 248 | + .request_device_prompt_updated.on(event => { |
| 249 | + resolve(event); |
| 250 | + remove_handler(); |
| 251 | + }); |
| 252 | + }); |
| 253 | + }, |
108 | 254 | } |
109 | 255 | }, |
110 | 256 | /** |
|
1340 | 1486 |
|
1341 | 1487 | bidi: { |
1342 | 1488 | bluetooth: { |
| 1489 | + handle_request_device_prompt: function() { |
| 1490 | + throw new Error( |
| 1491 | + 'bidi.bluetooth.handle_request_device_prompt is not implemented by testdriver-vendor.js'); |
| 1492 | + }, |
1343 | 1493 | simulate_adapter: function () { |
1344 | 1494 | throw new Error( |
1345 | 1495 | "bidi.bluetooth.simulate_adapter is not implemented by testdriver-vendor.js"); |
| 1496 | + }, |
| 1497 | + simulate_preconnected_peripheral: function() { |
| 1498 | + throw new Error( |
| 1499 | + 'bidi.bluetooth.simulate_preconnected_peripheral is not implemented by testdriver-vendor.js'); |
| 1500 | + }, |
| 1501 | + request_device_prompt_updated: { |
| 1502 | + async subscribe() { |
| 1503 | + throw new Error( |
| 1504 | + 'bidi.bluetooth.request_device_prompt_updated.subscribe is not implemented by testdriver-vendor.js'); |
| 1505 | + }, |
| 1506 | + on() { |
| 1507 | + throw new Error( |
| 1508 | + 'bidi.bluetooth.request_device_prompt_updated.on is not implemented by testdriver-vendor.js'); |
| 1509 | + } |
1346 | 1510 | } |
1347 | 1511 | }, |
1348 | 1512 | log: { |
|
0 commit comments