Bug 1192818 - part2 : only dispatch DOMAudioPlaybackStarted when there is audible sound. r=baku
☠☠ backed out by ee46f0aa4132 ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Tue, 21 Feb 2017 18:41:13 +0800
changeset 373037 042e5fbe7846af33ee8f5bfcf93913033ae7e334
parent 373036 38fa2ec33fa499fa7dbd49fabc9f043434604121
child 373038 52f41ac3440dac1609a58ec2b357b9885964773a
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1192818
milestone54.0a1
Bug 1192818 - part2 : only dispatch DOMAudioPlaybackStarted when there is audible sound. r=baku The DOMAudioPlaybackStarted event would affect the tabbrowser's attribute, "soundPlaying", and this attribute should indicate whether the tab is audible or not. However, in present codebase, even the tab has "soundplaying", it doens't mean the tab has audible sound, you need to check extra attribute, "muted". After applying this patch, tabbrowser can only own one of the attributes ("soundplaying" or "mute"). These attributes won't exist at the same time, so we can easily know whether the tab is audible by checking "soundPlaying". Let's see an example, step1. playing a playing audio - tab owns "soundPlaying" step2. mute the tab - tab owns "muted" step3. stop audio - tab owns "muted" step4. replay the audio - tab owns "muted" step5. unmute the tab - tab owns "soundPlaying" step6. stop audio - tab owns "" MozReview-Commit-ID: 50NorRbRIP
toolkit/content/widgets/browser.xml
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -693,16 +693,19 @@
       <!-- Obsolete name for blockedPopups. Used by android. -->
       <property name="pageReport"
          onget="return this.blockedPopups;"
          readonly="true"/>
 
       <method name="audioPlaybackStarted">
         <body>
           <![CDATA[
+            if (this._audioMuted) {
+              return;
+            }
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackStarted", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
       <method name="audioPlaybackStopped">