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

Unified Diff: third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-two-iframes.html

Issue 2658473002: Refactor BluetoothAllowedDevicesMap (Closed)
Patch Set: cleaned up layout test code 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/server/getPrimaryService/two-iframes-from-same-origin.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/server/getPrimaryService/two-iframes-from-same-origin.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698