diff --git a/dom/security/featurepolicy/FeaturePolicy.cpp b/dom/security/featurepolicy/FeaturePolicy.cpp index 30aa2beb51fb..1bd546e3b61c 100644 --- a/dom/security/featurepolicy/FeaturePolicy.cpp +++ b/dom/security/featurepolicy/FeaturePolicy.cpp @@ -148,6 +148,16 @@ bool FeaturePolicy::AllowsFeatureInternal(const nsAString& aFeatureName, return false; } +void FeaturePolicy::Features(nsTArray& aFeatures) { + RefPtr self = this; + FeaturePolicyUtils::ForEachFeature( + [self, &aFeatures](const char* aFeatureName) { + nsString featureName; + featureName.AppendASCII(aFeatureName); + aFeatures.AppendElement(featureName); + }); +} + void FeaturePolicy::AllowedFeatures(nsTArray& aAllowedFeatures) { RefPtr self = this; FeaturePolicyUtils::ForEachFeature( diff --git a/dom/security/featurepolicy/FeaturePolicy.h b/dom/security/featurepolicy/FeaturePolicy.h index 3856cd25d173..1fe517e3a3af 100644 --- a/dom/security/featurepolicy/FeaturePolicy.h +++ b/dom/security/featurepolicy/FeaturePolicy.h @@ -113,6 +113,8 @@ class FeaturePolicy final : public nsISupports, public nsWrapperCache { bool AllowsFeature(const nsAString& aFeatureName, const Optional& aOrigin) const; + void Features(nsTArray& aFeatures); + void AllowedFeatures(nsTArray& aAllowedFeatures); void GetAllowlistForFeature(const nsAString& aFeatureName, diff --git a/dom/security/featurepolicy/test/mochitest/mochitest.ini b/dom/security/featurepolicy/test/mochitest/mochitest.ini index 3402c8662f4b..a9598fd7ee39 100644 --- a/dom/security/featurepolicy/test/mochitest/mochitest.ini +++ b/dom/security/featurepolicy/test/mochitest/mochitest.ini @@ -8,3 +8,4 @@ support-files = test_parser.html^headers^ [test_parser.html] +[test_featureList.html] diff --git a/dom/security/featurepolicy/test/mochitest/test_featureList.html b/dom/security/featurepolicy/test/mochitest/test_featureList.html new file mode 100644 index 000000000000..ed51d67092d9 --- /dev/null +++ b/dom/security/featurepolicy/test/mochitest/test_featureList.html @@ -0,0 +1,42 @@ + + + + Test feature policy - list + + + + + + + + diff --git a/dom/webidl/FeaturePolicy.webidl b/dom/webidl/FeaturePolicy.webidl index 85a3b82ce892..e89f56b6ded8 100644 --- a/dom/webidl/FeaturePolicy.webidl +++ b/dom/webidl/FeaturePolicy.webidl @@ -10,6 +10,7 @@ [NoInterfaceObject] interface FeaturePolicy { boolean allowsFeature(DOMString feature, optional DOMString origin); + sequence features(); sequence allowedFeatures(); sequence getAllowlistForFeature(DOMString feature); };