diff --git a/browser/base/content/test/general/browser_audioTabIcon.js b/browser/base/content/test/general/browser_audioTabIcon.js index d3f2b4492b0b..707e5a5b3c23 100644 --- a/browser/base/content/test/general/browser_audioTabIcon.js +++ b/browser/base/content/test/general/browser_audioTabIcon.js @@ -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"); diff --git a/dom/canvas/test/reftest/reftest.list b/dom/canvas/test/reftest/reftest.list index b573c7f94743..a4ba90cfeda3 100644 --- a/dom/canvas/test/reftest/reftest.list +++ b/dom/canvas/test/reftest/reftest.list @@ -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 diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 6031d0f534c7..feaa5229d6af 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -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; } diff --git a/dom/media/test/crashtests/crashtests.list b/dom/media/test/crashtests/crashtests.list index 63dbfe30c3b7..df560ab2a0cc 100644 --- a/dom/media/test/crashtests/crashtests.list +++ b/dom/media/test/crashtests/crashtests.list @@ -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