Backed out 6 changesets (bug 1347758) for eslint failure
authorIris Hsiao <ihsiao@mozilla.com>
Fri, 24 Mar 2017 16:58:08 +0800
changeset 349369 e7dbc2e8b2f997b9371e0e026f2906b4fca09d94
parent 349368 ec80a3f5cebc2a8b54feeead3db2af7f9af05f27
child 349370 d3c146c2e90af53713cecd13db35a68c4ed9c524
child 349387 473e0b20176139cff952b04e3eeff3ee155d0d3d
push id39475
push userihsiao@mozilla.com
push dateFri, 24 Mar 2017 08:58:20 +0000
treeherderautoland@e7dbc2e8b2f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1347758
milestone55.0a1
backs out9becd55242c177056d602cbde548b67e1559966c
2abce19f5001f97ff7df214cb2a92b6d81ffa0be
80232d4c85d546b267972a493cd96fd1be5f4017
1fd084ec34d4e189f5a855cb3a25310bb8815299
cafb3c12027b87c802f8c15fc632962d0384e229
85846edfe95729b7ca380d5d204f2183be1c944a
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 6 changesets (bug 1347758) for eslint failure Backed out changeset 9becd55242c1 (bug 1347758) Backed out changeset 2abce19f5001 (bug 1347758) Backed out changeset 80232d4c85d5 (bug 1347758) Backed out changeset 1fd084ec34d4 (bug 1347758) Backed out changeset cafb3c12027b (bug 1347758) Backed out changeset 85846edfe957 (bug 1347758)
dom/audiochannel/AudioChannelAgent.cpp
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsGlobalWindow.cpp
dom/base/nsIDocument.h
dom/base/nsPIDOMWindow.h
dom/html/HTMLMediaElement.cpp
dom/media/webaudio/AudioDestinationNode.cpp
dom/plugins/base/nsNPAPIPluginInstance.cpp
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_block_notInTreeAudio.js
toolkit/content/tests/browser/browser_block_plugIn.js
toolkit/content/tests/browser/browser_block_webAudio.js
toolkit/content/tests/browser/file_nonAutoplayAudio.html
toolkit/content/tests/browser/file_plugIn.html
toolkit/content/tests/browser/file_webAudio.html
toolkit/content/tests/browser/head.js
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -215,20 +215,18 @@ AudioChannelAgent::NotifyStartedPlaying(
   service->RegisterAudioChannelAgent(this,
     static_cast<AudioChannelService::AudibleState>(aAudible));
 
   AudioPlaybackConfig config = service->GetMediaConfig(mWindow,
                                                        mAudioChannelType);
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelAgent, NotifyStartedPlaying, this = %p, "
-          "audible = %s, mute = %s, volume = %f, suspend = %s\n", this,
-          AudibleStateToStr(static_cast<AudioChannelService::AudibleState>(aAudible)),
-          config.mMuted ? "true" : "false", config.mVolume,
-          SuspendTypeToStr(config.mSuspend)));
+          "audible = %d, mute = %d, volume = %f, suspend = %d\n", this,
+          aAudible, config.mMuted, config.mVolume, config.mSuspend));
 
   aConfig->SetConfig(config.mVolume, config.mMuted, config.mSuspend);
   mIsRegToService = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AudioChannelAgent::NotifyStoppedPlaying()
@@ -250,19 +248,17 @@ AudioChannelAgent::NotifyStoppedPlaying(
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AudioChannelAgent::NotifyStartedAudible(uint8_t aAudible, uint32_t aReason)
 {
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelAgent, NotifyStartedAudible, this = %p, "
-          "audible = %s, reason = %s\n", this,
-          AudibleStateToStr(static_cast<AudioChannelService::AudibleState>(aAudible)),
-          AudibleChangedReasonToStr(static_cast<AudioChannelService::AudibleChangedReasons>(aReason))));
+          "audible = %d, reason = %d\n", this, aAudible, aReason));
 
   RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_FAILURE;
   }
 
   service->AudioAudibleChanged(
     this,
@@ -286,19 +282,18 @@ AudioChannelAgent::WindowVolumeChanged()
 {
   nsCOMPtr<nsIAudioChannelAgentCallback> callback = GetCallback();
   if (!callback) {
     return;
   }
 
   AudioPlaybackConfig config = GetMediaConfig();
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %s, "
-          "volume = %f\n",
-          this, config.mMuted ? "true" : "false", config.mVolume));
+         ("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
+          "volume = %f\n", this, config.mMuted, config.mVolume));
 
   callback->WindowVolumeChanged(config.mVolume, config.mMuted);
 }
 
 void
 AudioChannelAgent::WindowSuspendChanged(nsSuspendedTypes aSuspend)
 {
   nsCOMPtr<nsIAudioChannelAgentCallback> callback = GetCallback();
@@ -307,17 +302,17 @@ AudioChannelAgent::WindowSuspendChanged(
   }
 
   if (!IsDisposableSuspend(aSuspend)) {
     aSuspend = GetMediaConfig().mSuspend;
   }
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelAgent, WindowSuspendChanged, this = %p, "
-          "suspended = %s\n", this, SuspendTypeToStr(aSuspend)));
+          "suspended = %d\n", this, aSuspend));
 
   callback->WindowSuspendChanged(aSuspend);
 }
 
 AudioPlaybackConfig
 AudioChannelAgent::GetMediaConfig()
 {
   RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -88,18 +88,18 @@ public:
     // TODO : remove b2g related event in bug1299390.
     observerService->NotifyObservers(wrapper,
                                      "media-playback",
                                      mActive
                                        ? u"active"
                                        : u"inactive");
 
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-           ("NotifyChannelActiveRunnable, type = %" PRIu32 ", active = %s\n",
-            static_cast<uint32_t>(mAudioChannel), mActive ? "true" : "false"));
+           ("NotifyChannelActiveRunnable, type = %" PRIu32 ", active = %d\n",
+            static_cast<uint32_t>(mAudioChannel), mActive));
 
     return NS_OK;
   }
 
 private:
   const uint64_t mWindowID;
   const AudioChannel mAudioChannel;
   const bool mActive;
