Bug 1340191 - reverse the checking condition. r=sebastian
authorAlastor Wu <alwu@mozilla.com>
Wed, 22 Feb 2017 15:51:08 +0800
changeset 344353 9294b1e9b7e2c0b0b6a74e4d22634874433f11e4
parent 344352 34202e15401144849de180fa3f290e1ad0da4195
child 344354 cbf216f00dba92561fdd37df679e92e4b146aa60
push id31407
push usercbook@mozilla.com
push dateThu, 23 Feb 2017 13:58:01 +0000
treeherdermozilla-central@27dade5e0c83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1340191
milestone54.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 1340191 - reverse the checking condition. r=sebastian 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
@@ -4578,29 +4578,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) {