Files
firefox/testing/web-platform/tests/webhid/unload-iframe.https.window.js
Matt Reynolds 2ee1434220 Bug 1729094 [wpt PR 30339] - webhid: Close service connection when context is lost, a=testonly
Automatic update from web-platform-tests
webhid: Close service connection when context is lost

This fixes an issue where the execution context could be destroyed
before the mojo connection to the HID service is disconnected, causing
blink::HID to be torn down with pending Promise callbacks.

This CL makes blink::HID an ExecutionContextLifecycleObserver so it
can respond to ContextDestroyed and resolve the pending callbacks.

Bug: 1243284
Change-Id: Ic1860ffa39d7e1fc7197b14c8cb0bbe4570d1115
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3140735
Reviewed-by: Reilly Grant <[email protected]>
Commit-Queue: Matt Reynolds <[email protected]>
Cr-Commit-Position: refs/heads/main@{#919947}

--

wpt-commits: d158929ca1342ab5b44efea382e5f3aa4f2b2307
wpt-pr: 30339
2021-09-29 09:23:44 +00:00

23 lines
651 B
JavaScript

let frame;
window.unloadChild = function() {
document.body.removeChild(frame);
};
promise_test(async t => {
frame = document.createElement('iframe');
frame.srcdoc = `<script>
navigator.hid.getDevices();
window.parent.unloadChild();
</script>`;
document.body.appendChild(frame);
}, 'Unload child iframe with pending getDevices promise');
promise_test(async t => {
frame = document.createElement('iframe');
frame.srcdoc = `<script>
navigator.hid.requestDevice({filters: []});
window.parent.unloadChild();
</script>`;
document.body.appendChild(frame);
}, 'Unload child iframe with pending requestDevice promise');