Bug 1213154 - tab-sound-icon should be supported by bfcache, r=roc

This commit is contained in:
Andrea Marchesini 2015-11-06 16:16:57 +00:00
Родитель 5294a0ca8d
Коммит ea75b3fe7a
4 изменённых файлов: 20 добавлений и 24 удалений

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

@ -192,7 +192,7 @@ function* test_swapped_browser(oldTab, newBrowser, isPlaying) {
});
let AudioPlaybackPromise = new Promise(resolve => {
let observer = (subject, topic, data) => {
ok(false, "Should not see an audio-playback notification");
ok(true, "Should see an audio-playback notification");
};
Services.obs.addObserver(observer, "audio-playback", false);
setTimeout(() => {
@ -207,7 +207,7 @@ function* test_swapped_browser(oldTab, newBrowser, isPlaying) {
ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab");
is(newTab.hasAttribute("soundplaying"), isPlaying, "Expected the correct soundplaying attribute on the new tab");
// Wait to see if an audio-playback event is dispatched. This should not happen!
// Wait to see if an audio-playback event is dispatched.
yield AudioPlaybackPromise;
ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab");

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

@ -1,5 +1,5 @@
# WebGL Reftests!
default-preferences pref(webgl.force-enabled,true)
default-preferences pref(webgl.force-enabled,true) pref(media.useAudioChannelAPI,false)
# Check that disabling works:
== webgl-disable-test.html?nogl wrapper.html?green.png

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

@ -107,12 +107,6 @@ static PRLogModuleInfo* gMediaElementEventsLog;
#include "mozilla/EventStateManager.h"
#if defined(MOZ_B2G) && !defined(MOZ_GRAPHENE)
// This controls the b2g specific of pausing the media element when the
// AudioChannel tells us to mute it.
#define PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
#endif
using namespace mozilla::layers;
using mozilla::net::nsMediaFragmentURIParser;
@ -4238,15 +4232,12 @@ bool HTMLMediaElement::IsBeingDestroyed()
void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
{
bool pauseElement = NotifyOwnerDocumentActivityChangedInternal();
if (pauseElement && mAudioChannelAgent
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
if (pauseElement && mAudioChannelAgent &&
// On B2G, NotifyOwnerDocumentActivityChangedInternal may return true for
// two reasons: the document no longer being active, or the element being
// paused by the audio channel. However we are only interested in the
// first case here, so we need to filter out the second case.
&& !ComputedMuted()
#endif
) {
(!UseAudioChannelAPI() || !ComputedMuted())) {
// If the element is being paused since we are navigating away from the
// document, notify the audio channel agent.
// Be careful to ignore this event during a docshell frame swap.
@ -4270,15 +4261,13 @@ HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal()
}
bool pauseElement = !IsActive();
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
// Only pause the element when we start playing. If we pause without playing
// audio, the resource loading would be affected unexpectedly. For example,
// the media element is muted by default, but we don't want this behavior
// interrupting the loading process.
if (mAudioChannelAgent) {
if (UseAudioChannelAPI() && mAudioChannelAgent) {
pauseElement |= ComputedMuted();
}
#endif
SuspendOrResumeElement(pauseElement, !IsActive());
@ -4712,9 +4701,10 @@ nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted)
}
}
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
SuspendOrResumeElement(ComputedMuted(), false);
#endif
if (UseAudioChannelAPI()) {
SuspendOrResumeElement(ComputedMuted(), false);
}
return NS_OK;
}
@ -4748,6 +4738,12 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return false;
}
// We should consider any bfcached page or inactive document/channel as
// non-playing.
if (mPausedForInactiveDocumentOrChannel) {
return false;
}
// A loop always is playing
if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
return true;
@ -4819,9 +4815,9 @@ NS_IMETHODIMP HTMLMediaElement::WindowVolumeChanged(float aVolume, bool aMuted)
UpdateChannelMuteState(aVolume, aMuted);
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
mPaused.SetCanPlay(!aMuted);
#endif
if (UseAudioChannelAPI()) {
mPaused.SetCanPlay(!aMuted);
}
return NS_OK;
}

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

@ -7,7 +7,7 @@ load 474744-1.html
HTTP load 481136-1.html # needs to be HTTP to recognize the ogg as an audio file?
load 492286-1.xhtml
load 493915-1.html
load 495794-1.html
skip-if(B2G) load 495794-1.html # in b2g all the media are muted by default
load 576612-1.html
load 752784-1.html
load 789075-1.html