Chromium Code Reviews| 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..920bd6ffe1cd21e6818ff23775f90f0ca80f9f9d |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html |
| @@ -0,0 +1,53 @@ |
| +<!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(() => { |
| + let iframe_connected = new Promise(resolve => { |
| + window.onmessage = messageEvent => { |
| + if (messageEvent.data === 'Ready') { |
| + let iframe = document.querySelector('iframe'); |
| + callWithKeyDown(() => { |
| + iframe.contentWindow.postMessage('Go', '*'); |
| + }); |
| + } else if (messageEvent.data === 'Connected') { |
| + resolve(); |
| + } else { |
| + reject(); |
| + } |
| + } |
| + }); |
| + |
| + return setBluetoothFakeAdapter('HeartRateAdapter') |
| + .then(() => { |
| + let iframe = document.createElement('iframe'); |
| + iframe.src = '../../../resources/bluetooth/connect-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 => { |
| + let event_listener = e => { |
|
Jeffrey Yasskin
2017/01/20 21:29:41
Comment what this is waiting for.
ortuno
2017/01/24 02:38:25
Done.
|
| + characteristic.removeEventListener( |
| + 'characteristicvaluechanged', event_listener); |
| + resolve(characteristic); |
| + }; |
| + characteristic.addEventListener( |
| + 'characteristicvaluechanged', event_listener); |
| + })) |
| + .then(characteristic => { |
| + characteristic.service.device.gatt.disconnect() |
| + return assert_no_events(characteristic, |
|
Jeffrey Yasskin
2017/01/20 21:29:41
Comment why we expect the browser to still receive
ortuno
2017/01/24 02:38:25
Added comment up top and here as well.
|
| + 'characteristicvaluechanged'); |
| + }); |
| + }); |
| +}, 'Characteristic sends notification after disconnection. Should not ' + |
| + 'fire an event.'); |
| +</script> |