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

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: Make iframe subscribe to notifications and add comments. 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/server/disconnect/detach-gc.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« 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