Bug 1191491 - Do not dispatch an audio-playback notification when swapping browsers; r=smaug

We send a pagehide event during swapping docshell frame loaders, and
before this patch we would not be able to differentiate this event with
the one that we send when navigating away from a page, so we would
incorrectly dispatch an audio-playback notification indicating that
audio playback has stopped.  This patch adds a flag to the root docshell
when the frame loader swapping is in progress and disables the above
behavior when that flag is set.
This commit is contained in:
Ehsan Akhgari
2015-08-06 10:03:24 -04:00
parent e79a496046
commit 9e1ae0a6f8
6 changed files with 68 additions and 6 deletions

View File

@@ -103,6 +103,7 @@ static PRLogModuleInfo* gMediaElementEventsLog;
#include "nsIPermissionManager.h"
#include "nsContentTypeParser.h"
#include "nsDocShell.h"
#include "mozilla/EventStateManager.h"
@@ -4013,7 +4014,14 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
if (pauseElement && mAudioChannelAgent) {
// If the element is being paused since we are navigating away from the
// document, notify the audio channel agent.
NotifyAudioChannelAgent(false);
// Be careful to ignore this event during a docshell frame swap.
auto docShell = static_cast<nsDocShell*>(OwnerDoc()->GetDocShell());
if (!docShell) {
return;
}
if (!docShell->InFrameSwap()) {
NotifyAudioChannelAgent(false);
}
}
}