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

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: Make iframe subscribe to notifications and add comments. Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/server/disconnect/detach-gc.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The iframe we create will subscribe to notifications and will ensure
9 // that the browser keeps receiving notifications even after this frame's
10 // device disconnects.
11 let iframe_connected = new Promise(resolve => {
12 window.onmessage = messageEvent => {
13 if (messageEvent.data === 'Ready') {
14 let iframe = document.querySelector('iframe');
15 callWithKeyDown(() => {
16 iframe.contentWindow.postMessage('RequestAndConnect', '*');
17 });
18 } else if (messageEvent.data === 'Connected') {
19 let iframe = document.querySelector('iframe');
20 iframe.contentWindow.postMessage('StartNotifications', '*');
21 } else if (messageEvent.data === 'NotificationsStarted') {
22 resolve();
23 } else {
24 reject();
25 }
26 }
27 });
28
29 return setBluetoothFakeAdapter('HeartRateAdapter')
30 .then(() => {
31 let iframe = document.createElement('iframe');
32 iframe.src = '../../../resources/bluetooth/heart-rate-iframe.html';
33 document.body.appendChild(iframe);
34
35 return iframe_connected
36 .then(() => requestDeviceWithKeyDown(
37 {filters: [{services: ['heart_rate']}]}))
38 .then(device => device.gatt.connect())
39 .then(gatt => gatt.getPrimaryService('heart_rate'))
40 .then(service => service.getCharacteristic('heart_rate_measurement'))
41 .then(characteristic => characteristic.startNotifications())
42 .then(characteristic => new Promise(resolve => {
43 // Make sure we are receiving events.
44 let event_listener = e => {
45 characteristic.removeEventListener(
46 'characteristicvaluechanged', event_listener);
47 resolve(characteristic);
48 };
49 characteristic.addEventListener(
50 'characteristicvaluechanged', event_listener);
51 }))
52 .then(characteristic => {
53 characteristic.service.device.gatt.disconnect()
54 // The browser still receives notifications because of the iframe but
55 // no events should be dispatched on this characteristic because
56 // the characteristic's device disconnected.
57 return assert_no_events(characteristic,
58 'characteristicvaluechanged');
59 });
60 });
61 }, 'Characteristic sends notification after disconnection. Should not ' +
62 'fire an event.');
63 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/server/disconnect/detach-gc.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698