mirror of
https://github.com/servo/servo.git
synced 2025-09-02 11:08:22 +01:00
Update web-platform-tests to revision 0fe9f012a8ee5503b728a379705a6c5286ba1e96
This commit is contained in:
parent
8329a45163
commit
5dc1649544
69 changed files with 1716 additions and 112 deletions
|
@ -0,0 +1,19 @@
|
|||
<!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 = 'A device disconnecting while connected should fire the ' +
|
||||
'gattserverdisconnected event.';
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice()
|
||||
.then(({device, fake_peripheral}) => {
|
||||
fake_peripheral.simulateGATTDisconnection();
|
||||
return eventPromise(device, 'gattserverdisconnected');
|
||||
})
|
||||
.then(e => assert_true(e.bubbles)),
|
||||
test_desc);
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
<!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 = 'A device disconnecting after the BluetoothDevice object ' +
|
||||
'has been GC\'ed should not access freed memory.';
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice()
|
||||
.then(({fake_peripheral}) => {
|
||||
// 1. Disconnect.
|
||||
fake_peripheral.simulateGATTDisconnection();
|
||||
// 2. Run garbage collection.
|
||||
fake_peripheral = undefined;
|
||||
runGarbageCollection();
|
||||
})
|
||||
// 3. Wait 50ms after the GC runs for the disconnection event to come back.
|
||||
// There's nothing to assert other than that only valid memory is used.
|
||||
.then(() => new Promise(resolve => step_timeout(resolve, 50))),
|
||||
test_desc);
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
<!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(() => getHealthThermometerDevice()
|
||||
.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>
|
|
@ -0,0 +1,34 @@
|
|||
<!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';
|
||||
let test_desc = 'A device that reconnects during the gattserverdisconnected ' +
|
||||
'event should still receive gattserverdisconnected events after ' +
|
||||
're-connection.';
|
||||
let device, fake_peripheral;
|
||||
bluetooth_test(() => getHealthThermometerDevice()
|
||||
.then(_ => ({device, fake_peripheral} = _))
|
||||
// 1. Disconnect.
|
||||
.then(() => new Promise(resolve => {
|
||||
fake_peripheral.simulateGATTDisconnection();
|
||||
device.addEventListener(
|
||||
'gattserverdisconnected', function onDisconnected() {
|
||||
device.removeEventListener('gattserverdisconnected', onDisconnected);
|
||||
// 2. Reconnect.
|
||||
fake_peripheral.setNextGATTConnectionResponse({
|
||||
code: HCI_SUCCESS,
|
||||
})
|
||||
.then(() => device.gatt.connect())
|
||||
.then(() => resolve());
|
||||
});
|
||||
}))
|
||||
// 3. Disconnect after reconnecting.
|
||||
.then(() => {
|
||||
fake_peripheral.simulateGATTDisconnection();
|
||||
return eventPromise(device, 'gattserverdisconnected')
|
||||
}), test_desc);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue