Bug 1514296 - Rename Document.policy to Document.featurePolicy, r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D35801

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-07-03 13:02:05 +00:00
Родитель 5e0a7630a4
Коммит 0bcffcfa72
10 изменённых файлов: 116 добавлений и 114 удалений

Просмотреть файл

@ -2211,7 +2211,7 @@ nsresult Document::Init() {
// we need to create a policy here so getting the policy within
// ::Policy() can *always* return a non null policy
mFeaturePolicy = new FeaturePolicy(this);
mFeaturePolicy = new mozilla::dom::FeaturePolicy(this);
mFeaturePolicy->SetDefaultOrigin(NodePrincipal());
mStyleSet = MakeUnique<ServoStyleSet>(*this);
@ -3275,14 +3275,14 @@ nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) {
mFeaturePolicy->SetDefaultOrigin(NodePrincipal());
RefPtr<FeaturePolicy> parentPolicy = nullptr;
RefPtr<mozilla::dom::FeaturePolicy> parentPolicy = nullptr;
if (mDocumentContainer) {
nsPIDOMWindowOuter* containerWindow = mDocumentContainer->GetWindow();
if (containerWindow) {
nsCOMPtr<nsINode> node = containerWindow->GetFrameElementInternal();
HTMLIFrameElement* iframe = HTMLIFrameElement::FromNodeOrNull(node);
if (iframe) {
parentPolicy = iframe->Policy();
parentPolicy = iframe->FeaturePolicy();
}
}
}
@ -12573,10 +12573,10 @@ void Document::MaybeResolveReadyForIdle() {
}
}
FeaturePolicy* Document::Policy() const {
mozilla::dom::FeaturePolicy* Document::FeaturePolicy() const {
// The policy is created when the document is initialized. We _must_ have a
// policy here even if the featurePolicy pref is off. If this assertion fails,
// it means that ::Policy() is called before ::StartDocumentLoad().
// it means that ::FeaturePolicy() is called before ::StartDocumentLoad().
MOZ_ASSERT(mFeaturePolicy);
return mFeaturePolicy;
}

Просмотреть файл

@ -4052,7 +4052,7 @@ class Document : public nsINode,
mAllowPaymentRequest = aAllowPaymentRequest;
}
FeaturePolicy* Policy() const;
mozilla::dom::FeaturePolicy* FeaturePolicy() const;
bool ModuleScriptsEnabled();
@ -4474,7 +4474,7 @@ class Document : public nsINode,
RefPtr<Promise> mReadyForIdle;
RefPtr<FeaturePolicy> mFeaturePolicy;
RefPtr<mozilla::dom::FeaturePolicy> mFeaturePolicy;
UniquePtr<ResizeObserverController> mResizeObserverController;

Просмотреть файл

