summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js')
-rw-r--r--testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js b/testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js
new file mode 100644
index 0000000000..ea55b7b495
--- /dev/null
+++ b/testing/web-platform/tests/bluetooth/server/getPrimaryServices/gen-disconnect-discovery-timeout.https.window.js
@@ -0,0 +1,46 @@
+// 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 =
+ 'Calls to getPrimaryServices when device disconnects and discovery' +
+ ' times out should reject promise rather than get stuck.';
+let device;
+
+bluetooth_test(
+ async (t) => {
+ let {device, fake_peripheral} =
+ await getConnectedHealthThermometerDevice({
+ filters: [{services: ['health_thermometer']}],
+ optionalServices: ['generic_access']
+ });
+
+ await fake_peripheral.setNextGATTDiscoveryResponse({
+ code: HCI_CONNECTION_TIMEOUT,
+ });
+ await Promise.all([
+ fake_peripheral.simulateGATTDisconnection({
+ code: HCI_SUCCESS,
+ }),
+ // Using promise_rejects_dom here rather than
+ // assert_promise_rejects_with_message as the race between
+ // simulateGATTDisconnection and getPrimaryServices might end up giving
+ // slightly different exception message (i.e has "Failed to execute ...
+ // on
+ // ... " prefix when disconnected state is reflected on the renderer
+ // side). The point of the test is no matter how race between them, the
+ // promise will be rejected as opposed to get stuck.
+ promise_rejects_dom(t, 'NetworkError', device.gatt.getPrimaryServices()),
+ ]);
+ },
+ test_desc, '',
+ // As specified above there is a race condition between
+ // simulateGATTDisconnection and getPrimaryServices, the artificial
+ // GATTDiscoveryResponse might not be consumed in case
+ // simulateGATTDisconnection happens first. As a result explicitly skip
+ // all response consumed validation at the end of the test.
+ /*validate_response_consumed=*/ false);
+