cross-origin-iframe-getAvailability.sub.https.window.js (1186B)
1 // META: script=/resources/testdriver.js?feature=bidi 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/bluetooth/resources/bluetooth-test.js 4 // META: script=/bluetooth/resources/bluetooth-fake-devices.js 5 // META: timeout=long 6 'use strict'; 7 const test_desc = 'getAvailability() resolves with false if called from a ' + 8 'unique origin'; 9 const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' + 10 '/bluetooth/resources/health-thermometer-iframe.html' 11 let iframe = document.createElement('iframe'); 12 13 bluetooth_bidi_test(async () => { 14 await navigator.bluetooth.test.simulateCentral({state: 'powered-on'}); 15 await new Promise(resolve => { 16 iframe.src = cross_origin_src; 17 document.body.appendChild(iframe); 18 iframe.addEventListener('load', resolve); 19 }); 20 await new Promise(resolve => { 21 callWithTrustedClick( 22 () => iframe.contentWindow.postMessage({type: 'GetAvailability'}, '*')); 23 24 window.onmessage = messageEvent => { 25 assert_equals( 26 messageEvent.data, false, 27 'getAvailability resolves to false when called from a unique ' + 28 'origin.'); 29 resolve(); 30 }; 31 }); 32 }, test_desc);