@@ -132,18 +132,18 @@ public:
     nsAutoString state;
     GetActiveState(state);
 
     observerService->NotifyObservers(ToSupports(mWindow),
                                      "audio-playback",
                                      state.get());
 
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-           ("AudioPlaybackRunnable, active = %s, reason = %s\n",
-            mActive ? "true" : "false", AudibleChangedReasonToStr(mReason)));
+           ("AudioPlaybackRunnable, active = %d, reason = %d\n",
+            mActive, mReason));
 
     return NS_OK;
   }
 
 private:
   void GetActiveState(nsAString& astate)
   {
     if (mActive) {
@@ -175,82 +175,16 @@ IsEnableAudioCompetingForAllAgents()
   return true;
 #else
   return sAudioChannelCompetingAllAgents;
 #endif
 }
 
 } // anonymous namespace
 
-namespace mozilla {
-namespace dom {
-
-const char*
-SuspendTypeToStr(const nsSuspendedTypes& aSuspend)
-{
-  MOZ_ASSERT(aSuspend == nsISuspendedTypes::NONE_SUSPENDED ||
-             aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE ||
-             aSuspend == nsISuspendedTypes::SUSPENDED_BLOCK ||
-             aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
-             aSuspend == nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
-
-  switch (aSuspend) {
-    case nsISuspendedTypes::NONE_SUSPENDED:
-      return "none";
-    case nsISuspendedTypes::SUSPENDED_PAUSE:
-      return "pause";
-    case nsISuspendedTypes::SUSPENDED_BLOCK:
-      return "block";
-    case nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE:
-      return "disposable-pause";
-    case nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE:
-      return "disposable-stop";
-    default:
-      return "unknown";
-  }
-}
-
-const char*
-AudibleStateToStr(const AudioChannelService::AudibleState& aAudible)
-{
-  MOZ_ASSERT(aAudible == AudioChannelService::AudibleState::eNotAudible ||
-             aAudible == AudioChannelService::AudibleState::eMaybeAudible ||
-             aAudible == AudioChannelService::AudibleState::eAudible);
-
-  switch (aAudible) {
-    case AudioChannelService::AudibleState::eNotAudible :
-      return "not-audible";
-    case AudioChannelService::AudibleState::eMaybeAudible :
-      return "maybe-audible";
-    case AudioChannelService::AudibleState::eAudible :
-      return "audible";
-    default:
-      return "unknown";
-  }
-}
-
-const char*
-AudibleChangedReasonToStr(const AudioChannelService::AudibleChangedReasons& aReason)
-{
-  MOZ_ASSERT(aReason == AudioChannelService::AudibleChangedReasons::eVolumeChanged ||
-             aReason == AudioChannelService::AudibleChangedReasons::eDataAudibleChanged ||
-             aReason == AudioChannelService::AudibleChangedReasons::ePauseStateChanged);
-
-  switch (aReason) {
-    case AudioChannelService::AudibleChangedReasons::eVolumeChanged :
-      return "volume";
-    case AudioChannelService::AudibleChangedReasons::eDataAudibleChanged :
-      return "data-audible";
-    case AudioChannelService::AudibleChangedReasons::ePauseStateChanged :
-      return "pause-state";
-    default:
-      return "unknown";
-  }
-}
-
 StaticRefPtr<AudioChannelService> gAudioChannelService;
 
 // Mappings from 'mozaudiochannel' attribute strings to an enumeration.
 static const nsAttrValue::EnumTable kMozAudioChannelAttributeTable[] = {
   { "normal",             (int16_t)AudioChannel::Normal },
   { "content",            (int16_t)AudioChannel::Content },
   { "notification",       (int16_t)AudioChannel::Notification },
   { "alarm",              (int16_t)AudioChannel::Alarm },
@@ -964,18 +898,17 @@ AudioChannelService::SetAudioChannelMute
                                           bool aMuted)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsOuterWindow());
 
   MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelService, SetAudioChannelMuted, window = %p, type = %" PRIu32 ", "
-          "mute = %s\n", aWindow, static_cast<uint32_t>(aAudioChannel),
-          aMuted ? "true" : "false"));
+          "mute = %d\n", aWindow, static_cast<uint32_t>(aAudioChannel), aMuted));
 
   if (aAudioChannel == AudioChannel::System) {
     // Workaround for bug1183033, system channel type can always playback.
     return;
   }
 
   AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
   winData->mChannels[(uint32_t)aAudioChannel].mMuted = aMuted;
