Bug 1505494 - not allow autoplay if we don't have a document. r=cpearce
authoralwu <alwu@mozilla.com>
Mon, 12 Nov 2018 17:39:51 +0000
changeset 505114 fe1869606e94
parent 505113 e0867651b222
child 505115 65987ae1dfca
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1505494
milestone65.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 1505494 - not allow autoplay if we don't have a document. r=cpearce In order to avoid the nullptr crash when using `approver`. Differential Revision: https://phabricator.services.mozilla.com/D11501
dom/media/AutoplayPolicy.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -86,16 +86,20 @@ IsWindowAllowedToPlay(nsPIDOMWindowInner
   // document. FeaturePolicy propagates the permission to any sub-documents if
   // they don't have special directives.
   if (!FeaturePolicyUtils::IsFeatureAllowed(aWindow->GetExtantDoc(),
                                             NS_LITERAL_STRING("autoplay"))) {
     return false;
   }
 
   nsIDocument* approver = ApproverDocOf(*aWindow->GetExtantDoc());
+  if (!approver) {
+    return false;
+  }
+
   if (nsContentUtils::IsExactSitePermAllow(approver->NodePrincipal(),
                                            "autoplay-media")) {
     AUTOPLAY_LOG("Allow autoplay as document has autoplay permission.");
     return true;
   }
 
   if (approver->HasBeenUserGestureActivated()) {
     AUTOPLAY_LOG("Allow autoplay as document activated by user gesture.");