Bug 1483703 - part1 : allow media without audio track to autoplay. r=cpearce
authoralwu <alwu@mozilla.com>
Wed, 22 Aug 2018 23:31:58 +0000
changeset 490686 71ad474cdeeb928e303c2fb7eb5322402529b48b
parent 490685 a28f7398ddff28f51ee1ac68203a02286bca6367
child 490687 3326c0e920d4c9a180a26561a1a9d49b886c0eb7
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1483703
milestone63.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 1483703 - part1 : allow media without audio track to autoplay. r=cpearce We would allow media without audio track to autoplay after it had loaded the metadata. If media hasn't loaded metadata yet, we would treat it as audible media and then block it. Differential Revision: https://phabricator.services.mozilla.com/D3670
dom/media/AutoplayPolicy.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -138,17 +138,23 @@ IsMediaElementAllowedToPlay(const HTMLMe
   if (IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow())) {
     AUTOPLAY_LOG("Autoplay allowed as activated/whitelisted window, media %p.", &aElement);
     return true;
   }
 
   nsIDocument* topDocument = ApproverDocOf(*aElement.OwnerDoc());
   if (topDocument &&
       topDocument->MediaDocumentKind() == nsIDocument::MediaDocumentKind::Video) {
-    AUTOPLAY_LOG("Allow video document %p to autoplay\n", &aElement);
+    AUTOPLAY_LOG("Allow video document %p to autoplay", &aElement);
+    return true;
+  }
+
+  if (!aElement.HasAudio() &&
+      aElement.ReadyState() >= HTMLMediaElement_Binding::HAVE_METADATA) {
+    AUTOPLAY_LOG("Allow media %p without audio track to autoplay", &aElement);
     return true;
   }
 
   if (!aElement.HasAudio() &&
       aElement.ReadyState() >= HTMLMediaElement_Binding::HAVE_METADATA) {
     AUTOPLAY_LOG("Allow media without audio track %p to autoplay\n", &aElement);
     return true;
   }