Bug 1872770: Allowing the MessagePort ForceClose message to be not in sync with the previous messages sent on the port.r=edenchuang

As described here, https://bugzilla.mozilla.org/show_bug.cgi?id=1872770#c10 the MessagePort ForceClose message can be out of sync
in certain situations and hence, the sequenceIDs could be different. This is fine as we don't expect to receive more messages after
the ForceClose.

Differential Revision: https://phabricator.services.mozilla.com/D200014
This commit is contained in:
hsingh 2024-02-05 23:50:03 +00:00
Родитель 5e5508c24c
Коммит 5f5f222030
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -391,11 +391,15 @@ bool MessagePortService::ForceClose(const nsID& aUUID,
return true;
}
if (!data->mDestinationUUID.Equals(aDestinationUUID) ||
data->mSequenceID != aSequenceID) {
NS_WARNING("DestinationUUID and/or sequenceID do not match.");
return false;
}
NS_ENSURE_TRUE(data->mDestinationUUID.Equals(aDestinationUUID), false);
// If StructuredCloneData includes a MessagePort, StructuredCloneData
// serialization failure in postMessage can trigger MessagePort::ForceClose().
// And since the serialized port transfered has started but not finished yet,
// the SequenceID will not be synchronized to the parent side, which will
// cause the SequenceID to mismatch here. See bug 1872770.
NS_WARNING_ASSERTION(data->mSequenceID == aSequenceID,
"sequence IDs do not match");
CloseAll(aUUID, true);
return true;