blob: 101a6a7a92c989f5df3cdc6fa02e7086b6048143 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../external/wpt/bluetooth/resources/bluetooth-helpers.js"></script>
<body></body>
<script>
'use strict';
function createIframe(iframe) {
return new Promise(resolve => {
iframe.src = '';
iframe.onload = () => {
resolve(iframe.contentWindow.navigator.bluetooth);
};
document.body.appendChild(iframe);
});
}
promise_test(async (t) => {
let iframe = document.createElement('iframe');
let iframeBluetoothObject = await createIframe(iframe);
document.body.removeChild(iframe);
// Set iframe to null to ensure that the GC cleans up as much as possible.
iframe = null;
GCController.collect();
return callWithTrustedClick(iframeBluetoothObject.requestLEScan)
.catch(err => assert_equals(err.name, 'ReferenceError'));
}, 'detaching from iframe invalidates reference to the iframe bluetooth object');
</script>