Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1783)

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/characteristic/notifications/notification-after-disconnection.html

Issue 2648583004: bluetooth: Stop firing value changed events after gatt disconnects (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698