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

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

Issue 2729603006: Fix Web Bluetooth two iframes from same origin layout test (Closed)
Patch Set: updated test code Created 3 years, 9 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script> 2 <script>
3 'use restrict'; 3 'use restrict';
4 let device; 4 let device;
5 window.onmessage = messageEvent => { 5 window.onmessage = messageEvent => {
6 if (messageEvent.data === 'Iframe1RequestAndConnect') { 6 if (messageEvent.data === 'Iframe1RequestAndConnect') {
7 navigator.bluetooth.requestDevice({ 7 navigator.bluetooth.requestDevice({
8 filters: [{services: ['heart_rate']}] 8 filters: [{services: ['heart_rate']}]
9 }) 9 })
10 .then(device => device.gatt.connect()) 10 .then(device => device.gatt.connect())
11 .then(gattServer => { 11 .then(gattServer => {
12 // iframe1 can access heart_rate service. 12 // iframe1 can access heart_rate service.
13 gattServer.getPrimaryService('heart_rate'); 13 return gattServer.getPrimaryService('heart_rate');
14 }).then(() => {
14 parent.postMessage('Iframe1Connected', '*'); 15 parent.postMessage('Iframe1Connected', '*');
15 }).catch(err => { 16 }).catch(err => {
16 console.error(err); 17 console.error(err);
17 parent.postMessage('FAIL: ' + err, '*'); 18 parent.postMessage('FAIL: ' + err, '*');
18 }); 19 });
20 } else if (messageEvent.data === 'Iframe1TryAccessGenericAccessService') {
21 navigator.bluetooth.requestDevice({
22 filters: [{services: ['heart_rate']}]
23 })
24 .then(device => device.gatt.connect())
25 .then(gattServer => {
26 // iframe1 can not access generic_access service.
27 return gattServer.getPrimaryService('generic_access');
28 }).catch(err => {
29 parent.postMessage('Iframe1AccessGenericAccessServiceFailed', '*');
30 });
19 } else if (messageEvent.data === 'Iframe2RequestAndConnect') { 31 } else if (messageEvent.data === 'Iframe2RequestAndConnect') {
20 navigator.bluetooth.requestDevice({ 32 navigator.bluetooth.requestDevice({
21 filters: [{services: ['generic_access']}] 33 filters: [{services: ['generic_access']}]
22 }) 34 })
23 .then(device => device.gatt.connect()) 35 .then(device => device.gatt.connect())
24 .then(gattServer => { 36 .then(gattServer => {
25 gattServer.getPrimaryService('generic_access');
26 // Since iframe1 can access heart_rate service, and iframe2 has the 37 // Since iframe1 can access heart_rate service, and iframe2 has the
27 // same origin as iframe1, iframe2 should also be able to access 38 // same origin as iframe1, iframe2 should also be able to access
28 // heart_rate service. 39 // heart_rate service.
29 gattServer.getPrimaryService('heart_rate'); 40 return Promise.all([gattServer.getPrimaryService('generic_access'),
41 gattServer.getPrimaryService('heart_rate')]);
42 }).then(() => {
30 parent.postMessage('Iframe2Connected', '*'); 43 parent.postMessage('Iframe2Connected', '*');
31 }).catch(err => { 44 }).catch(err => {
32 console.error(err); 45 console.error(err);
33 parent.postMessage('FAIL: ' + err, '*'); 46 parent.postMessage('FAIL: ' + err, '*');
34 }); 47 });
35 } else if (messageEvent.data === 'TestIframe1HasGenericAccessService') { 48 } else if (messageEvent.data === 'TestIframe1HasGenericAccessService') {
36 navigator.bluetooth.requestDevice({ 49 navigator.bluetooth.requestDevice({
37 filters: [{services: ['heart_rate']}] 50 filters: [{services: ['heart_rate']}]
38 }) 51 })
39 .then(device => device.gatt.connect()) 52 .then(device => device.gatt.connect())
40 .then(gattServer => { 53 .then(gattServer => {
41 // Since iframe2 can access generic_access service, and iframe1 has the 54 // Since iframe2 can access generic_access service, and iframe1 has the
42 // same origin as iframe2, iframe1 should also be able to access 55 // same origin as iframe2, iframe1 should also be able to access
43 // generic_access service. 56 // generic_access service.
44 gattServer.getPrimaryService('generic_access'); 57 return gattServer.getPrimaryService('generic_access');
58 }).then(() => {
45 parent.postMessage('DoneTest', '*'); 59 parent.postMessage('DoneTest', '*');
46 }).catch(err => { 60 }).catch(err => {
47 console.error(err); 61 console.error(err);
48 parent.postMessage('FAIL: ' + err, '*'); 62 parent.postMessage('FAIL: ' + err, '*');
49 }); 63 });
50 } 64 }
51 }; 65 };
52 parent.postMessage("Ready", "*"); 66 parent.postMessage("Ready", "*");
53 </script> 67 </script>
OLDNEW
« 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