diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js')
-rw-r--r-- | testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js b/testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js new file mode 100644 index 0000000000..8b3ba7cc6b --- /dev/null +++ b/testing/web-platform/tests/bluetooth/service/getCharacteristics/gen-reconnect-during.https.window.js @@ -0,0 +1,39 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/common/gc.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py +'use strict'; +const test_desc = 'disconnect() and connect() called during ' + + 'getCharacteristics. Reject with NetworkError.'; +const expected = new DOMException( + 'GATT Server is disconnected. Cannot retrieve characteristics. ' + + '(Re)connect first with `device.gatt.connect`.', + 'NetworkError'); +let device; + +bluetooth_test(() => getHealthThermometerDeviceWithServicesDiscovered({ + filters: [{services: [health_thermometer.name]}], +}) + .then(_ => ({device} = _)) + .then(() => device.gatt.getPrimaryService(health_thermometer.name)) + .then(service => Promise.all([ + // 1. Make a call to service.getCharacteristics, while the service is still + // valid. + assert_promise_rejects_with_message(service.getCharacteristics(), expected), + + // 2. disconnect() and connect before the initial call completes. + // This is accomplished by making the calls without waiting for the + // earlier promises to resolve. + // connect() guarantees on OS-level connection, but disconnect() + // only disconnects the current instance. + // getHealthThermometerDeviceWithServicesDiscovered holds another + // connection in an iframe, so disconnect() and connect() are certain to + // reconnect. However, disconnect() will invalidate the service object so + // the subsequent calls made to it will fail, even after reconnecting. + device.gatt.disconnect(), + device.gatt.connect() + ])), + test_desc); + |