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

Unified Diff: third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.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
Index: third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.html
diff --git a/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.html b/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..4f1442af76d606e8f2facfc85393b5ad5d3810ef
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script>
+ let device;
+ window.onmessage = messageEvent => {
+ if (messageEvent.data === 'RequestAndConnect') {
+ navigator.bluetooth.requestDevice({
+ filters: [{services: ['heart_rate']}]
+ })
+ .then(device => device.gatt.connect())
+ .then(gattServer => {
+ device = gattServer.device;
+ parent.postMessage('Connected', '*');
+ }).catch(err => {
+ console.error(err);
+ parent.postMessage('FAIL: ' + err, '*');
+ });
+ } else if (messageEvent.data === 'StartNotifications') {
+ device.gatt.getPrimaryService('heart_rate')
+ .then(service => service.getCharacteristic('heart_rate_measurement'))
+ .then(char => char.startNotifications())
+ .then(char => {
+ char.addEventListener('characteristicvaluechanged', function() {});
+ parent.postMessage('NotificationsStarted', '*');
+ });
+ }
+ };
+ parent.postMessage("Ready", "*");
+</script>

Powered by Google App Engine
This is Rietveld 408576698