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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/resources/connectGATT-iframe.html

Issue 1611773002: bluetooth: Disconnect if the page becomes hidden or is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Address jyasskin's comments Created 4 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script> 2 <script>
3 window.onmessage = messageEvent => { 3 window.onmessage = messageEvent => {
4 if (messageEvent.data === 'Go') { 4 if (messageEvent.data === 'Go') {
5 navigator.bluetooth.requestDevice({ 5 navigator.bluetooth.requestDevice({
6 filters: [{services: ['generic_access']}] 6 filters: [{services: ['heart_rate']}]
7 }).then(device => { 7 })
8 if (device.constructor.name === "BluetoothDevice") { 8 .then(device => device.connectGATT())
9 parent.postMessage('Success', '*'); 9 .then(gattServer => {
10 } else { 10 parent.postMessage('Connected', '*');
11 parent.postMessage('FAIL: requestDevice in iframe returned ' + device, '*');
12 }
13 }).catch(err => { 11 }).catch(err => {
14 console.error(err); 12 console.error(err);
15 parent.postMessage('FAIL: ' + err, '*'); 13 parent.postMessage('FAIL: ' + err, '*');
16 }); 14 });
17 } 15 }
18 }; 16 };
19 parent.postMessage("Ready", "*"); 17 parent.postMessage("Ready", "*");
20 </script> 18 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698