Bug 1505494 - not allow autoplay if we don't have a document. r=cpearce a=jcristau
authoralwu <alwu@mozilla.com>
Mon, 12 Nov 2018 17:39:51 +0000
changeset 501233 466cc7c2f4c99f2149529201d46a03e54f9497e9
parent 501232 501a272c7aad0d0f18fe0cc2499e7892280e1a8d
child 501234 dd1c529945d9bd41e31b56651374e9a3ed81fa5f
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, jcristau
bugs1505494
milestone64.0
Bug 1505494 - not allow autoplay if we don't have a document. r=cpearce a=jcristau 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.");