Bug 1516598 - remove 'feature-policy' checking for autoplay policy. r=cpearce,baku
authorAlastor Wu <alwu@mozilla.com>
Tue, 12 Feb 2019 18:21:58 +0000
changeset 458775 204a7782dc0b
parent 458774 67b183ba1627
child 458776 c8e523ac7349
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, baku
bugs1516598
milestone67.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 1516598 - remove 'feature-policy' checking for autoplay policy. r=cpearce,baku From the following table, we can know the feature policy have no any effect for the autoplay result. That is, if the document has been gesture activated, we want to playback, regardless of the status of the feature policy. If the site has denied autoplay permission via feature policy, if the user gesture activates (clicks play) we still want to be able to play. Therefore, we can remove `feature-policy` checking. | gesture activated | autoplay feature policy status | allowed to play | |-------------------|--------------------------------|-----------------| | activated | allowed | true | | not activated | not allowed | false | | activated | not allowed | true | | not activated | allowed | false | Differential Revision: https://phabricator.services.mozilla.com/D18098
dom/media/AutoplayPolicy.cpp
dom/security/featurepolicy/FeaturePolicyUtils.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -83,26 +83,16 @@ static bool IsWindowAllowedToPlay(nsPIDO
         " permission.");
     return true;
   }
 
   if (!aWindow->GetExtantDoc()) {
     return false;
   }
 
-  // Here we are checking whether the current document is blocked via
-  // feature-policy, and further down we walk up the doc tree to the top level
-  // content document and check permissions etc on the top level content
-  // 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;
-  }
-
   Document* approver = ApproverDocOf(*aWindow->GetExtantDoc());
   if (!approver) {
     return false;
   }
 
   if (approver->HasBeenUserGestureActivated()) {
     AUTOPLAY_LOG("Allow autoplay as document activated by user gesture.");
     return true;
--- a/dom/security/featurepolicy/FeaturePolicyUtils.cpp
+++ b/dom/security/featurepolicy/FeaturePolicyUtils.cpp
@@ -20,16 +20,20 @@ struct FeatureMap {
   FeaturePolicyUtils::FeaturePolicyValue mDefaultAllowList;
 };
 
 /*
  * IMPORTANT: Do not change this list without review from a DOM peer _AND_ a
  * DOM Security peer!
  */
 static FeatureMap sSupportedFeatures[] = {
+    // We don't support 'autoplay' for now, because it would be overwrote by
+    // 'user-gesture-activation' policy. However, we can still keep it in the
+    // list as we might start supporting it after we use different autoplay
+    // policy.
     {"autoplay", FeaturePolicyUtils::FeaturePolicyValue::eAll},
     {"camera", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
     {"encrypted-media", FeaturePolicyUtils::FeaturePolicyValue::eAll},
     {"fullscreen", FeaturePolicyUtils::FeaturePolicyValue::eAll},
     {"geolocation", FeaturePolicyUtils::FeaturePolicyValue::eAll},
     {"microphone", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
     {"midi", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
     {"payment", FeaturePolicyUtils::FeaturePolicyValue::eAll},