| Index: third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html
|
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html b/third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..591596af9b133c26c4d8db53edb4a9ed0f3ed970
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html
|
| @@ -0,0 +1,63 @@
|
| +<!DOCTYPE html>
|
| +<script src="../../../resources/testharness.js"></script>
|
| +<script src="../../../resources/testharnessreport.js"></script>
|
| +<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
|
| +<script>
|
| +'use strict';
|
| +promise_test(() => {
|
| + // The iframe we create will subscribe to notifications and will ensure
|
| + // that the browser keeps receiving notifications even after this frame's
|
| + // device disconnects.
|
| + let iframe_connected = new Promise(resolve => {
|
| + window.onmessage = messageEvent => {
|
| + if (messageEvent.data === 'Ready') {
|
| + let iframe = document.querySelector('iframe');
|
| + callWithKeyDown(() => {
|
| + iframe.contentWindow.postMessage('RequestAndConnect', '*');
|
| + });
|
| + } else if (messageEvent.data === 'Connected') {
|
| + let iframe = document.querySelector('iframe');
|
| + iframe.contentWindow.postMessage('StartNotifications', '*');
|
| + } else if (messageEvent.data === 'NotificationsStarted') {
|
| + resolve();
|
| + } else {
|
| + reject();
|
| + }
|
| + }
|
| + });
|
| +
|
| + return setBluetoothFakeAdapter('HeartRateAdapter')
|
| + .then(() => {
|
| + let iframe = document.createElement('iframe');
|
| + iframe.src = '../../../resources/bluetooth/heart-rate-iframe.html';
|
| + document.body.appendChild(iframe);
|
| +
|
| + return iframe_connected
|
| + .then(() => requestDeviceWithKeyDown(
|
| + {filters: [{services: ['heart_rate']}]}))
|
| + .then(device => device.gatt.connect())
|
| + .then(gatt => gatt.getPrimaryService('heart_rate'))
|
| + .then(service => service.getCharacteristic('heart_rate_measurement'))
|
| + .then(characteristic => characteristic.startNotifications())
|
| + .then(characteristic => new Promise(resolve => {
|
| + // Make sure we are receiving events.
|
| + let event_listener = e => {
|
| + characteristic.removeEventListener(
|
| + 'characteristicvaluechanged', event_listener);
|
| + resolve(characteristic);
|
| + };
|
| + characteristic.addEventListener(
|
| + 'characteristicvaluechanged', event_listener);
|
| + }))
|
| + .then(characteristic => {
|
| + characteristic.service.device.gatt.disconnect()
|
| + // The browser still receives notifications because of the iframe but
|
| + // no events should be dispatched on this characteristic because
|
| + // the characteristic's device disconnected.
|
| + return assert_no_events(characteristic,
|
| + 'characteristicvaluechanged');
|
| + });
|
| + });
|
| +}, 'Characteristic sends notification after disconnection. Should not ' +
|
| + 'fire an event.');
|
| +</script>
|
|
|