Backed out 5 changesets (bug 1328058) for timing out in browser_block_silentAudioTrack_media.js
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 02 Feb 2017 20:59:34 -0800
changeset 332345 8c32b1b8aa9218ce143ad42671cbe3a42ad17327
parent 332344 5d641acb1f4ec08ea58ac83cd1359db19176a270
child 332346 b3d1819dc7b463c3c28be21ac72f74c60c700c68
push id31303
push usercbook@mozilla.com
push dateFri, 03 Feb 2017 12:23:51 +0000
treeherdermozilla-central@28bb04d0338d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1328058
milestone54.0a1
backs out0c48cff3db5d9e904c943694e24cdd0b6565c45d
37d35ca95b1fd6efbd576190d007a2ec6e6c90c0
0c177bdf5ec302d937f1c428e78c3ad2a96ed838
b369d9999b8a7dcaf4809ff9697f03e47d0ef393
61dbcbe35565c51cbc50f1123bee7c383731cd7c
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 5 changesets (bug 1328058) for timing out in browser_block_silentAudioTrack_media.js CLOSED TREE Backed out changeset 0c48cff3db5d (bug 1328058) Backed out changeset 37d35ca95b1f (bug 1328058) Backed out changeset 0c177bdf5ec3 (bug 1328058) Backed out changeset b369d9999b8a (bug 1328058) Backed out changeset 61dbcbe35565 (bug 1328058)
browser/base/content/tabbrowser.xml
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
toolkit/content/browser-content.js
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_block_silentAudioTrack_media.js
toolkit/content/tests/browser/file_silentAudioTrack.html
toolkit/content/tests/browser/silentAudioTrack.mp4
toolkit/content/widgets/browser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -7104,16 +7104,24 @@
           let browser = this.linkedBrowser;
           let modifiedAttrs = [];
           let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED");
 
           if (browser.audioBlocked) {
             this.removeAttribute("blocked");
             modifiedAttrs.push("blocked");
 
+            // We don't want sound icon flickering between "blocked", "none" and
+            // "sound-playing", here adding the "soundplaying" is to keep the
+            // transition smoothly.
+            if (!this.hasAttribute("soundplaying")) {
+              this.setAttribute("soundplaying", true);
+              modifiedAttrs.push("soundplaying");
+            }
+
             browser.resumeMedia();
             hist.add(3 /* unblockByClickingIcon */);
             this.finishMediaBlockTimer();
           } else {
             if (browser.audioMuted) {
               browser.unmute();
               this.removeAttribute("muted");
               BrowserUITelemetry.countTabMutingEvent("unmute", aMuteReason);
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -1054,39 +1054,16 @@ AudioChannelService::RefreshAgentsAudioF
     AudioChannelWindow* winData = iter.GetNext();
     if (winData->mOwningAudioFocus) {
       winData->AudioFocusChanged(aAgent, aActive);
     }
   }
 }
 
 void
-AudioChannelService::NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow)
-{
-  MOZ_ASSERT(aWindow);
-  MOZ_ASSERT(aWindow->IsOuterWindow());
-
-  nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
-  if (!topWindow) {
-    return;
-  }
-
-  AudioChannelWindow* winData = GetWindowData(topWindow->WindowID());
-  if (!winData) {
-    return;
-  }
-
-  if (!winData->mShouldSendBlockStopEvent) {
-    return;
-  }
-
-  winData->NotifyMediaBlockStop(aWindow);
-}
-
-void
 AudioChannelService::AudioChannelWindow::RequestAudioFocus(AudioChannelAgent* aAgent)
 {
   MOZ_ASSERT(aAgent);
 
   // Don't need to check audio focus for window-less agent.
   if (!aAgent->Window()) {
     return;
   }
@@ -1282,36 +1259,16 @@ AudioChannelService::AudioChannelWindow:
   RemoveAgentAndReduceAgentsNum(aAgent);
   AudioCapturedChanged(aAgent, AudioCaptureState::eNotCapturing);
   AudioAudibleChanged(aAgent,
                       AudibleState::eNotAudible,
                       AudibleChangedReasons::ePauseStateChanged);
 }
 
 void
-AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop(nsPIDOMWindowOuter* aWindow)
-{
-  mShouldSendBlockStopEvent = false;
-  // Can't use raw pointer for lamba variable capturing, use smart ptr.
-  nsCOMPtr<nsPIDOMWindowOuter> window = aWindow;
-  NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
-      nsCOMPtr<nsIObserverService> observerService =
-        services::GetObserverService();
-      if (NS_WARN_IF(!observerService)) {
-        return;
-      }
-
-      observerService->NotifyObservers(ToSupports(window),
-                                       "audio-playback",
-                                       u"blockStop");
-    })
-  );
-}
-
-void
 AudioChannelService::AudioChannelWindow::AppendAgentAndIncreaseAgentsNum(AudioChannelAgent* aAgent)
 {
   MOZ_ASSERT(aAgent);
   MOZ_ASSERT(!mAgents.Contains(aAgent));
 
   int32_t channel = aAgent->AudioChannelType();
   mAgents.AppendElement(aAgent);
 
@@ -1365,17 +1322,17 @@ AudioChannelService::AudioChannelWindow:
   if (aAudible == AudibleState::eAudible) {
     AppendAudibleAgentIfNotContained(aAgent, aReason);
   } else {
     RemoveAudibleAgentIfContained(aAgent, aReason);
   }
 
   NotifyAudioCompetingChanged(aAgent, aAudible == AudibleState::eAudible);
   if (aAudible != AudibleState::eNotAudible) {
-    MaybeNotifyMediaBlockStart(aAgent);
+    MaybeNotifyMediaBlocked(aAgent);
   }
 }
 
 void
 AudioChannelService::AudioChannelWindow::AppendAudibleAgentIfNotContained(AudioChannelAgent* aAgent,
                                                                           AudibleChangedReasons aReason)
 {
   MOZ_ASSERT(aAgent);
@@ -1442,17 +1399,17 @@ AudioChannelService::AudioChannelWindow:
 {
   RefPtr<NotifyChannelActiveRunnable> runnable =
     new NotifyChannelActiveRunnable(aWindowID, aChannel, aActive);
   DebugOnly<nsresult> rv = NS_DispatchToCurrentThread(runnable);
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
 }
 
 void
-AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannelAgent* aAgent)
+AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlocked(AudioChannelAgent* aAgent)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = aAgent->Window();
   if (!window) {
     return;
   }
 
   MOZ_ASSERT(window->IsOuterWindow());
   nsCOMPtr<nsPIDOMWindowInner> inner = window->GetCurrentInnerWindow();
@@ -1465,24 +1422,21 @@ AudioChannelService::AudioChannelWindow:
     return;
   }
 
   if (window->GetMediaSuspend() != nsISuspendedTypes::SUSPENDED_BLOCK ||
       !doc->Hidden()) {
     return;
   }
 
-  if (!mShouldSendBlockStopEvent) {
-      mShouldSendBlockStopEvent = true;
-      NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
-        nsCOMPtr<nsIObserverService> observerService =
-          services::GetObserverService();
-        if (NS_WARN_IF(!observerService)) {
-          return;
-        }
+  NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
+      nsCOMPtr<nsIObserverService> observerService =
+        services::GetObserverService();
+      if (NS_WARN_IF(!observerService)) {
+        return;
+      }
 
-        observerService->NotifyObservers(ToSupports(window),
-                                         "audio-playback",
-                                         u"blockStart");
-      })
-    );
-  }
+      observerService->NotifyObservers(ToSupports(window),
+                                       "audio-playback",
+                                       u"block");
+    })
+  );
 }
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -196,18 +196,16 @@ public:
 
   void Notify(uint64_t aWindowID);
 
   void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
                            bool aContentOrNormalChannel, bool aAnyChannel);
 
   void NotifyCreatedNewAgent(AudioChannelAgent* aAgent);
 
