cross-origin-iframe.sub.https.window.js (1265B)
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 = 'Request device from a unique origin. ' + 8 'Should reject with SecurityError.'; 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 (t) => { 14 await setUpHealthThermometerDevice(); 15 16 // 1. Load the iframe. 17 const iframeWatcher = new EventWatcher(t, iframe, ['load']); 18 iframe.src = cross_origin_src; 19 document.body.appendChild(iframe); 20 await iframeWatcher.wait_for('load'); 21 22 // 2. Request the device from the iframe. 23 const windowWatcher = new EventWatcher(t, window, ['message']); 24 iframe.contentWindow.postMessage({type: 'RequestDevice'}, '*'); 25 const messageEvent = await windowWatcher.wait_for('message'); 26 assert_equals( 27 messageEvent.data, 28 'FAIL: SecurityError: Failed to execute \'requestDevice\' on \'Bluetooth\': Access to the feature "bluetooth" is disallowed by permissions policy.'); 29 }, test_desc);