@@ -1206,18 +1139,18 @@ AudioChannelService::AudioChannelWindow:
   // One exception is if the pref "media.block-autoplay-until-in-foreground"
   // is on and the background page is the non-visited before. Because the media
   // in that page would be blocked until the page is going to foreground.
   mOwningAudioFocus = (!(aAgent->Window()->IsBackground()) ||
                        aAgent->Window()->GetMediaSuspend() == nsISuspendedTypes::SUSPENDED_BLOCK) ;
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelWindow, RequestAudioFocus, this = %p, "
-          "agent = %p, owning audio focus = %s\n",
-          this, aAgent, mOwningAudioFocus ? "true" : "false"));
+          "agent = %p, owning audio focus = %d\n",
+          this, aAgent, mOwningAudioFocus));
 }
 
 void
 AudioChannelService::AudioChannelWindow::NotifyAudioCompetingChanged(AudioChannelAgent* aAgent)
 {
   // This function may be called after RemoveAgentAndReduceAgentsNum(), so the
   // agent may be not contained in mAgent. In addition, the agent would still
   // be alive because we have kungFuDeathGrip in UnregisterAudioChannelAgent().
@@ -1308,17 +1241,17 @@ AudioChannelService::AudioChannelWindow:
           agent->WindowSuspendChanged(type);
           break;
       }
     }
   }
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelWindow, AudioFocusChanged, this = %p, "
-          "OwningAudioFocus = %s\n", this, mOwningAudioFocus ? "true" : "false"));
+          "OwningAudioFocus = %d\n", this, mOwningAudioFocus));
 }
 
 bool
 AudioChannelService::AudioChannelWindow::IsContainingPlayingAgent(AudioChannelAgent* aAgent) const
 {
   return (aAgent->WindowID() == mWindowID);
 }
 
@@ -1336,19 +1269,18 @@ AudioChannelService::AudioChannelWindow:
   // TODO : add other competing cases for MediaSession API
   if (presentChannelType == int32_t(AudioChannel::Normal) &&
       aIncomingChannelType == int32_t(AudioChannel::Normal)) {
     competingBehavior = nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE;
   }
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelWindow, GetCompetingBehavior, this = %p, "
-          "present type = %d, incoming channel = %d, behavior = %s\n",
-          this, presentChannelType, aIncomingChannelType,
-          SuspendTypeToStr(competingBehavior)));
+          "present type = %d, incoming channel = %d, behavior = %d\n",
+          this, presentChannelType, aIncomingChannelType, competingBehavior));
 
   return competingBehavior;
 }
 
 /* static */ bool
 AudioChannelService::IsAudioChannelMutedByDefault()
 {
   CreateServiceIfNeeded();
@@ -1459,22 +1391,23 @@ void
 AudioChannelService::AudioChannelWindow::AudioAudibleChanged(AudioChannelAgent* aAgent,
                                                              AudibleState aAudible,
                                                              AudibleChangedReasons aReason)
 {
   MOZ_ASSERT(aAgent);
 
   if (aAudible == AudibleState::eAudible) {
     AppendAudibleAgentIfNotContained(aAgent, aReason);
-    NotifyAudioCompetingChanged(aAgent);
   } else {
     RemoveAudibleAgentIfContained(aAgent, aReason);
   }
 
-  if (aAudible != AudibleState::eNotAudible) {
+  if (aAudible == AudibleState::eAudible) {
+    NotifyAudioCompetingChanged(aAgent);
+  } else if (aAudible != AudibleState::eNotAudible) {
     MaybeNotifyMediaBlockStart(aAgent);
   }
 }
 
 void
 AudioChannelService::AudioChannelWindow::AppendAudibleAgentIfNotContained(AudioChannelAgent* aAgent,
                                                                           AudibleChangedReasons aReason)
 {
@@ -1581,12 +1514,8 @@ AudioChannelService::AudioChannelWindow:
 
         observerService->NotifyObservers(ToSupports(window),
                                          "audio-playback",
                                          u"blockStart");
       })
     );
   }
 }
-
-} // namespace dom
-} // namespace mozilla
-
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -364,16 +364,12 @@ private:
   bool mAnyChannel;
 
   // This is needed for IPC comunication between
   // AudioChannelServiceChild and this class.
   friend class ContentParent;
   friend class ContentChild;
 };
 
-const char* SuspendTypeToStr(const nsSuspendedTypes& aSuspend);
-const char* AudibleStateToStr(const AudioChannelService::AudibleState& aAudible);
-const char* AudibleChangedReasonToStr(const AudioChannelService::AudibleChangedReasons& aReason);
-
 } // namespace dom
 } // namespace mozilla
 
 #endif
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1322,16 +1322,17 @@ nsIDocument::nsIDocument()
     mHasHadDefaultView(false),
     mStyleSheetChangeEventsEnabled(false),
     mIsSrcdocDocument(false),
     mDidDocumentOpen(false),
     mHasDisplayDocument(false),
     mFontFaceSetDirty(true),
     mGetUserFontSetCalled(false),
     mPostedFlushUserFontSet(false),
+    mEverInForeground(false),
     mCompatMode(eCompatibility_FullStandards),
     mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
     mStyleBackendType(StyleBackendType::None),
 #ifdef MOZILLA_INTERNAL_API
     mVisibilityState(dom::VisibilityState::Hidden),
 #else
     mDummy(0),
 #endif
@@ -1420,16 +1421,18 @@ nsDocument::nsDocument(const char* aCont
 
   MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug, ("DOCUMENT %p created", this));
 
   // Start out mLastStyleSheetSet as null, per spec
   SetDOMStringToNull(mLastStyleSheetSet);
 
   // void state used to differentiate an empty source from an unselected source
   mPreloadPictureFoundSource.SetIsVoid(true);