@ -54,7 +54,7 @@ HTMLIFrameElement::HTMLIFrameElement(
FromParser aFromParser)
: nsGenericHTMLFrameElement(std::move(aNodeInfo), aFromParser) {
// We always need a featurePolicy, even if not exposed.
mFeaturePolicy = new FeaturePolicy(this);
mFeaturePolicy = new mozilla::dom::FeaturePolicy(this);
nsCOMPtr<nsIPrincipal> origin = GetFeaturePolicyDefaultOrigin();
MOZ_ASSERT(origin);
@ -224,7 +224,9 @@ JSObject* HTMLIFrameElement::WrapNode(JSContext* aCx,
return HTMLIFrameElement_Binding::Wrap(aCx, this, aGivenProto);
}
FeaturePolicy* HTMLIFrameElement::Policy() const { return mFeaturePolicy; }
mozilla::dom::FeaturePolicy* HTMLIFrameElement::FeaturePolicy() const {
return mFeaturePolicy;
}
already_AddRefed<nsIPrincipal>
HTMLIFrameElement::GetFeaturePolicyDefaultOrigin() const {
@ -268,7 +270,7 @@ void HTMLIFrameElement::RefreshFeaturePolicy(bool aParseAllowAttribute) {
origin);
}
mFeaturePolicy->InheritPolicy(OwnerDoc()->Policy());
mFeaturePolicy->InheritPolicy(OwnerDoc()->FeaturePolicy());
}
if (AllowPaymentRequest()) {

Просмотреть файл

@ -154,7 +154,7 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
bool FullscreenFlag() const { return mFullscreenFlag; }
void SetFullscreenFlag(bool aValue) { mFullscreenFlag = aValue; }
FeaturePolicy* Policy() const;
mozilla::dom::FeaturePolicy* FeaturePolicy() const;
protected:
virtual ~HTMLIFrameElement();

Просмотреть файл

@ -90,7 +90,7 @@ void FeaturePolicy::ResetDeclaredPolicy() { mFeatures.Clear(); }
JSObject* FeaturePolicy::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return Policy_Binding::Wrap(aCx, this, aGivenProto);
return FeaturePolicy_Binding::Wrap(aCx, this, aGivenProto);
}
bool FeaturePolicy::AllowsFeature(const nsAString& aFeatureName,

Просмотреть файл

@ -92,7 +92,7 @@ bool FeaturePolicyUtils::IsFeatureAllowed(Document* aDocument,
return true;
}
FeaturePolicy* policy = aDocument->Policy();
FeaturePolicy* policy = aDocument->FeaturePolicy();
MOZ_ASSERT(policy);
if (policy->AllowsFeatureInternal(aFeatureName, policy->DefaultOrigin())) {

Просмотреть файл

@ -12,40 +12,40 @@
SimpleTest.waitForExplicitFinish();
function test_document() {
info("Checking document.policy");
ok("policy" in document, "We have document.policy");
info("Checking document.featurePolicy");
ok("featurePolicy" in document, "We have document.featurePolicy");
ok(!document.policy.allowsFeature("foobar"), "Random feature");
ok(!document.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(!document.featurePolicy.allowsFeature("foobar"), "Random feature");
ok(!document.featurePolicy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(document.policy.allowsFeature("camera"), "Camera is allowed for self");
ok(document.policy.allowsFeature("camera", "http://foo.bar"), "Camera is always allowed");
let allowed = document.policy.getAllowlistForFeature("camera");
ok(document.featurePolicy.allowsFeature("camera"), "Camera is allowed for self");
ok(document.featurePolicy.allowsFeature("camera", "http://foo.bar"), "Camera is always allowed");
let allowed = document.featurePolicy.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 allowed for self");
ok(document.policy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for self");
ok(!document.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not allowed for any random URL");
allowed = document.policy.getAllowlistForFeature("geolocation");
ok(document.featurePolicy.allowsFeature("geolocation"), "Geolocation is allowed for self");
ok(document.featurePolicy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for self");
ok(!document.featurePolicy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is not allowed for any random URL");
allowed = document.featurePolicy.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 allowed for example.com");
ok(document.policy.allowsFeature("microphone", "http://example.org"), "Microphone is allowed for example.org");
allowed = document.policy.getAllowlistForFeature("microphone");
ok(!document.featurePolicy.allowsFeature("microphone"), "Microphone is disabled for self");
ok(!document.featurePolicy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
ok(!document.featurePolicy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
ok(document.featurePolicy.allowsFeature("microphone", "http://example.com"), "Microphone is allowed for example.com");
ok(document.featurePolicy.allowsFeature("microphone", "http://example.org"), "Microphone is allowed for example.org");
allowed = document.featurePolicy.getAllowlistForFeature("microphone");
is(allowed.length, 0, "No allowlist for microphone");
ok(!document.policy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!document.policy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!document.policy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = document.policy.getAllowlistForFeature("vr");
ok(!document.featurePolicy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!document.featurePolicy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!document.featurePolicy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = document.featurePolicy.getAllowlistForFeature("vr");
is(allowed.length, 0, "No allowlist for vr");
allowed = document.policy.allowedFeatures();
allowed = document.featurePolicy.allowedFeatures();
// microphone is disabled for this origin, vr is disabled everywhere.
let camera = false;
let geolocation = false;
@ -61,136 +61,136 @@ function test_document() {
}
function test_iframe_without_allow() {
info("Checking HTMLIFrameElement.policy");
info("Checking HTMLIFrameElement.featurePolicy");
let ifr = document.getElementById("ifr");
ok("policy" in ifr, "HTMLIFrameElement.policy exists");
ok("featurePolicy" in ifr, "HTMLIFrameElement.featurePolicy exists");
ok(!ifr.policy.allowsFeature("foobar"), "Random feature");
ok(!ifr.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(!ifr.featurePolicy.allowsFeature("foobar"), "Random feature");
ok(!ifr.featurePolicy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(ifr.policy.allowsFeature("camera"), "Camera is allowed 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");
let allowed = ifr.policy.getAllowlistForFeature("camera");
ok(ifr.featurePolicy.allowsFeature("camera"), "Camera is allowed for self");
ok(ifr.featurePolicy.allowsFeature("camera", location.origin), "Camera is allowed for self");
ok(!ifr.featurePolicy.allowsFeature("camera", "http://foo.bar"), "Camera is not allowed for a random URL");
let allowed = ifr.featurePolicy.getAllowlistForFeature("camera");
is(allowed.length, 1, "Only 1 entry in allowlist for camera");
is(allowed[0], location.origin, "allowlist is 'self'");
ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for any random URL");
allowed = ifr.policy.getAllowlistForFeature("geolocation");
ok(ifr.featurePolicy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.featurePolicy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.featurePolicy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for any random URL");
allowed = ifr.featurePolicy.getAllowlistForFeature("geolocation");
is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
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");
ok(!ifr.featurePolicy.allowsFeature("microphone"), "Microphone is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://example.com"), "Microphone is disabled for example.com");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://example.org"), "Microphone is disabled for example.org");
allowed = ifr.featurePolicy.getAllowlistForFeature("microphone");
is(allowed.length, 0, "No allowlist for microphone");
ok(!ifr.policy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.policy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.policy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.policy.getAllowlistForFeature("vr");
ok(!ifr.featurePolicy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.featurePolicy.getAllowlistForFeature("vr");
is(allowed.length, 0, "No allowlist for vr");
ok(ifr.policy.allowedFeatures().includes("camera"), "Camera is allowed");
ok(ifr.policy.allowedFeatures().includes("geolocation"), "Geolocation is allowed");
ok(ifr.featurePolicy.allowedFeatures().includes("camera"), "Camera is allowed");
ok(ifr.featurePolicy.allowedFeatures().includes("geolocation"), "Geolocation is allowed");
// microphone is disabled for this origin
ok(!ifr.policy.allowedFeatures().includes("microphone"), "microphone is not allowed");
ok(!ifr.featurePolicy.allowedFeatures().includes("microphone"), "microphone is not allowed");
// vr is disabled everywhere.
ok(!ifr.policy.allowedFeatures().includes("vr"), "VR is not allowed");
ok(!ifr.featurePolicy.allowedFeatures().includes("vr"), "VR is not allowed");
next();
}
function test_iframe_with_allow() {
info("Checking HTMLIFrameElement.policy");
info("Checking HTMLIFrameElement.featurePolicy");
let ifr = document.getElementById("ifr");
ok("policy" in ifr, "HTMLIFrameElement.policy exists");
ok("featurePolicy" in ifr, "HTMLIFrameElement.featurePolicy exists");
ifr.setAttribute("allow", "camera 'none'");
ok(!ifr.policy.allowsFeature("foobar"), "Random feature");
ok(!ifr.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(!ifr.featurePolicy.allowsFeature("foobar"), "Random feature");
ok(!ifr.featurePolicy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(!ifr.policy.allowsFeature("camera"), "Camera is not allowed");
let allowed = ifr.policy.getAllowlistForFeature("camera");
ok(!ifr.featurePolicy.allowsFeature("camera"), "Camera is not allowed");
let allowed = ifr.featurePolicy.getAllowlistForFeature("camera");
is(allowed.length, 0, "Camera has an empty allowlist");
ok(ifr.policy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.policy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for all");
allowed = ifr.policy.getAllowlistForFeature("geolocation");
ok(ifr.featurePolicy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.featurePolicy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.featurePolicy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for all");
allowed = ifr.featurePolicy.getAllowlistForFeature("geolocation");
is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
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");
ok(!ifr.featurePolicy.allowsFeature("microphone"), "Microphone is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://example.com"), "Microphone is disabled for example.com");
ok(!ifr.featurePolicy.allowsFeature("microphone", "http://example.org"), "Microphone is disabled for example.org");
allowed = ifr.featurePolicy.getAllowlistForFeature("microphone");
is(allowed.length, 0, "No allowlist for microphone");
ok(!ifr.policy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.policy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.policy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.policy.getAllowlistForFeature("vr");
ok(!ifr.featurePolicy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.featurePolicy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.featurePolicy.getAllowlistForFeature("vr");
is(allowed.length, 0, "No allowlist for vr");
ok(ifr.policy.allowedFeatures().includes("geolocation"), "Geolocation is allowed only for self");
ok(ifr.featurePolicy.allowedFeatures().includes("geolocation"), "Geolocation is allowed only for self");
next();
}
function test_iframe_contentDocument() {
info("Checking iframe document.policy");
info("Checking iframe document.featurePolicy");
let ifr = document.createElement("iframe");
ifr.setAttribute("src", "empty.html");
ifr.onload = function() {
ok("policy" in ifr.contentDocument, "We have ifr.contentDocument.policy");
ok("featurePolicy" in ifr.contentDocument, "We have ifr.contentDocument.featurePolicy");
ok(!ifr.contentDocument.policy.allowsFeature("foobar"), "Random feature");
ok(!ifr.contentDocument.policy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("foobar"), "Random feature");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("foobar", "http://www.something.net"), "Random feature");
ok(ifr.contentDocument.policy.allowsFeature("camera"), "Camera is allowed for self");
ok(ifr.contentDocument.policy.allowsFeature("camera", location.origin), "Camera is allowed for self");
ok(!ifr.contentDocument.policy.allowsFeature("camera", "http://foo.bar"), "Camera is allowed for self");
let allowed = ifr.contentDocument.policy.getAllowlistForFeature("camera");
ok(ifr.contentDocument.featurePolicy.allowsFeature("camera"), "Camera is allowed for self");
ok(ifr.contentDocument.featurePolicy.allowsFeature("camera", location.origin), "Camera is allowed for self");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("camera", "http://foo.bar"), "Camera is allowed for self");
let allowed = ifr.contentDocument.featurePolicy.getAllowlistForFeature("camera");
is(allowed.length, 1, "Only 1 entry in allowlist for camera");
is(allowed[0], location.origin, "allowlist is 'self'");
ok(ifr.contentDocument.policy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.contentDocument.policy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.contentDocument.policy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for any random URL");
allowed = ifr.contentDocument.policy.getAllowlistForFeature("geolocation");
ok(ifr.contentDocument.featurePolicy.allowsFeature("geolocation"), "Geolocation is allowed for all");
ok(ifr.contentDocument.featurePolicy.allowsFeature("geolocation", location.origin), "Geolocation is allowed for all");
ok(ifr.contentDocument.featurePolicy.allowsFeature("geolocation", "http://foo.bar"), "Geolocation is allowed for any random URL");
allowed = ifr.contentDocument.featurePolicy.getAllowlistForFeature("geolocation");
is(allowed.length, 1, "Only 1 entry in allowlist for geolocation");
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 allowed for example.com");
ok(!ifr.contentDocument.policy.allowsFeature("microphone", "http://example.org"), "Microphone is allowed for example.org");
allowed = ifr.contentDocument.policy.getAllowlistForFeature("microphone");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("microphone"), "Microphone is disabled for self");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("microphone", location.origin), "Microphone is disabled for self");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("microphone", "http://foo.bar"), "Microphone is disabled for foo.bar");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("microphone", "http://example.com"), "Microphone is allowed for example.com");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("microphone", "http://example.org"), "Microphone is allowed for example.org");
allowed = ifr.contentDocument.featurePolicy.getAllowlistForFeature("microphone");
is(allowed.length, 0, "No allowlist for microphone");
ok(!ifr.contentDocument.policy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.contentDocument.policy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.contentDocument.policy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.contentDocument.policy.getAllowlistForFeature("vr");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("vr"), "Vibrate is disabled for self");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("vr", location.origin), "Vibrate is disabled for self");
ok(!ifr.contentDocument.featurePolicy.allowsFeature("vr", "http://foo.bar"), "Vibrate is disabled for foo.bar");
allowed = ifr.contentDocument.featurePolicy.getAllowlistForFeature("vr");
is(allowed.length, 0, "No allowlist for vr");
ok(ifr.contentDocument.policy.allowedFeatures().includes("camera"), "Camera is allowed");
ok(ifr.contentDocument.policy.allowedFeatures().includes("geolocation"), "Geolocation is allowed");
ok(ifr.contentDocument.featurePolicy.allowedFeatures().includes("camera"), "Camera is allowed");
ok(ifr.contentDocument.featurePolicy.allowedFeatures().includes("geolocation"), "Geolocation is allowed");
// microphone is disabled for this origin
ok(!ifr.contentDocument.policy.allowedFeatures().includes("microphone"), "Microphone is not allowed");
ok(!ifr.contentDocument.featurePolicy.allowedFeatures().includes("microphone"), "Microphone is not allowed");
// vr is disabled everywhere.
ok(!ifr.contentDocument.policy.allowedFeatures().includes("vr"), "VR is not allowed");
ok(!ifr.contentDocument.featurePolicy.allowedFeatures().includes("vr"), "VR is not allowed");
next();
};

Просмотреть файл

@ -601,10 +601,10 @@ Document implements GeometryUtils;
Document implements FontFaceSource;
Document implements DocumentOrShadowRoot;
// https://wicg.github.io/feature-policy/#policy
// https://w3c.github.io/webappsec-feature-policy/#idl-index
partial interface Document {
[SameObject, Pref="dom.security.featurePolicy.webidl.enabled"]
readonly attribute Policy policy;
readonly attribute FeaturePolicy featurePolicy;
};
/**

Просмотреть файл

@ -4,11 +4,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* For more information on this interface, please see
* https://wicg.github.io/feature-policy/#policy
* https://w3c.github.io/webappsec-feature-policy/#idl-index
*/
[NoInterfaceObject]
interface Policy {
interface FeaturePolicy {
boolean allowsFeature(DOMString feature, optional DOMString origin);
sequence<DOMString> allowedFeatures();
sequence<DOMString> getAllowlistForFeature(DOMString feature);

Просмотреть файл

@ -70,10 +70,10 @@ partial interface HTMLIFrameElement {
HTMLIFrameElement implements MozFrameLoaderOwner;
HTMLIFrameElement implements BrowserElement;
// https://wicg.github.io/feature-policy/#policy
// https://w3c.github.io/webappsec-feature-policy/#idl-index
partial interface HTMLIFrameElement {
[SameObject, Pref="dom.security.featurePolicy.webidl.enabled"]
readonly attribute Policy policy;
readonly attribute FeaturePolicy featurePolicy;
[CEReactions, SetterThrows, Pure, Pref="dom.security.featurePolicy.enabled"]
attribute DOMString allow;