Bug 1694791 check placeholderListener instead of window listener for enumerateDevices() abort r=jib DONTBUILD

An enumerateDevices() call before a navigation possibly should sometimes
resolve its promise even after the navigation, but that shouldn't depend on
whether another enumerateDevices() call is made with the same Window after the
navigation but before the first would resolve.

The current behavior is that listeners are removed on Document navigation, but
listeners can be added after navigation.  Testing the window listener is
checking for any listener but testing the placeholderListener checks the
listener associated with this particular operation.

Differential Revision: https://phabricator.services.mozilla.com/D114317
This commit is contained in:
Karl Tomlinson 2021-05-06 20:21:41 +00:00
Родитель 98934eac2e
Коммит 354ec81af7
1 изменённых файлов: 2 добавлений и 3 удалений

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

@ -3046,15 +3046,14 @@ RefPtr<MediaManager::MgrPromise> MediaManager::EnumerateDevicesImpl(
aAudioInputEnumType, aOutDevices](bool) {
// Only run if window is still on our active list.
MediaManager* mgr = MediaManager::GetIfExists();
if (!mgr || !mgr->IsWindowStillActive(windowId)) {
if (!mgr || placeholderListener->Stopped()) {
// The listener has already been removed if the window is no
// longer active.
MOZ_ASSERT(placeholderListener->Stopped());
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
}
MOZ_ASSERT(!placeholderListener->Stopped());
MOZ_ASSERT(mgr->IsWindowStillActive(windowId));
placeholderListener->Stop();
for (auto& device : *aOutDevices) {