Bug 1113086 - AudioChannel policy in Browser API - patch 7 - Support non-app iframe, r=alwu

This commit is contained in:
Andrea Marchesini 2015-07-10 17:40:24 +01:00
parent edc798be42
commit f59934329a
3 changed files with 11 additions and 14 deletions

View File

@ -9,7 +9,6 @@ SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
SpecialPowers.setBoolPref("dom.testing.browserElementAudioChannel.noapp", true);
SpecialPowers.setBoolPref("media.useAudioChannelService", true);
function noaudio() {

View File

@ -520,9 +520,6 @@ nsBrowserElement::GetAllowedAudioChannels(
{
aAudioChannels.Clear();
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
// If empty, it means that this is the first call of this method.
if (mBrowserElementAudioChannels.IsEmpty()) {
nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
@ -531,6 +528,16 @@ nsBrowserElement::GetAllowedAudioChannels(
return;
}
bool isBrowserOrApp;
aRv = frameLoader->GetOwnerIsBrowserOrAppFrame(&isBrowserOrApp);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
if (!isBrowserOrApp) {
return;
}
nsCOMPtr<nsIDOMElement> frameElement;
aRv = frameLoader->GetOwnerElement(getter_AddRefs(frameElement));
if (NS_WARN_IF(aRv.Failed())) {
@ -587,14 +594,6 @@ nsBrowserElement::GetAllowedAudioChannels(
return;
}
bool noapp = false;
Preferences::GetBool("dom.testing.browserElementAudioChannel.noapp", &noapp);
if (!noapp && !app) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
// Normal is always allowed.
nsTArray<nsRefPtr<BrowserElementAudioChannel>> channels;
@ -609,7 +608,6 @@ nsBrowserElement::GetAllowedAudioChannels(
channels.AppendElement(ac);
// app can be null in case we are in a test.
if (app) {
const nsAttrValue::EnumTable* audioChannelTable =
AudioChannelService::GetAudioChannelTable();

View File

@ -30,7 +30,7 @@ interface BrowserElementAudioChannel : EventTarget {
};
partial interface BrowserElementPrivileged {
[Constant, Cached, Throws,
[Pure, Cached, Throws,
Pref="dom.mozBrowserFramesEnabled",
CheckPermissions="browser"]
readonly attribute sequence<BrowserElementAudioChannel> allowedAudioChannels;