Bug 1496037 - Default value for FeaturePolicy should be '*', r=ckerschb
☠☠ backed out by 9b895fc1db95 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 03 Oct 2018 17:01:34 +0200
changeset 495181 56ffd7466acc844c078e39a23d3bdc4a7e05394c
parent 495180 217d78349cb5b404b8999bc28291da3c086d61df
child 495182 a4b8f37b625d8e9e8d05b64eae60f5adbbccb8ab
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1496037
milestone64.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 1496037 - Default value for FeaturePolicy should be '*', r=ckerschb
dom/security/featurepolicy/FeaturePolicyUtils.cpp
dom/security/featurepolicy/test/mochitest/test_parser.html
testing/web-platform/meta/encrypted-media/clearkey-mp4-unique-origin.https.html.ini
testing/web-platform/meta/encrypted-media/encrypted-media-default-feature-policy.https.sub.html.ini
testing/web-platform/meta/feature-policy/payment-default-feature-policy.https.sub.html.ini
testing/web-platform/meta/webvr/webvr-enabled-by-feature-policy-attribute.https.sub.html.ini
--- a/dom/security/featurepolicy/FeaturePolicyUtils.cpp
+++ b/dom/security/featurepolicy/FeaturePolicyUtils.cpp
@@ -21,31 +21,31 @@ struct FeatureMap {
 };
 
 /*
  * IMPORTANT: Do not change this list without review from a DOM peer _AND_ a
  * DOM Security peer!
  */
 static FeatureMap sSupportedFeatures[] = {
   // TODO: not supported yet!!!
-  { "autoplay", FeatureMap::eSelf },
+  { "autoplay", FeatureMap::eAll },
   // TODO: not supported yet!!!
-  { "camera", FeatureMap::eSelf  },
-  { "encrypted-media", FeatureMap::eSelf  },
+  { "camera", FeatureMap::eAll  },
+  { "encrypted-media", FeatureMap::eAll  },
   // TODO: not supported yet!!!
-  { "fullscreen", FeatureMap::eSelf  },
+  { "fullscreen", FeatureMap::eAll  },
   // TODO: not supported yet!!!
-  { "geolocation", FeatureMap::eSelf  },
+  { "geolocation", FeatureMap::eAll  },
   // TODO: not supported yet!!!
-  { "microphone", FeatureMap::eSelf  },
-  { "midi", FeatureMap::eSelf  },
-  { "payment", FeatureMap::eSelf  },
+  { "microphone", FeatureMap::eAll  },
+  { "midi", FeatureMap::eAll  },
+  { "payment", FeatureMap::eAll  },
   // TODO: not supported yet!!!
-  { "speaker", FeatureMap::eSelf  },
-  { "vr", FeatureMap::eSelf  },
+  { "speaker", FeatureMap::eAll  },
+  { "vr", FeatureMap::eAll  },
 };
 
 /* static */ bool
 FeaturePolicyUtils::IsSupportedFeature(const nsAString& aFeatureName)
 {
   uint32_t numFeatures = (sizeof(sSupportedFeatures) / sizeof(sSupportedFeatures[0]));
   for (uint32_t i = 0; i < numFeatures; ++i) {
     if (aFeatureName.LowerCaseEqualsASCII(sSupportedFeatures[i].mFeatureName)) {
--- a/dom/security/featurepolicy/test/mochitest/test_parser.html
+++ b/dom/security/featurepolicy/test/mochitest/test_parser.html
@@ -21,17 +21,17 @@ function test_document() {
   ok(document.policy.allowsFeature("camera"), "Camera is always enabled");
   ok(document.policy.allowsFeature("camera", "http://foo.bar"), "Camera is always enabled");
   let allowed = document.policy.getAllowlistForFeature("camera");
   is(allowed.length, 1, "Only 1 entry in allowlist for camera");
   is(allowed[0], "*", "allowlist is *");
 
   ok(document.policy.allowsFeature("geolocation"), "Geolocation is enabled for self");
   ok(document.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for self");
-  ok(!document.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not enabled for anything else");
+  ok(!document.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not enabled for any random URL");
   allowed = document.policy.getAllowlistForFeature("geolocation");
   is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
   is(allowed[0], location.origin, "allowlist is self");
 
   ok(!document.policy.allowsFeature("microphone"), "Microphone is disabled for self");
   ok(!document.policy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
   ok(!document.policy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
   ok(document.policy.allowsFeature("microphone", "http://example.com"), "Microphone is enabled for example.com");
@@ -63,29 +63,29 @@ function test_document() {
 function test_iframe_without_allow() {
   info("Checking HTMLIFrameElement.policy");
   let ifr = document.getElementById("ifr");
   ok("policy" in ifr, "HTMLIFrameElement.policy exists");
 
   ok(!ifr.policy.allowsFeature("foobar"), "Random feature");
   ok(!ifr.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
 
-  ok(ifr.policy.allowsFeature("camera"), "Camera is always enabled for self");
-  ok(ifr.policy.allowsFeature("camera", location.origin), "Camera is allowed for self");
-  ok(!ifr.policy.allowsFeature("camera", "http://foo.bar"), "Camera is not allowed for a random URL");
+  ok(ifr.policy.allowsFeature("camera"), "Camera is always allowed");
+  ok(ifr.policy.allowsFeature("camera", location.origin), "Camera is always allowed");
+  ok(ifr.policy.allowsFeature("camera", "http://foo.bar"), "Camera is always allowed");
   let allowed = ifr.policy.getAllowlistForFeature("camera");
   is(allowed.length, 1, "Only 1 entry in allowlist for camera");
-  is(allowed[0], location.origin, "allowlist is 'self'");
+  is(allowed[0], "*", "allowlist is '*'");
 
-  ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is enabled for self");
-  ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for self");
-  ok(!ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not enabled for anything else");
+  ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is enabled for all");
+  ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for all");
+  ok(ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for any random URL");
   allowed = ifr.policy.getAllowlistForFeature("geolocation");
   is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
-  is(allowed[0], location.origin, "allowlist is self");
+  is(allowed[0], "*", "allowlist is '*'");
 
   ok(!ifr.policy.allowsFeature("microphone"), "Microphone is disabled for self");
   ok(!ifr.policy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
   ok(!ifr.policy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
   ok(!ifr.policy.allowsFeature("microphone", "http://example.com"), "Microphone is disabled for example.com");
   ok(!ifr.policy.allowsFeature("microphone", "http://example.org"), "Microphone is disabled for example.org");
   allowed = ifr.policy.getAllowlistForFeature("microphone");
   is(allowed.length, 0, "No allowlist for microphone");
@@ -115,22 +115,22 @@ function test_iframe_with_allow() {
 
   ok(!ifr.policy.allowsFeature("foobar"), "Random feature");
   ok(!ifr.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
 
   ok(!ifr.policy.allowsFeature("camera"), "Camera is not enabled");
   let allowed = ifr.policy.getAllowlistForFeature("camera");
   is(allowed.length, 0, "Camera has an empty allowlist");
 
-  ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is enabled for self");
-  ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for self");
-  ok(!ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not enabled for anything else");
+  ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is enabled for all");
+  ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for all");
+  ok(ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is enabled for all");
   allowed = ifr.policy.getAllowlistForFeature("geolocation");
   is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
-  is(allowed[0], location.origin, "allowlist is self");
+  is(allowed[0], "*", "allowlist is '*'");
 
   ok(!ifr.policy.allowsFeature("microphone"), "Microphone is disabled for self");
   ok(!ifr.policy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
   ok(!ifr.policy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
   ok(!ifr.policy.allowsFeature("microphone", "http://example.com"), "Microphone is disabled for example.com");
   ok(!ifr.policy.allowsFeature("microphone", "http://example.org"), "Microphone is disabled for example.org");
   allowed = ifr.policy.getAllowlistForFeature("microphone");
   is(allowed.length, 0, "No allowlist for microphone");
@@ -152,28 +152,28 @@ function test_iframe_contentDocument() {
   let ifr = document.createElement("iframe");
   ifr.setAttribute("src", "empty.html");
   ifr.onload = function() {
     ok("policy" in ifr.contentDocument, "We have ifr.contentDocument.policy");
 
     ok(!ifr.contentDocument.policy.allowsFeature("foobar"), "Random feature");
     ok(!ifr.contentDocument.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
 
-    ok(ifr.contentDocument.policy.allowsFeature("camera"), "Camera is always enabled for self");
-    ok(!ifr.contentDocument.policy.allowsFeature("camera", "http://foo.bar"), "Camera is not allowed for a random URL");
+    ok(ifr.contentDocument.policy.allowsFeature("camera"), "Camera is always allowed");
+    ok(ifr.contentDocument.policy.allowsFeature("camera", "http://foo.bar"), "Camera is always allowed");
     let allowed = ifr.contentDocument.policy.getAllowlistForFeature("camera");
     is(allowed.length, 1, "Only 1 entry in allowlist for camera");
-    is(allowed[0], location.origin, "allowlist is self");
+    is(allowed[0], "*", "allowlist is '*'");
 
-    ok(ifr.contentDocument.policy.allowsFeature("geolocation"), "Geolocation is enabled for self");
-    ok(ifr.contentDocument.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for self");
-    ok(!ifr.contentDocument.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not enabled for anything else");
+    ok(ifr.contentDocument.policy.allowsFeature("geolocation"), "Geolocation is enabled for all");
+    ok(ifr.contentDocument.policy.allowsFeature("geolocation", location.origin), "Geolocation is enabled for all");
+    ok(ifr.contentDocument.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is enabled for any random URL");
     allowed = ifr.contentDocument.policy.getAllowlistForFeature("geolocation");
     is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
-    is(allowed[0], location.origin, "allowlist is self");
+    is(allowed[0], "*", "allowlist is '*'");
 
     ok(!ifr.contentDocument.policy.allowsFeature("microphone"), "Microphone is disabled for self");
     ok(!ifr.contentDocument.policy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
     ok(!ifr.contentDocument.policy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
     ok(!ifr.contentDocument.policy.allowsFeature("microphone", "http://example.com"), "Microphone is enabled for example.com");
     ok(!ifr.contentDocument.policy.allowsFeature("microphone", "http://example.org"), "Microphone is enabled for example.org");
     allowed = ifr.contentDocument.policy.getAllowlistForFeature("microphone");
     is(allowed.length, 0, "No allowlist for microphone");
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/encrypted-media/clearkey-mp4-unique-origin.https.html.ini
@@ -0,0 +1,4 @@
+[clearkey-mp4-unique-origin.https.html]
+  [Unique origin is unable to create MediaKeys]
+    expected: FAIL
+
--- a/testing/web-platform/meta/encrypted-media/encrypted-media-default-feature-policy.https.sub.html.ini
+++ b/testing/web-platform/meta/encrypted-media/encrypted-media-default-feature-policy.https.sub.html.ini
@@ -1,8 +1,7 @@
 [encrypted-media-default-feature-policy.https.sub.html]
   expected: TIMEOUT
   [Default "encrypted-media" feature policy ["self"\] allows same-origin iframes.]
     expected: TIMEOUT
 
-  [Feature policy "encrypted-media" can be enabled in cross-origin iframes using "allow" attribute.]
+  [Default "encrypted-media" feature policy ["self"\] disallows cross-origin iframes.]
     expected: FAIL
-
--- a/testing/web-platform/meta/feature-policy/payment-default-feature-policy.https.sub.html.ini
+++ b/testing/web-platform/meta/feature-policy/payment-default-feature-policy.https.sub.html.ini
@@ -6,11 +6,8 @@
   [Default "payment" feature policy ["self"\] allows same-origin iframes.]
     expected:
       if not e10s: FAIL
 
   [Default "payment" feature policy ["self"\] allowpaymentrequest=true allows same-origin iframes.]
     expected:
       if not e10s: FAIL
 
-  [Default "payment" feature policy ["self"\] allowpaymentrequest=true allows cross-origin iframes.]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/webvr/webvr-enabled-by-feature-policy-attribute.https.sub.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[webvr-enabled-by-feature-policy-attribute.https.sub.html]
-  [Feature-Policy allow="vr" attribute allows cross-origin iframe]
-    expected: FAIL
-