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 fdcfabc657
commit 870806be6f
3 changed files with 11 additions and 14 deletions

View File

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

View File

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

View File

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