-  void NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow);
-
 private:
   AudioChannelService();
   ~AudioChannelService();
 
   void RefreshAgents(nsPIDOMWindowOuter* aWindow,
                      std::function<void(AudioChannelAgent*)> aFunc);
 
   static void CreateServiceIfNeeded();
@@ -242,47 +240,41 @@ private:
 
   class AudioChannelWindow final
   {
   public:
     explicit AudioChannelWindow(uint64_t aWindowID)
       : mWindowID(aWindowID)
       , mIsAudioCaptured(false)
       , mOwningAudioFocus(!AudioChannelService::IsEnableAudioCompeting())
-      , mShouldSendBlockStopEvent(false)
     {
       // Workaround for bug1183033, system channel type can always playback.
       mChannels[(int16_t)AudioChannel::System].mMuted = false;
     }
 
     void AudioFocusChanged(AudioChannelAgent* aNewPlayingAgent, bool aActive);
     void AudioAudibleChanged(AudioChannelAgent* aAgent,
                              AudibleState aAudible,
                              AudibleChangedReasons aReason);
 
     void AppendAgent(AudioChannelAgent* aAgent, AudibleState aAudible);
     void RemoveAgent(AudioChannelAgent* aAgent);
 
-    void NotifyMediaBlockStop(nsPIDOMWindowOuter* aWindow);
-
     uint64_t mWindowID;
     bool mIsAudioCaptured;
     AudioChannelConfig mChannels[NUMBER_OF_AUDIO_CHANNELS];
 
     // Raw pointer because the AudioChannelAgent must unregister itself.
     nsTObserverArray<AudioChannelAgent*> mAgents;
     nsTObserverArray<AudioChannelAgent*> mAudibleAgents;
 
     // Owning audio focus when the window starts playing audible sound, and
     // lose audio focus when other windows starts playing.
     bool mOwningAudioFocus;
 
-    // If we've dispatched "blockStart" event, we must dispatch another event
-    // "blockStop" when the window is resumed from suspend-block.
-    bool mShouldSendBlockStopEvent;
   private:
     void AudioCapturedChanged(AudioChannelAgent* aAgent,
                               AudioCaptureState aCapture);
 
     void AppendAudibleAgentIfNotContained(AudioChannelAgent* aAgent,
                                           AudibleChangedReasons aReason);
     void RemoveAudibleAgentIfContained(AudioChannelAgent* aAgent,
                                        AudibleChangedReasons aReason);
@@ -294,17 +286,17 @@ private:
     bool IsLastAudibleAgent() const;
 
     void NotifyAudioAudibleChanged(nsPIDOMWindowOuter* aWindow,
                                    AudibleState aAudible,
                                    AudibleChangedReasons aReason);
 
     void NotifyChannelActive(uint64_t aWindowID, AudioChannel aChannel,
                              bool aActive);
-    void MaybeNotifyMediaBlockStart(AudioChannelAgent* aAgent);
+    void MaybeNotifyMediaBlocked(AudioChannelAgent* aAgent);
 
     void RequestAudioFocus(AudioChannelAgent* aAgent);
     void NotifyAudioCompetingChanged(AudioChannelAgent* aAgent, bool aActive);
 
     uint32_t GetCompetingBehavior(AudioChannelAgent* aAgent,
                                   int32_t aIncomingChannelType,
                                   bool aIncomingChannelActive) const;
     bool IsAgentInvolvingInAudioCompeting(AudioChannelAgent* aAgent) const;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4225,35 +4225,22 @@ void
 nsPIDOMWindowOuter::SetMediaSuspend(SuspendTypes aSuspend)
 {
   if (IsInnerWindow()) {
     mOuterWindow->SetMediaSuspend(aSuspend);
     return;
   }
 
   if (!IsDisposableSuspend(aSuspend)) {
-    MaybeNotifyMediaResumedFromBlock(aSuspend);
     mMediaSuspend = aSuspend;
   }
 
   RefreshMediaElementsSuspend(aSuspend);
 }
 
-void
-nsPIDOMWindowOuter::MaybeNotifyMediaResumedFromBlock(SuspendTypes aSuspend)
-{
-  if (mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK &&
-      aSuspend == nsISuspendedTypes::NONE_SUSPENDED) {
-    RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-    if (service) {
-      service->NotifyMediaResumedFromBlock(GetOuterWindow());
-    }
-  }
-}
-
 bool
 nsPIDOMWindowOuter::GetAudioMuted() const
 {
   if (IsInnerWindow()) {
     return mOuterWindow->GetAudioMuted();
   }
 
   return mAudioMuted;
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -893,17 +893,16 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWin
 // NB: It's very very important that these two classes have identical vtables
 // and memory layout!
 class nsPIDOMWindowOuter : public nsPIDOMWindow<mozIDOMWindowProxy>
 {
 protected:
   void RefreshMediaElementsVolume();
   void RefreshMediaElementsSuspend(SuspendTypes aSuspend);
   bool IsDisposableSuspend(SuspendTypes aSuspend) const;
-  void MaybeNotifyMediaResumedFromBlock(SuspendTypes aSuspend);
 
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWOUTER_IID)
 
   static nsPIDOMWindowOuter* From(mozIDOMWindowProxy* aFrom) {
     return static_cast<nsPIDOMWindowOuter*>(aFrom);
   }
 
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -1011,20 +1011,18 @@ var AudioPlaybackListener = {
         break;
     }
   },
 
   observe(subject, topic, data) {
     if (topic === "audio-playback") {
       if (subject && subject.top == global.content) {
         let name = "AudioPlayback:";
-        if (data === "blockStart") {
-          name += "BlockStart";
-        } else if (data === "blockStop") {
-          name += "BlockStop";
+        if (data === "block") {
+          name += "Block";
         } else {
           name += (data === "active") ? "Start" : "Stop";
         }
         sendAsyncMessage(name);
       }
     } else if (topic == "AudioFocusChanged" || topic == "MediaControl") {
       this.handleMediaControlMessage(data);
     }
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -8,21 +8,16 @@ support-files =
 tags = audiochannel
 support-files =
   file_multipleAudio.html
 [browser_autoscroll_disabled.js]
 [browser_block_autoplay_media.js]
 tags = audiochannel
 support-files =
   file_multipleAudio.html
-[browser_block_silentAudioTrack_media.js]
-tags = audiochannel
-support-files =
-  file_silentAudioTrack.html
-  silentAudioTrack.mp4
 [browser_block_autoplay_media_pausedAfterPlay.js]
  tags = audiochannel
 support-files =
   file_blockMedia_shouldPlay.html
   file_blockMedia_shouldNotPlay.html
 [browser_bug295977_autoscroll_overflow.js]
 [browser_bug451286.js]
 skip-if = !e10s
deleted file mode 100644
--- a/toolkit/content/tests/browser/browser_block_silentAudioTrack_media.js
+++ /dev/null
@@ -1,149 +0,0 @@
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_silentAudioTrack.html";
-
-var SuspendedType = {
-  NONE_SUSPENDED             : 0,
-  SUSPENDED_PAUSE            : 1,
-  SUSPENDED_BLOCK            : 2,
-  SUSPENDED_PAUSE_DISPOSABLE : 3
-};
-
-function* wait_for_tab_playing_event(tab, expectPlaying) {
-  if (tab.soundPlaying == expectPlaying) {
-    ok(true, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
-  } else {
-    info("Playing state doens't match, wait for attributes changes.");
-    yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
-      if (event.detail.changed.indexOf("soundplaying") >= 0) {
-        is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
-        return true;
-      }
-      return false;
-    });
-  }
-}
-
-function* wait_for_tab_block_event(tab, expectBlocked) {
-  if (tab.soundBlocked == expectBlocked) {
-    ok(true, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
-  } else {
-    info("Block state doens't match, wait for attributes changes.");
-    yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
-      if (event.detail.changed.indexOf("blocked") >= 0) {
-        is(tab.soundBlocked, expectBlocked, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
-        return true;
-      }
-      return false;
-    });
-  }
-}
-
-function disable_non_test_mouse(disable) {
-  let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIDOMWindowUtils);
-  utils.disableNonTestMouseEvents(disable);
-}
-
-function* hover_icon(icon, tooltip) {
-  disable_non_test_mouse(true);
-
-  let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
-  EventUtils.synthesizeMouse(icon, 1, 1, {type: "mouseover"});
-  EventUtils.synthesizeMouse(icon, 2, 2, {type: "mousemove"});
-  EventUtils.synthesizeMouse(icon, 3, 3, {type: "mousemove"});
-  EventUtils.synthesizeMouse(icon, 4, 4, {type: "mousemove"});
-  return popupShownPromise;
-}
-
-function leave_icon(icon) {
-  EventUtils.synthesizeMouse(icon, 0, 0, {type: "mouseout"});
-  EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
-  EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
-  EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
-
-  disable_non_test_mouse(false);
-}
-
-function* click_unblock_icon(tab) {
-  let icon = document.getAnonymousElementByAttribute(tab, "anonid", "soundplaying-icon");
-
-  yield hover_icon(icon, document.getElementById("tabbrowser-tab-tooltip"));
-  EventUtils.synthesizeMouseAtCenter(icon, {button: 0});
-  leave_icon(icon);
-}
-
-function check_audio_suspended(suspendedType) {
-  var autoPlay = content.document.getElementById("autoplay");
-  if (!autoPlay) {
-    ok(false, "Can't get the audio element!");
-  }
-
-  is(autoPlay.computedSuspended, suspendedType,
-     "The suspeded state of autoplay audio is correct.");
-}
-
-add_task(function* setup_test_preference() {
-  yield SpecialPowers.pushPrefEnv({"set": [
-    ["media.useAudioChannelService.testing", true],
-    ["media.block-autoplay-until-in-foreground", true]
-  ]});
-});
-
-add_task(function* unblock_icon_should_disapear_after_resume_tab() {
-  info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
-  tab.linkedBrowser.loadURI(PAGE);
-  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-
-  info("- the suspend state of tab should be suspend-block -");
-  yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
-                          check_audio_suspended);
-
-  info("- tab should display unblocking icon -");
-  yield wait_for_tab_block_event(tab, true);
-
-  info("- select tab as foreground tab -");
-  yield BrowserTestUtils.switchTab(window.gBrowser, tab);
-
-  info("- the suspend state of tab should be none-suspend -");
-  yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
-                          check_audio_suspended);
-
-  info("- should not display unblocking icon -");
-  yield wait_for_tab_block_event(tab, false);
-
-  info("- should not display sound indicator icon -");
-  yield wait_for_tab_playing_event(tab, false);
-
-  info("- remove tab -");
-  yield BrowserTestUtils.removeTab(tab);
-});
-
-add_task(function* should_not_show_sound_indicator_after_resume_tab() {
-  info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
-  tab.linkedBrowser.loadURI(PAGE);
-  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-
-  info("- the suspend state of tab should be suspend-block -");
-  yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
-                          check_audio_suspended);
-
-  info("- tab should display unblocking icon -");
-  yield wait_for_tab_block_event(tab, true);
-
-  info("- click play tab icon -");
-  yield click_unblock_icon(tab);
-
-  info("- the suspend state of tab should be none-suspend -");
-  yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
-                          check_audio_suspended);
-
-  info("- should not display unblocking icon -");
-  yield wait_for_tab_block_event(tab, false);
-
-  info("- should not display sound indicator icon -");
-  yield wait_for_tab_playing_event(tab, false);
-
-  info("- remove tab -");
-  yield BrowserTestUtils.removeTab(tab);
-});
deleted file mode 100644
--- a/toolkit/content/tests/browser/file_silentAudioTrack.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!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="autoplay" src="silentAudioTrack.mp4"></audio>
-<script type="text/javascript">
-
-// In linux debug on try server, sometimes the download process would fail, so
-// we can't activate the "auto-play" or playing after receving "oncanplay".
-// Therefore, we just call play here.
-var audio = document.getElementById("autoplay");
-audio.loop = true;
-audio.play();
-
-</script>
-</body>
deleted file mode 100644
index a37ef724dcd472940fab3412701c5c7266c4c33f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -695,55 +695,47 @@
          readonly="true"/>
 
       <method name="audioPlaybackStarted">
         <body>
           <![CDATA[
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackStarted", true, false);
             this.dispatchEvent(event);
+            if (this._audioBlocked) {
+              this._audioBlocked = false;
+              event = document.createEvent("Events");
+              event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
+              this.dispatchEvent(event);
+            }
           ]]>
         </body>
       </method>
 
       <method name="audioPlaybackStopped">
         <body>
           <![CDATA[
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackStopped", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
-      <method name="audioPlaybackBlockStarted">
+      <method name="audioPlaybackBlocked">
         <body>
           <![CDATA[
             this._audioBlocked = true;
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackBlockStarted", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
-      <method name="audioPlaybackBlockStopped">
-        <body>
-          <![CDATA[
-            if (!this._audioBlocked) {
-              return;
-            }
-            this._audioBlocked = false;
-            let event = document.createEvent("Events");
-            event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
-            this.dispatchEvent(event);
-          ]]>
-        </body>
-      </method>
-
       <field name="_audioMuted">false</field>
       <property name="audioMuted"
                 onget="return this._audioMuted;"
                 readonly="true"/>
 
 
       <field name="_audioBlocked">false</field>
       <property name="audioBlocked"
@@ -962,18 +954,17 @@
           }
 
           if (this.messageManager) {
             this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
             this.messageManager.addMessageListener("Autoscroll:Start", this);
             this.messageManager.addMessageListener("Autoscroll:Cancel", this);
             this.messageManager.addMessageListener("AudioPlayback:Start", this);
             this.messageManager.addMessageListener("AudioPlayback:Stop", this);
-            this.messageManager.addMessageListener("AudioPlayback:BlockStart", this);
-            this.messageManager.addMessageListener("AudioPlayback:BlockStop", this);
+            this.messageManager.addMessageListener("AudioPlayback:Block", this);
 
             if (this.hasAttribute("selectmenulist")) {
               this.messageManager.addMessageListener("Forms:ShowDropDown", this);
               this.messageManager.addMessageListener("Forms:HideDropDown", this);
             }
 
           }
         ]]>
@@ -1061,21 +1052,18 @@
               this._autoScrollPopup.hidePopup();
               break;
             case "AudioPlayback:Start":
               this.audioPlaybackStarted();
               break;
             case "AudioPlayback:Stop":
               this.audioPlaybackStopped();
               break;
-            case "AudioPlayback:BlockStart":
-              this.audioPlaybackBlockStarted();
-              break;
-            case "AudioPlayback:BlockStop":
-              this.audioPlaybackBlockStopped();
+            case "AudioPlayback:Block":
+              this.audioPlaybackBlocked();
               break;
             case "Forms:ShowDropDown": {
               if (!this._selectParentHelper) {
                 this._selectParentHelper =
                   Cu.import("resource://gre/modules/SelectParentHelper.jsm", {}).SelectParentHelper;
               }
 
               let menulist = document.getElementById(this.getAttribute("selectmenulist"));