Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-two-iframes.html |
| diff --git a/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-two-iframes.html b/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-two-iframes.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fe4f46cd23556a7ca86d6ee0f1d3a727034633fc |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-two-iframes.html |
| @@ -0,0 +1,53 @@ |
| +<!DOCTYPE html> |
| +<script> |
| +'use restrict'; |
| + let device; |
| + window.onmessage = messageEvent => { |
| + if (messageEvent.data === 'Iframe1RequestAndConnect') { |
| + navigator.bluetooth.requestDevice({ |
| + filters: [{services: ['heart_rate']}] |
| + }) |
| + .then(device => device.gatt.connect()) |
| + .then(gattServer => { |
| + // iframe1 can access heart_rate service. |
| + gattServer.getPrimaryService('heart_rate'); |
| + parent.postMessage('Iframe1Connected', '*'); |
| + }).catch(err => { |
| + console.error(err); |
| + parent.postMessage('FAIL: ' + err, '*'); |
| + }); |
| + } else if (messageEvent.data === 'Iframe2RequestAndConnect') { |
| + navigator.bluetooth.requestDevice({ |
| + filters: [{services: ['generic_access']}] |
| + }) |
| + .then(device => device.gatt.connect()) |
| + .then(gattServer => { |
| + gattServer.getPrimaryService('generic_access'); |
| + // Since iframe1 can access heart_rate service, and iframe2 has the |
| + // same origin as iframe1, iframe2 should also be able to access |
| + // heart_rate service. |
| + gattServer.getPrimaryService('heart_rate'); |
|
ortuno
2017/02/14 02:52:28
Why are we calling getPrimaryService here? We are
juncai
2017/02/14 05:52:47
Thanks! I'll fix it in a separate CL.
|
| + parent.postMessage('Iframe2Connected', '*'); |
| + }).catch(err => { |
| + console.error(err); |
| + parent.postMessage('FAIL: ' + err, '*'); |
| + }); |
| + } else if (messageEvent.data === 'TestIframe1HasGenericAccessService') { |
| + navigator.bluetooth.requestDevice({ |
| + filters: [{services: ['heart_rate']}] |
| + }) |
| + .then(device => device.gatt.connect()) |
| + .then(gattServer => { |
| + // Since iframe2 can access generic_access service, and iframe1 has the |
| + // same origin as iframe2, iframe1 should also be able to access |
| + // generic_access service. |
| + gattServer.getPrimaryService('generic_access'); |
|
ortuno
2017/02/14 02:52:28
Same here. The promise could reject and we would s
juncai
2017/02/14 05:52:47
ditto.
|
| + parent.postMessage('DoneTest', '*'); |
| + }).catch(err => { |
| + console.error(err); |
| + parent.postMessage('FAIL: ' + err, '*'); |
| + }); |
| + } |
| + }; |
| + parent.postMessage("Ready", "*"); |
| +</script> |