Bug 1458383 - Remove browser mediaBlocked attribute. r=mikedeboer
authorChris Pearce <cpearce@mozilla.com>
Wed, 09 May 2018 14:45:39 +1200
changeset 418253 510dfe436e4ecbfcecb5e01d5b476d749094a791
parent 418252 a80de077d7402101f522ff866a391304e9863ee2
child 418254 97e9b87a9a553e6e3863d3ed96860570bf1bd526
push id63972
push usercpearce@mozilla.com
push dateTue, 15 May 2018 01:01:22 +0000
treeherderautoland@74dc3b5bb9aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1458383, 1347791
milestone62.0a1
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
Bug 1458383 - Remove browser mediaBlocked attribute. r=mikedeboer This is a partial backout of Bug 1347791 part 3; a5fbb7e2d1d0. a5fbb7e2d1d0 added a mediaBlocked attribute to the browser element, which tracked whether the tab has ever been in the foreground, so that this could be saved and restored in session restore. We don't session restore this anymore, so we can remove this attribute and associated event handlers. This also removes the media.autoplay* pref accesses which are accounted for in the test browser_preferencecs_usage.js, so remove those prefs from that test. MozReview-Commit-ID: HLeylLzEsW8
browser/base/content/test/performance/browser_preferences_usage.js
toolkit/content/browser-content.js
toolkit/content/widgets/browser.xml
--- a/browser/base/content/test/performance/browser_preferences_usage.js
+++ b/browser/base/content/test/performance/browser_preferences_usage.js
@@ -130,27 +130,19 @@ add_task(async function open_10_tabs() {
     "security.insecure_connection_text.pbmode.enabled": {
       min: 17,
       max: 25,
     },
     "dom.ipc.processCount": {
       min: 10,
       max: 15,
     },
-    "media.autoplay.enabled": {
-      min: 10,
-      max: 30,
-    },
     "browser.startup.record": {
       max: 20,
     },
-    "media.block-autoplay-until-in-foreground": {
-      min: 10,
-      max: 30,
-    },
     "dom.max_chrome_script_run_time": {
       max: 20,
     },
     "toolkit.cosmeticAnimations.enabled": {
       min: 5,
       max: 20,
     },
   };
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -1233,18 +1233,16 @@ var AudioPlaybackListener = {
   observe(subject, topic, data) {
     if (topic === "audio-playback") {
       if (subject && subject.top == global.content) {
         let name = "AudioPlayback:";
         if (data === "activeMediaBlockStart") {
           name += "ActiveMediaBlockStart";
         } else if (data === "activeMediaBlockStop") {
           name += "ActiveMediaBlockStop";
-        } else if (data == "mediaBlockStop") {
-          name += "MediaBlockStop";
         } else {
           name += (data === "active") ? "Start" : "Stop";
         }
         sendAsyncMessage(name);
       }
     }
   },
 
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -635,27 +635,25 @@
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackStopped", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
       <!--
-        When the pref "media.block-autoplay-until-in-foreground" is on, all
-        windows would be blocked by default in gecko. The "block" means the
-        autoplay media can't be started in that tab unless the tab has been
-        visited or resumed by tab's play tab icon. Since the window is blocked
-        by default, there's no method to signal entering that state.
-        (1) If the window is resumed, no matter it has autoplay media or not
-            - will call mediaBlockStopped()
-        (2) If the window has blocked any autoplay media
-            - will call activeMediaBlockStarted()
-        (3) If the window has resumed any autoplay media
-            - will call activeMediaBlockStopped()
+        When the pref "media.block-autoplay-until-in-foreground" is on,
+        Gecko delays starting playback of media resources in tabs until the
+        tab has been in the foreground or resumed by tab's play tab icon.
+        - When Gecko delays starting playback of a media resource in a window,
+        it sends a message to call activeMediaBlockStarted(). This causes the
+        tab audio indicator to show.
+        - When a tab is foregrounded, Gecko starts playing all delayed media
+        resources in that tab, and sends a message to call
+        activeMediaBlockStopped(). This causes the tab audio indicator to hide.
        -->
       <method name="activeMediaBlockStarted">
         <body>
           <![CDATA[
             this._hasAnyPlayingMediaBeenBlocked = true;
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackBlockStarted", true, false);
             this.dispatchEvent(event);
@@ -672,42 +670,21 @@
             this._hasAnyPlayingMediaBeenBlocked = false;
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
-      <method name="mediaBlockStopped">
-        <body>
-          <![CDATA[
-            this._mediaBlocked = false;
-          ]]>
-        </body>
-      </method>
-
       <field name="_audioMuted">false</field>
       <property name="audioMuted"
                 onget="return this._audioMuted;"
                 readonly="true"/>
 
-      <field name="_mediaBlocked">true</field>
-      <property name="mediaBlocked" readonly="true">
-        <getter>
-          <![CDATA[
-            if (this.mPrefs.getBoolPref("media.block-autoplay-until-in-foreground", true) &&
-                this.mPrefs.getBoolPref("media.autoplay.enabled", true)) {
-              return this._mediaBlocked;
-            }
-            return false;
-          ]]>
-        </getter>
-      </property>
-
       <field name="_hasAnyPlayingMediaBeenBlocked">false</field>
 
       <method name="mute">
         <parameter name="transientState"/>
         <body>
           <![CDATA[
             if (!transientState) {
               this._audioMuted = true;
@@ -752,17 +729,16 @@
                                                  {type: "mediaControlStopped"});
           ]]>
         </body>
       </method>
 
       <method name="resumeMedia">
         <body>
           <![CDATA[
-            this._mediaBlocked = false;
             this.messageManager.sendAsyncMessage("AudioPlayback",
                                                  {type: "resumeMedia"});
             if (this._hasAnyPlayingMediaBeenBlocked) {
               this._hasAnyPlayingMediaBeenBlocked = false;
               let event = document.createEvent("Events");
               event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
               this.dispatchEvent(event);
             }
@@ -910,17 +886,16 @@
           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:ActiveMediaBlockStart", this);
             this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStop", this);
-            this.messageManager.addMessageListener("AudioPlayback:MediaBlockStop", this);
             this.messageManager.addMessageListener("UnselectedTabHover:Toggle", this);
 
             if (this.hasAttribute("selectmenulist")) {
               this.messageManager.addMessageListener("Forms:ShowDropDown", this);
               this.messageManager.addMessageListener("Forms:HideDropDown", this);
             }
 
           }
@@ -1035,19 +1010,16 @@
               this.audioPlaybackStopped();
               break;
             case "AudioPlayback:ActiveMediaBlockStart":
               this.activeMediaBlockStarted();
               break;
             case "AudioPlayback:ActiveMediaBlockStop":
               this.activeMediaBlockStopped();
               break;
-            case "AudioPlayback:MediaBlockStop":
-              this.mediaBlockStopped();
-              break;
             case "UnselectedTabHover:Toggle":
               this._shouldSendUnselectedTabHover = data.enable ?
                 ++this._unselectedTabHoverMessageListenerCount > 0 :
                 --this._unselectedTabHoverMessageListenerCount == 0;
               break;
             case "Forms:ShowDropDown": {
               if (!this._selectParentHelper) {
                 this._selectParentHelper =