Bug 1851829 - Do not send close messages for MIDI ports that have already been disconnected from their remote object r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D189361
This commit is contained in:
Gabriele Svelto 2023-09-28 09:03:09 +00:00
parent 0489f93a3d
commit 85dbd41802
4 changed files with 36 additions and 1 deletions

View File

@ -254,8 +254,10 @@ void MIDIPort::Receive(const nsTArray<MIDIMessage>& aMsg) {
}
void MIDIPort::DisconnectFromOwner() {
if (Port()) {
Port()->SendClose();
}
DontKeepAliveOnStatechange();
Port()->SendClose();
DOMEventTargetHelper::DisconnectFromOwner();
}

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html class="reftest-wait">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1851829
-->
<head>
<meta charset="utf-8">
<title>Bug 1851829</title>
<script>
async function timeout (cmd) {
const timer = new Promise((resolve, reject) => {
const id = setTimeout(() => {
clearTimeout(id)
reject(new Error('Promise timed out!'))
}, 750)
})
return Promise.race([cmd, timer])
}
window.addEventListener('load', async () => {
// <script>window.close()<\/script>
const tab = window.open('data:text/plain;charset=utf-8;base64,PHNjcmlwdD53aW5kb3cuY2xvc2UoKTwvc2NyaXB0Pg==')
setTimeout(async () => {
try { await timeout(tab.navigator.requestMIDIAccess({})) } catch (e) {}
window.close()
document.documentElement.classList.remove("reftest-wait");
}, 400)
})
</script>
</head>
</html>

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,7 @@ include ../../dom/media/webvtt/test/crashtests/crashtests.list
skip-if(!webrtc) include ../../dom/media/tests/crashtests/crashtests.list
skip-if(!webrtc) include ../../dom/media/webrtc/tests/crashtests/crashtests.list
include ../../dom/media/webspeech/synth/crashtests/crashtests.list
include ../../dom/midi/crashtests/crashtests.list
include ../../dom/plugins/test/crashtests/crashtests.list
include ../../dom/security/test/crashtests/crashtests.list
include ../../dom/serializers/crashtests/crashtests.list