summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js')
-rw-r--r--testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js b/testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js
new file mode 100644
index 0000000000..bdaf47c661
--- /dev/null
+++ b/testing/web-platform/tests/bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.window.js
@@ -0,0 +1,31 @@
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+// META: script=/bluetooth/resources/bluetooth-test.js
+// META: script=/bluetooth/resources/bluetooth-fake-devices.js
+'use strict';
+const test_desc = 'A device that reconnects during the ' +
+ 'gattserverdisconnected event should still receive ' +
+ 'gattserverdisconnected events after re-connection.';
+
+bluetooth_test(async () => {
+ const {device, fake_peripheral} = await getConnectedHealthThermometerDevice();
+
+ const reconnectPromise = new Promise(async (resolve) => {
+ device.addEventListener('gattserverdisconnected', async () => {
+ // 2. Reconnect.
+ await fake_peripheral.setNextGATTConnectionResponse({
+ code: HCI_SUCCESS,
+ });
+ await device.gatt.connect();
+
+ // 3. Disconnect after reconnecting.
+ const disconnectPromise = eventPromise(device, 'gattserverdisconnected');
+ fake_peripheral.simulateGATTDisconnection();
+ resolve(disconnectPromise);
+ }, {once: true});
+ });
+
+ // 1. Disconnect.
+ await fake_peripheral.simulateGATTDisconnection();
+ await reconnectPromise;
+}, test_desc);