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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
5 <script>
6 'use strict';
7 promise_test(() => {
8 let iframe_connected = new Promise(resolve => {
9 window.onmessage = messageEvent => {
10 if (messageEvent.data === 'Ready') {
11 let iframe = document.querySelector('iframe');
12 callWithKeyDown(() => {
13 iframe.contentWindow.postMessage('Go', '*');
14 });
15 } else if (messageEvent.data === 'Connected') {
16 resolve();
17 } else {
18 reject();
19 }
20 }
21 });
22
23 return setBluetoothFakeAdapter('HeartRateAdapter')
24 .then(() => {
25 let iframe = document.createElement('iframe');
26 iframe.src = '../../../resources/bluetooth/connect-iframe.html';
27 document.body.appendChild(iframe);
28
29 return iframe_connected
30 .then(() => requestDeviceWithKeyDown(
31 {filters: [{services: ['heart_rate']}]}))
32 .then(device => device.gatt.connect())
33 .then(gatt => gatt.getPrimaryService('heart_rate'))
34 .then(service => service.getCharacteristic('heart_rate_measurement'))
35 .then(characteristic => characteristic.startNotifications())
36 .then(characteristic => new Promise(resolve => {
37 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.
38 characteristic.removeEventListener(
39 'characteristicvaluechanged', event_listener);
40 resolve(characteristic);
41 };
42 characteristic.addEventListener(
43 'characteristicvaluechanged', event_listener);
44 }))
45 .then(characteristic => {
46 characteristic.service.device.gatt.disconnect()
47 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.
48 'characteristicvaluechanged');
49 });
50 });
51 }, 'Characteristic sends notification after disconnection. Should not ' +
52 'fire an event.');
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698