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 445898 fe1869606e9429f9b71dc3eb693c543e5a62e7a6
parent 445897 e0867651b22246656dcf8a5b408b4d9641b90f07
child 445899 65987ae1dfca24cd89bf99803f78d298ca9029b8
push id35028
push usercsabou@mozilla.com
push dateMon, 12 Nov 2018 21:54:15 +0000
treeherdermozilla-central@05331fb8f533 [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.");