Bug 1339930 - Don't crash in AudioChannelService when dealing with Windows without a parent; r=baku

This commit is contained in:
Ehsan Akhgari 2017-02-16 10:56:00 -05:00
Родитель b0b1d367ca
Коммит f57b29ed8e
3 изменённых файлов: 41 добавлений и 0 удалений

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

@ -829,6 +829,10 @@ AudioChannelService::GetAudioChannelVolume(mozIDOMWindowProxy* aWindow,
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aVolume = 0.f;
return NS_ERROR_FAILURE;
}
*aVolume = GetAudioChannelVolume(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
@ -859,6 +863,9 @@ AudioChannelService::SetAudioChannelVolume(mozIDOMWindowProxy* aWindow,
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
return NS_ERROR_FAILURE;
}
SetAudioChannelVolume(window, (AudioChannel)aAudioChannel, aVolume);
return NS_OK;
}
@ -883,6 +890,10 @@ AudioChannelService::GetAudioChannelMuted(mozIDOMWindowProxy* aWindow,
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aMuted = false;
return NS_ERROR_FAILURE;
}
*aMuted = GetAudioChannelMuted(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
@ -918,6 +929,9 @@ AudioChannelService::SetAudioChannelMuted(mozIDOMWindowProxy* aWindow,
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
return NS_ERROR_FAILURE;
}
SetAudioChannelMuted(window, (AudioChannel)aAudioChannel, aMuted);
return NS_OK;
}
@ -942,6 +956,10 @@ AudioChannelService::IsAudioChannelActive(mozIDOMWindowProxy* aWindow,
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aActive = false;
return NS_ERROR_FAILURE;
}
*aActive = IsAudioChannelActive(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
@ -952,6 +970,9 @@ AudioChannelService::IsWindowActive(nsPIDOMWindowOuter* aWindow)
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
return false;
}
AudioChannelWindow* winData = GetOrCreateWindowData(window);
return !winData->mAudibleAgents.IsEmpty();
}

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

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
window.onload = function(){
let x = document.getElementsByTagName("iframe")[0];
let w = window.open();
let o = window.frames[0];
x.remove();
o.requestIdleCallback(function(){});
w.close();
};
</script>
</head>
<body>
<iframe></iframe>
</body>
</html>

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

@ -1 +1,2 @@
load 1223734.html
load 1339930.html