mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Bug 1514474 - Implement FeaturePolicy.features(), r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D35802 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e01cab332f
commit
5a8e4fdbe9
@ -148,6 +148,16 @@ bool FeaturePolicy::AllowsFeatureInternal(const nsAString& aFeatureName,
|
||||
return false;
|
||||
}
|
||||
|
||||
void FeaturePolicy::Features(nsTArray<nsString>& aFeatures) {
|
||||
RefPtr<FeaturePolicy> self = this;
|
||||
FeaturePolicyUtils::ForEachFeature(
|
||||
[self, &aFeatures](const char* aFeatureName) {
|
||||
nsString featureName;
|
||||
featureName.AppendASCII(aFeatureName);
|
||||
aFeatures.AppendElement(featureName);
|
||||
});
|
||||
}
|
||||
|
||||
void FeaturePolicy::AllowedFeatures(nsTArray<nsString>& aAllowedFeatures) {
|
||||
RefPtr<FeaturePolicy> self = this;
|
||||
FeaturePolicyUtils::ForEachFeature(
|
||||
|
@ -113,6 +113,8 @@ class FeaturePolicy final : public nsISupports, public nsWrapperCache {
|
||||
bool AllowsFeature(const nsAString& aFeatureName,
|
||||
const Optional<nsAString>& aOrigin) const;
|
||||
|
||||
void Features(nsTArray<nsString>& aFeatures);
|
||||
|
||||
void AllowedFeatures(nsTArray<nsString>& aAllowedFeatures);
|
||||
|
||||
void GetAllowlistForFeature(const nsAString& aFeatureName,
|
||||
|
@ -8,3 +8,4 @@ support-files =
|
||||
test_parser.html^headers^
|
||||
|
||||
[test_parser.html]
|
||||
[test_featureList.html]
|
||||
|
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test feature policy - list</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="empty.html" id="ifr"></iframe>
|
||||
<script type="text/javascript">
|
||||
|
||||
let supportedFeatures = [
|
||||
"autoplay",
|
||||
"camera",
|
||||
"encrypted-media",
|
||||
"fullscreen",
|
||||
"geolocation",
|
||||
"microphone",
|
||||
"midi",
|
||||
"payment",
|
||||
"display-capture",
|
||||
"document-domain",
|
||||
"speaker",
|
||||
"vr",
|
||||
];
|
||||
|
||||
function checkFeatures(features) {
|
||||
features.forEach(feature => {
|
||||
ok(supportedFeatures.includes(feature), "Feature: " + feature);
|
||||
});
|
||||
}
|
||||
|
||||
ok("featurePolicy" in document, "We have document.featurePolicy");
|
||||
checkFeatures(document.featurePolicy.features());
|
||||
|
||||
let ifr = document.getElementById("ifr");
|
||||
ok("featurePolicy" in ifr, "We have HTMLIFrameElement.featurePolicy");
|
||||
checkFeatures(ifr.featurePolicy.features());
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -10,6 +10,7 @@
|
||||
[NoInterfaceObject]
|
||||
interface FeaturePolicy {
|
||||
boolean allowsFeature(DOMString feature, optional DOMString origin);
|
||||
sequence<DOMString> features();
|
||||
sequence<DOMString> allowedFeatures();
|
||||
sequence<DOMString> getAllowlistForFeature(DOMString feature);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user