Bug 1340191 - Reverse the checking condition. r=sebastian, a=gchang
authorAlastor Wu <alwu@mozilla.com>
Wed, 22 Feb 2017 15:51:08 +0800
changeset 376548 29f91acdc27ff1f127c194d60b4642fc3284f626
parent 376547 c3e6050e17f11a9c8844c83d061b3ff277692c9a
child 376549 2690fd706b25499e45fd489a55adddcfbd9772ce
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, gchang
bugs1340191
milestone53.0a2
Bug 1340191 - Reverse the checking condition. r=sebastian, a=gchang Since BBC website puts their audio in another iframe, we can't get the media element to check its duration, so we always return false. The ideal way to fix it is to get every iframe and check its element, but I think it's not very easy to do considering the flexibility of using iframe and the cost time. First, if we want to get the information inside iframe, we need to listen the onload event, but it's async operation. If there are lots iframe, we need to spend lots time to wait every iframe. The worst situation is we got the nested iframe, it would need lots time and effect to wait every iframe loaded and get the element we want. Therefore, I would prefer the workaround which is to reverse the checking condition, that is we only check duration for the main window. MozReview-Commit-ID: F93BjbzRMXO
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -4483,29 +4483,29 @@ Tab.prototype = {
   ShouldNotifyMediaPlaybackChange: function(inactive) {
     // We don't want to show the media control interface for the short sound
     // which duration is smaller than the threshold. The basic unit is second.
     // Note : the streaming format's duration is infinite.
     const mediaDurationThreshold = 1.0;
 
     let audioElements = this.browser.contentDocument.getElementsByTagName("audio");
     for (let audio of audioElements) {
-      if (audio.paused == inactive && audio.duration > mediaDurationThreshold) {
-        return true;
+      if (audio.paused == inactive && audio.duration < mediaDurationThreshold) {
+        return false;
       }
     }
 
     let videoElements = this.browser.contentDocument.getElementsByTagName("video");
     for (let video of videoElements) {
-      if (video.paused == inactive && video.duration > mediaDurationThreshold) {
-        return true;
-      }
-    }
-
-    return false;
+      if (video.paused == inactive && video.duration < mediaDurationThreshold) {
+        return false;
+      }
+    }
+
+    return true;
   },
 
   observe: function(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "before-first-paint":
         // Is it on the top level?
         let contentDocument = aSubject;
         if (contentDocument == this.browser.contentDocument) {