blob: 111d109458f6b08cc09a4968195e873453bd3237 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
<script src="../../external/wpt/bluetooth/resources/bluetooth-helpers.js"></script>
<body>
<script>
'use strict';
const test_desc = 'Request device from a unique origin. ' +
'Should reject with SecurityError.';
let iframe = document.createElement('iframe');
bluetooth_test(() => getHealthThermometerDevice()
// 1. Load the iframe.
.then(() => new Promise(resolve => {
iframe.sandbox.add('allow-scripts');
iframe.src = '../../resources/bluetooth/requestDevice-in-iframe.html';
document.body.appendChild(iframe);
iframe.addEventListener('load', resolve);
}))
// 2. Request the device from the iframe.
.then(() => new Promise(resolve => {
callWithTrustedClick(() => {
iframe.contentWindow.postMessage('Go', '*');
});
window.onmessage = messageEvent => {
assert_equals(messageEvent.data, 'SecurityError: requestDevice() ' +
'called from cross-origin iframe.');
resolve();
}
})), test_desc);
</script>
</body>