+
+  mEverInForeground = false;
 }
 
 void
 nsDocument::ClearAllBoxObjects()
 {
   if (mBoxObjectTable) {
     for (auto iter = mBoxObjectTable->Iter(); !iter.Done(); iter.Next()) {
       nsPIBoxObject* boxObject = iter.UserData();
@@ -10321,16 +10324,32 @@ nsDocument::AddResponsiveContent(nsICont
 void
 nsDocument::RemoveResponsiveContent(nsIContent* aContent)
 {
   MOZ_ASSERT(aContent);
   mResponsiveContent.RemoveEntry(aContent);
 }
 
 void
+nsDocument::AddMediaContent(nsIContent* aContent)
+{
+  MOZ_ASSERT(aContent);
+  MOZ_ASSERT(aContent->IsHTMLElement(nsGkAtoms::video) ||
+             aContent->IsHTMLElement(nsGkAtoms::audio));
+  mMediaContent.PutEntry(aContent);
+}
+
+void
+nsDocument::RemoveMediaContent(nsIContent* aContent)
+{
+  MOZ_ASSERT(aContent);
+  mMediaContent.RemoveEntry(aContent);
+}
+
+void
 nsDocument::NotifyMediaFeatureValuesChanged()
 {
   for (auto iter = mResponsiveContent.ConstIter(); !iter.Done();
        iter.Next()) {
     nsCOMPtr<nsIContent> content = iter.Get()->GetKey();
     if (content->IsHTMLElement(nsGkAtoms::img)) {
       auto* imageElement = static_cast<HTMLImageElement*>(content.get());
       imageElement->MediaFeatureValuesChanged();
@@ -12188,20 +12207,29 @@ nsDocument::PostVisibilityUpdateEvent()
   nsCOMPtr<nsIRunnable> event =
     NewRunnableMethod(this, &nsDocument::UpdateVisibilityState);
   Dispatch("nsDocument::UpdateVisibilityState", TaskCategory::Other, event.forget());
 }
 
 void
 nsDocument::MaybeActiveMediaComponents()
 {
+  if (mEverInForeground) {
+    return;
+  }
+
   if (!mWindow) {
     return;
   }
 
+  if (mMediaContent.IsEmpty()) {
+    return;
+  }
+
+  mEverInForeground = true;
   GetWindow()->MaybeActiveMediaComponents();
 }
 
 NS_IMETHODIMP
 nsDocument::GetHidden(bool* aHidden)
 {
   *aHidden = Hidden();
   return NS_OK;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -1017,16 +1017,23 @@ public:
   virtual nsresult AddResponsiveContent(nsIContent* aContent) override;
   // Removes an element from mResponsiveContent when the element is
   // removed from the tree.
   virtual void RemoveResponsiveContent(nsIContent* aContent) override;
   // Notifies any responsive content added by AddResponsiveContent upon media
   // features values changing.
   virtual void NotifyMediaFeatureValuesChanged() override;
 
+  // Adds an element to mMediaContent when the element is added to the tree.
+  virtual void AddMediaContent(nsIContent* aContent) override;
+
+  // Removes an element from mMediaContent when the element is removed from
+  // the tree.
+  virtual void RemoveMediaContent(nsIContent* aContent) override;
+
   virtual nsresult GetStateObject(nsIVariant** aResult) override;
 
   virtual nsDOMNavigationTiming* GetNavigationTiming() const override;
   virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) override;
 
   virtual Element* FindImageMap(const nsAString& aNormalizedMapName) override;
 
   virtual nsTArray<Element*> GetFullscreenStack() const override;
@@ -1569,16 +1576,19 @@ private:
   // state so we can provide useful assertions to consumers of ForgetLink and
   // AddStyleRelevantLink.
   bool mStyledLinksCleared;
 #endif
 
   // A set of responsive images keyed by address pointer.
   nsTHashtable< nsPtrHashKey<nsIContent> > mResponsiveContent;
 
+  // A set of media elements keyed by address pointer.
+  nsTHashtable<nsPtrHashKey<nsIContent>> mMediaContent;
+
   // Member to store out last-selected stylesheet set.
   nsString mLastStyleSheetSet;
 
   nsTArray<RefPtr<nsFrameLoader> > mInitializableFrameLoaders;
   nsTArray<nsCOMPtr<nsIRunnable> > mFrameLoaderFinalizers;
   RefPtr<nsRunnableMethod<nsDocument> > mFrameLoaderRunner;
 
   nsCOMPtr<nsIRunnable> mMaybeEndOutermostXBLUpdateRunner;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -984,18 +984,17 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMW
   mMediaSuspend(Preferences::GetBool("media.block-autoplay-until-in-foreground", true) ?
     nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
   mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
   mDesktopModeViewport(false), mIsRootOuterWindow(false), mInnerWindow(nullptr),
   mOuterWindow(aOuterWindow),
   // Make sure no actual window ends up with mWindowID == 0
   mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
   mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
-  mLargeAllocStatus(LargeAllocStatus::NONE),
-  mShouldResumeOnFirstActiveMediaComponent(false)
+  mLargeAllocStatus(LargeAllocStatus::NONE)
 {
   if (aOuterWindow) {
     mTimeoutManager =
       MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindow::Cast(AsInner()));
   }
 }
 
 template<class T>
@@ -4344,57 +4343,49 @@ bool
 nsPIDOMWindowInner::IsRunningTimeout()
 {
   return TimeoutManager().IsRunningTimeout();
 }
 
 void
 nsPIDOMWindowOuter::NotifyCreatedNewMediaComponent()
 {
-  // We would only active media component when there is any alive one.
-  mShouldResumeOnFirstActiveMediaComponent = true;
+  if (mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
+    return;
+  }
 
   // If the document is already on the foreground but the suspend state is still
   // suspend-block, that means the media component was created after calling
   // MaybeActiveMediaComponents, so the window's suspend state doesn't be
   // changed yet. Therefore, we need to call it again, because the state is only
   // changed after there exists alive media within the window.
   MaybeActiveMediaComponents();
 }
 
 void
 nsPIDOMWindowOuter::MaybeActiveMediaComponents()
 {
   if (IsInnerWindow()) {
     return mOuterWindow->MaybeActiveMediaComponents();
   }
 
-  // Resume the media when the tab was blocked and the tab already has
-  // alive media components.
-  if (!mShouldResumeOnFirstActiveMediaComponent ||
-      mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
-    return;
-  }
-
   nsCOMPtr<nsPIDOMWindowInner> inner = GetCurrentInnerWindow();
   if (!inner) {
     return;
   }
 
-  // If the document is not visible, don't need to resume it.
   nsCOMPtr<nsIDocument> doc = inner->GetExtantDoc();
-  if (!doc || doc->Hidden()) {
-    return;
-  }
-
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("nsPIDOMWindowOuter, MaybeActiveMediaComponents, "
-          "resume the window from blocked, this = %p\n", this));
-
-  SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
+  if (!doc) {
+    return;
+  }
+
+  if (!doc->Hidden() &&
+      mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK) {
+    SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
+  }
 }
 
 SuspendTypes
 nsPIDOMWindowOuter::GetMediaSuspend() const
 {
   if (IsInnerWindow()) {
     return mOuterWindow->GetMediaSuspend();
   }
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2436,16 +2436,19 @@ public:
   virtual nsresult AddPlugin(nsIObjectLoadingContent* aPlugin) = 0;
   virtual void RemovePlugin(nsIObjectLoadingContent* aPlugin) = 0;
   virtual void GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) = 0;
 
   virtual nsresult AddResponsiveContent(nsIContent* aContent) = 0;
   virtual void RemoveResponsiveContent(nsIContent* aContent) = 0;
   virtual void NotifyMediaFeatureValuesChanged() = 0;
 
+  virtual void AddMediaContent(nsIContent* aContent) = 0;
+  virtual void RemoveMediaContent(nsIContent* aContent) = 0;
+
   virtual nsresult GetStateObject(nsIVariant** aResult) = 0;
 
   virtual nsDOMNavigationTiming* GetNavigationTiming() const = 0;
 
   virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) = 0;
 
   virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0;
 
@@ -3178,16 +3181,19 @@ protected:
   bool mFontFaceSetDirty : 1;
 
   // Has GetUserFontSet() been called?
   bool mGetUserFontSetCalled : 1;
 
   // Do we currently have an event posted to call FlushUserFontSet?
   bool mPostedFlushUserFontSet : 1;
 
+  // True is document has ever been in a foreground window.
+  bool mEverInForeground : 1;
+
   // Compatibility mode
   nsCompatibility mCompatMode;
 
   // Our readyState
   ReadyState mReadyState;
 
   // Whether this document has (or will have, once we have a pres shell) a
   // Gecko- or Servo-backed style system.
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -732,20 +732,16 @@ protected:
 
   uint32_t mMarkedCCGeneration;
 
   // Let the service workers plumbing know that some feature are enabled while
   // testing.
   bool mServiceWorkersTestingEnabled;
 
   mozilla::dom::LargeAllocStatus mLargeAllocStatus; // Outer window only
-
-  // When there is any created alive media component, we can consider to resume
-  // the media content in the window.
-  bool mShouldResumeOnFirstActiveMediaComponent;
 };
 
 #define NS_PIDOMWINDOWINNER_IID \
 { 0x775dabc9, 0x8f43, 0x4277, \
   { 0x9a, 0xdb, 0xf1, 0x99, 0x0d, 0x77, 0xcf, 0xfb } }
 
 #define NS_PIDOMWINDOWOUTER_IID \
   { 0x769693d4, 0xb009, 0x4fe2, \
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -687,18 +687,17 @@ public:
 
   NS_IMETHODIMP
   WindowVolumeChanged(float aVolume, bool aMuted) override
   {
     MOZ_ASSERT(mAudioChannelAgent);
 
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
            ("HTMLMediaElement::AudioChannelAgentCallback, WindowVolumeChanged, "
-            "this = %p, aVolume = %f, aMuted = %s\n",
-            this, aVolume, aMuted ? "true" : "false"));
+            "this = %p, aVolume = %f, aMuted = %d\n", this, aVolume, aMuted));
 
     if (mAudioChannelVolume != aVolume) {
       mAudioChannelVolume = aVolume;
       mOwner->SetVolumeInternal();
     }
 
     const uint32_t muted = mOwner->mMuted;
     if (aMuted && !mOwner->ComputedMuted()) {
@@ -712,17 +711,17 @@ public:
 
   NS_IMETHODIMP
   WindowSuspendChanged(SuspendTypes aSuspend) override
   {
     MOZ_ASSERT(mAudioChannelAgent);
 
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
            ("HTMLMediaElement::AudioChannelAgentCallback, WindowSuspendChanged, "
-            "this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
+            "this = %p, aSuspend = %d\n", this, aSuspend));
 
     switch (aSuspend) {
       case nsISuspendedTypes::NONE_SUSPENDED:
         Resume();
         break;
       case nsISuspendedTypes::SUSPENDED_PAUSE:
       case nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE:
       case nsISuspendedTypes::SUSPENDED_BLOCK:
@@ -879,17 +878,17 @@ private:
     if (mSuspended == aSuspend) {
       return;
     }
 
     MaybeNotifyMediaResumed(aSuspend);
     mSuspended = aSuspend;
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
            ("HTMLMediaElement::AudioChannelAgentCallback, SetAudioChannelSuspended, "
-            "this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
+            "this = %p, aSuspend = %d\n", this, aSuspend));
 
     NotifyAudioPlaybackChanged(
       AudioChannelService::AudibleChangedReasons::ePauseStateChanged);
   }
 
   void
   Resume()
   {
@@ -4305,16 +4304,17 @@ nsresult HTMLMediaElement::BindToTree(ns
 
   if (aDocument) {
     mAutoplayEnabled =
       IsAutoplayEnabled() && (!aDocument || !aDocument->IsStaticDocument()) &&
       !IsEditable();
     // The preload action depends on the value of the autoplay attribute.
     // It's value may have changed, so update it.
     UpdatePreloadAction();
+    aDocument->AddMediaContent(this);
   }
 
   NotifyDecoderActivityChanges();
 
   return rv;
 }
 
 /* static */
@@ -4537,16 +4537,19 @@ HTMLMediaElement::ReportTelemetry()
   }
 }
 
 void HTMLMediaElement::UnbindFromTree(bool aDeep,
                                       bool aNullParent)
 {
   mUnboundFromTree = true;
   mVisibilityState = Visibility::UNTRACKED;
+  if (OwnerDoc()) {
+    OwnerDoc()->RemoveMediaContent(this);
+  }
 
   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
 
   MOZ_ASSERT(IsHidden());
   NotifyDecoderActivityChanges();
 
   RefPtr<HTMLMediaElement> self(this);
   nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([self] () {
--- a/dom/media/webaudio/AudioDestinationNode.cpp
+++ b/dom/media/webaudio/AudioDestinationNode.cpp
@@ -502,21 +502,16 @@ AudioDestinationNode::StartRendering(Pro
 
 NS_IMETHODIMP
 AudioDestinationNode::WindowVolumeChanged(float aVolume, bool aMuted)
 {
   if (!mStream) {
     return NS_OK;
   }
 
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("AudioDestinationNode, WindowVolumeChanged, "
-          "this = %p, aVolume = %f, aMuted = %s\n",
-          this, aVolume, aMuted ? "true" : "false"));
-
   float volume = aMuted ? 0.0 : aVolume;
   mStream->SetAudioOutputVolume(&gWebAudioOutputKey, volume);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AudioDestinationNode::WindowSuspendChanged(nsSuspendedTypes aSuspend)
 {
@@ -524,20 +519,16 @@ AudioDestinationNode::WindowSuspendChang
     return NS_OK;
   }
 
   bool suspended = (aSuspend != nsISuspendedTypes::NONE_SUSPENDED);
   if (mAudioChannelSuspended == suspended) {
     return NS_OK;
   }
 
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("AudioDestinationNode, WindowSuspendChanged, "
-          "this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
-
   mAudioChannelSuspended = suspended;
   Context()->DispatchTrustedEvent(!suspended ?
     NS_LITERAL_STRING("mozinterruptend") :
     NS_LITERAL_STRING("mozinterruptbegin"));
 
   DisabledTrackMode disabledMode = suspended ? DisabledTrackMode::SILENCE_BLACK
                                              : DisabledTrackMode::ENABLED;
   mStream->SetTrackEnabled(AudioNodeStream::AUDIO_TRACK, disabledMode);
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1733,21 +1733,16 @@ nsNPAPIPluginInstance::GetOrCreateAudioC
   nsCOMPtr<nsIAudioChannelAgent> agent = mAudioChannelAgent;
   agent.forget(aAgent);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
 {
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("nsNPAPIPluginInstance, WindowVolumeChanged, "
-          "this = %p, aVolume = %f, aMuted = %s\n",
-          this, aVolume, aMuted ? "true" : "false"));
-
   // We just support mute/unmute
   nsresult rv = SetMuted(aMuted);
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetMuted failed");
   if (mMuted != aMuted) {
     mMuted = aMuted;
     if (mAudioChannelAgent) {
       AudioChannelService::AudibleState audible = aMuted ?
         AudioChannelService::AudibleState::eNotAudible :
@@ -1757,20 +1752,16 @@ nsNPAPIPluginInstance::WindowVolumeChang
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
 {
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("nsNPAPIPluginInstance, WindowSuspendChanged, "
-          "this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
-
   // It doesn't support suspended, so we just do something like mute/unmute.
   WindowVolumeChanged(1.0, /* useless */
                       aSuspend != nsISuspendedTypes::NONE_SUSPENDED);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNPAPIPluginInstance::WindowAudioCaptureChanged(bool aCapture)
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -1,83 +1,78 @@
 [DEFAULT]
 support-files =
-  audio.ogg
-  empty.png
+  head.js
+  file_blockMedia_shouldPlay.html
   file_blockMedia_shouldNotPlay.html
-  file_blockMedia_shouldPlay.html
   file_contentTitle.html
   file_mediaPlayback.html
   file_mediaPlayback2.html
   file_mediaPlaybackFrame.html
   file_mediaPlaybackFrame2.html
   file_multipleAudio.html
   file_multiplePlayingAudio.html
   file_nonAutoplayAudio.html
-  file_plugIn.html
-  file_redirect.html
-  file_redirect_to.html
   file_silentAudioTrack.html
-  file_webAudio.html
-  head.js
-  image.jpg
-  image_page.html
+  audio.ogg
   silentAudioTrack.webm
 
 [browser_audioCompeting.js]
 tags = audiochannel
 [browser_audioCompeting_onlyForActiveAgent.js]
 tags = audiochannel
 [browser_autoscroll_disabled.js]
 [browser_block_autoplay_media.js]
 tags = audiochannel
+[browser_block_silentAudioTrack_media.js]
+tags = audiochannel
 [browser_block_autoplay_media_pausedAfterPlay.js]
  tags = audiochannel
-[browser_block_autoplay_playAfterTabVisible.js]
-tags = audiochannel
-[browser_block_notInTreeAudio.js]
-tags = audiochannel
 [browser_block_playMediaInMuteTab.js]
 tags = audiochannel
-[browser_block_plugIn.js]
-tags = audiochannel
-[browser_block_silentAudioTrack_media.js]
+[browser_block_autoplay_playAfterTabVisible.js]
 tags = audiochannel
-[browser_block_webAudio.js]
-tags = audiochannel
-[browser_bug1170531.js]
-[browser_bug1198465.js]
 [browser_bug295977_autoscroll_overflow.js]
 [browser_bug451286.js]
 skip-if = !e10s
 [browser_bug594509.js]
 [browser_bug982298.js]
-[browser_content_url_annotation.js]
-skip-if = !e10s || !crashreporter
+[browser_bug1198465.js]
 [browser_contentTitle.js]
 [browser_crash_previous_frameloader.js]
 run-if = e10s && crashreporter
 [browser_default_image_filename.js]
 [browser_f7_caret_browsing.js]
 [browser_findbar.js]
+[browser_label_textlink.js]
 [browser_isSynthetic.js]
+support-files =
+  empty.png
 [browser_keyevents_during_autoscrolling.js]
-[browser_label_textlink.js]
+[browser_save_resend_postdata.js]
+support-files =
+  common/mockTransfer.js
+  data/post_form_inner.sjs
+  data/post_form_outer.sjs
+skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.getElementById("postForm").submit();)
+[browser_content_url_annotation.js]
+skip-if = !e10s || !crashreporter
+support-files =
+  file_redirect.html
+  file_redirect_to.html
+[browser_bug1170531.js]
 [browser_mediaPlayback.js]
 tags = audiochannel
 [browser_mediaPlayback_mute.js]
 tags = audiochannel
 [browser_mediaPlayback_suspended.js]
 tags = audiochannel
 [browser_mediaPlayback_suspended_multipleAudio.js]
 tags = audiochannel
 [browser_mute.js]
 tags = audiochannel
 [browser_mute2.js]
 tags = audiochannel
 [browser_quickfind_editable.js]
-[browser_save_resend_postdata.js]
+[browser_saveImageURL.js]
 support-files =
-  common/mockTransfer.js
-  data/post_form_inner.sjs
-  data/post_form_outer.sjs
-skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.getElementById("postForm").submit();)
-[browser_saveImageURL.js]
+  image.jpg
+  image_page.html
deleted file mode 100644
--- a/toolkit/content/tests/browser/browser_block_notInTreeAudio.js
+++ /dev/null
@@ -1,87 +0,0 @@
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_nonAutoplayAudio.html";
-
-var SuspendedType = {
-  NONE_SUSPENDED             : 0,
-  SUSPENDED_PAUSE            : 1,
-  SUSPENDED_BLOCK            : 2,
-  SUSPENDED_PAUSE_DISPOSABLE : 3
-};
-
-function check_audio_suspended(suspendedType) {
-  var audio = content.document.getElementById("testAudio");
-  if (!audio) {
-    ok(false, "Can't get the audio element!");
-  }
-
-  is(audio.computedSuspended, suspendedType,
-     "The suspeded state of audio is correct.");
-}
-
-function check_audio_pause_state(expectPause) {
-  var audio = content.document.getElementById("testAudio");
-  if (!audio) {
-    ok(false, "Can't get the audio element!");
-  }
-
-  is(audio.paused, expectPause,
-    "The pause state of audio is corret.")
-}
-
-function play_not_in_tree_audio() {
-  var audio = content.document.getElementById("testAudio");
-  if (!audio) {
-    ok(false, "Can't get the audio element!");
-  }
-
-  content.document.body.removeChild(audio);
-
-  // Add timeout to ensure the audio is removed from DOM tree.
-  setTimeout(function() {
-    info("Prepare to start playing audio.");
-    audio.play();
-  }, 1000);
-}
-
-add_task(function* setup_test_preference() {
-  yield SpecialPowers.pushPrefEnv({"set": [
-    ["media.useAudioChannelService.testing", true],
-    ["media.block-autoplay-until-in-foreground", true]
-  ]});
-});
-
-add_task(function* block_not_in_tree_media() {
-  info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
-  tab.linkedBrowser.loadURI(PAGE);
-  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-
-  info("- tab should not be blocked -");
-  yield waitForTabBlockEvent(tab, false);
-
-  info("- check audio's suspend state -");
-  yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
-                          check_audio_suspended);
-
-  info("- check audio's playing state -");
-  yield ContentTask.spawn(tab.linkedBrowser, true,
-                          check_audio_pause_state);
-
-  info("- playing audio -");
-  yield ContentTask.spawn(tab.linkedBrowser, null,
-                          play_not_in_tree_audio);
-
-  info("- tab should be blocked -");
-  yield waitForTabBlockEvent(tab, true);
-
-  info("- switch tab -");
-  yield BrowserTestUtils.switchTab(window.gBrowser, tab);
-
-  info("- tab should be resumed -");
-  yield waitForTabBlockEvent(tab, false);
-
-  info("- tab should be audible -");
-  yield waitForTabPlayingEvent(tab, true);
-
-  info("- remove tab -");
-  yield BrowserTestUtils.removeTab(tab);
-});
deleted file mode 100644
--- a/toolkit/content/tests/browser/browser_block_plugIn.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_plugIn.html";
-
-add_task(function* setup_test_preference() {
-  setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
-  yield SpecialPowers.pushPrefEnv({"set": [
-    ["media.useAudioChannelService.testing", true],
-    ["media.block-autoplay-until-in-foreground", true]
-  ]});
-});
-
-add_task(function* block_plug_in() {
-  info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
-  tab.linkedBrowser.loadURI(PAGE);
-  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-
-  info("- tab should be blocked -");
-  yield waitForTabBlockEvent(tab, true);
-
-  info("- switch tab -");
-  yield BrowserTestUtils.switchTab(window.gBrowser, tab);
-
-  info("- tab should be resumed -");
-  yield waitForTabBlockEvent(tab, false);
-
-  info("- tab should be audible -");
-  yield waitForTabPlayingEvent(tab, true);
-
-  info("- remove tab -");
-  yield BrowserTestUtils.removeTab(tab);
-});
deleted file mode 100644
--- a/toolkit/content/tests/browser/browser_block_webAudio.js
+++ /dev/null
@@ -1,30 +0,0 @@
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_webAudio.html";
-
-add_task(function* setup_test_preference() {
-  yield SpecialPowers.pushPrefEnv({"set": [
-    ["media.useAudioChannelService.testing", true],
-    ["media.block-autoplay-until-in-foreground", true]
-  ]});
-});
-
-add_task(function* block_web_audio() {
-  info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
-  tab.linkedBrowser.loadURI(PAGE);
-  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-
-  info("- tab should be blocked -");
-  yield waitForTabBlockEvent(tab, true);
-
-  info("- switch tab -");
-  yield BrowserTestUtils.switchTab(window.gBrowser, tab);
-
-  info("- tab should be resumed -");
-  yield waitForTabBlockEvent(tab, false);
-
-  info("- tab should be audible -");
-  yield waitForTabPlayingEvent(tab, true);
-
-  info("- remove tab -");
-  yield BrowserTestUtils.removeTab(tab);
-});
--- a/toolkit/content/tests/browser/file_nonAutoplayAudio.html
+++ b/toolkit/content/tests/browser/file_nonAutoplayAudio.html
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <head>
   <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
   <meta content="utf-8" http-equiv="encoding">
 </head>
 <body>
-<audio id="testAudio" src="audio.ogg" loop></audio>
\ No newline at end of file
+<audio id="testAudio" src="audio.ogg"></audio>
\ No newline at end of file
deleted file mode 100644
--- a/toolkit/content/tests/browser/file_plugIn.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<embed type="application/x-test" width="200" height="200"></embed>
-<script>
-var plugin = document.querySelector("embed");
-onload = function() {
-  plugin.startAudioPlayback();
-};
-</script>
\ No newline at end of file
deleted file mode 100644
--- a/toolkit/content/tests/browser/file_webAudio.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<head>
-  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
-  <meta content="utf-8" http-equiv="encoding">
-</head>
-<script type="text/javascript">
-  var ac = new AudioContext();
-  var dest = ac.destination;
-  var osc = ac.createOscillator();
-  osc.connect(dest);
-  osc.start();
-</script>
-<body>
-</body>
\ No newline at end of file
--- a/toolkit/content/tests/browser/head.js
+++ b/toolkit/content/tests/browser/head.js
@@ -62,39 +62,8 @@ function* waitForTabPlayingEvent(tab, ex
       if (event.detail.changed.indexOf("soundplaying") >= 0) {
         is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
         return true;
       }
       return false;
     });
   }
 }
-
-function getTestPlugin(pluginName) {
-  var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
-                                 .getService(SpecialPowers.Ci.nsIPluginHost);
-  var tags = ph.getPluginTags();
-  var name = pluginName || "Test Plug-in";
-  for (var tag of tags) {
-    if (tag.name == name) {
-      return tag;
-    }
-  }
-
-  ok(false, "Could not find plugin tag with plugin name '" + name + "'");
-  return null;
-}
-
-function setTestPluginEnabledState(newEnabledState, pluginName) {
-  var oldEnabledState = SpecialPowers.setTestPluginEnabledState(newEnabledState, pluginName);
-  if (!oldEnabledState) {
-    return;
-  }
-  var plugin = getTestPlugin(pluginName);
-  while (plugin.enabledState != newEnabledState) {
-    // Run a nested event loop to wait for the preference change to
-    // propagate to the child. Yuck!
-    SpecialPowers.Services.tm.currentThread.processNextEvent(true);
-  }
-  SimpleTest.registerCleanupFunction(function() {
-    SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
-  });
-}