Bug 1458383 - Assume tabs delay playback start of media. r=baku draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 09 May 2018 15:32:08 +1200
changeset 795043 deb240bda1980bcefbfc63f9ec0b00693c5777d2
parent 795042 37ca839bdf9f323b11e010df643c31f895c602f5
push id109848
push userbmo:cpearce@mozilla.com
push dateMon, 14 May 2018 22:46:33 +0000
reviewersbaku
bugs1458383
milestone62.0a1
Bug 1458383 - Assume tabs delay playback start of media. r=baku Regardless of whether autoplay is enabled or not, we want to delay playback start in tabs until the tab has been in the foreground. So initialize nsPIDOMWindowOuter::mMediaSuspend to SUSPENDED_BLOCK if the controlling pref for the delay-playback-start feature is enabled. MozReview-Commit-ID: 7A8U5922AW8
dom/base/nsGlobalWindowOuter.cpp
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -7698,28 +7698,36 @@ nsPIDOMWindowOuter::GetDocGroup() const
 namespace mozilla {
 namespace dom {
 extern uint64_t
 NextWindowID();
 } // namespace dom
 } // namespace mozilla
 
 nsPIDOMWindowOuter::nsPIDOMWindowOuter()
-: mFrameElement(nullptr), mDocShell(nullptr), mModalStateDepth(0),
-  mIsActive(false), mIsBackground(false),
-  mMediaSuspend(
-    Preferences::GetBool("media.block-autoplay-until-in-foreground", true) &&
-    Preferences::GetBool("media.autoplay.enabled", true) ?
-    nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
-  mAudioMuted(false), mAudioVolume(1.0),
-  mDesktopModeViewport(false), mIsRootOuterWindow(false), mInnerWindow(nullptr),
+  : mFrameElement(nullptr)
+  , mDocShell(nullptr)
+  , mModalStateDepth(0)
+  , mIsActive(false)
+  , mIsBackground(false)
+  , mMediaSuspend(
+      Preferences::GetBool("media.block-autoplay-until-in-foreground", true)
+        ? nsISuspendedTypes::SUSPENDED_BLOCK
+        : nsISuspendedTypes::NONE_SUSPENDED)
+  , mAudioMuted(false)
+  , mAudioVolume(1.0)
+  , mDesktopModeViewport(false)
+  , mIsRootOuterWindow(false)
+  , mInnerWindow(nullptr)
+  ,
   // Make sure no actual window ends up with mWindowID == 0
-  mWindowID(NextWindowID()),
-  mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
-  mLargeAllocStatus(LargeAllocStatus::NONE)
+  mWindowID(NextWindowID())
+  , mMarkedCCGeneration(0)
+  , mServiceWorkersTestingEnabled(false)
+  , mLargeAllocStatus(LargeAllocStatus::NONE)
 {
 }
 
 nsPIDOMWindowOuter::~nsPIDOMWindowOuter() {}
 
 nsAutoPopupStatePusherInternal::nsAutoPopupStatePusherInternal(PopupControlState aState, bool aForce)
   : mOldState(nsContentUtils::PushPopupControlState(aState, aForce))
 {