mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 03:05:34 +00:00
e214eb1ddc
Automatic update from web-platform-testsbluetooth: web: test: Use AllResponsesConsumed This change uses AllResponsesConsumed in the bluetooth Web Platform Tests in order to make sure we have consumed all the anticipatory responses that we've set on our fakes. BUG=569709 Change-Id: I9767792fcd5dda71fabf2f8941638f744aefa2dc Reviewed-on: https://chromium-review.googlesource.com/988422 Commit-Queue: Conley Owens <cco3@chromium.org> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org> Cr-Commit-Position: refs/heads/master@{#548125} wpt-commits: 148f026e5178b0b8d77e8f374671c9c5ff1545bf wpt-pr: 10257 wpt-commits: 148f026e5178b0b8d77e8f374671c9c5ff1545bf wpt-pr: 10257
33 lines
1.2 KiB
HTML
33 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
|
<script>
|
|
'use strict';
|
|
const test_desc = 'If a site disconnects from a device while the platform is ' +
|
|
'disconnecting that device, only one gattserverdisconnected event should ' +
|
|
'fire.';
|
|
let device, fake_peripheral;
|
|
let num_events = 0;
|
|
|
|
bluetooth_test(() => getConnectedHealthThermometerDevice()
|
|
.then(_ => ({device, fake_peripheral} = _))
|
|
// 1. Listen for disconnections.
|
|
.then(() =>
|
|
device.addEventListener('gattserverdisconnected', () => num_events++))
|
|
// 2. Disconnect several times.
|
|
.then(() => Promise.all([
|
|
eventPromise(device, 'gattserverdisconnected'),
|
|
fake_peripheral.simulateGATTDisconnection(),
|
|
device.gatt.disconnect(),
|
|
device.gatt.disconnect(),
|
|
]))
|
|
// 3. Wait to catch disconnect events.
|
|
.then(() => new Promise(resolve => step_timeout(resolve, 50)))
|
|
// 4. Ensure there is exactly 1 disconnection recorded.
|
|
.then(() => assert_equals(num_events, 1)),
|
|
test_desc);
|
|
</script>
|