diff --git a/dom/credentialmanagement/CredentialsContainer.cpp b/dom/credentialmanagement/CredentialsContainer.cpp index fb9a4d3c28731..9d30ab1d6c101 100644 --- a/dom/credentialmanagement/CredentialsContainer.cpp +++ b/dom/credentialmanagement/CredentialsContainer.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/Credential.h" #include "mozilla/dom/CredentialsContainer.h" +#include "mozilla/dom/FeaturePolicyUtils.h" #include "mozilla/dom/IdentityCredential.h" #include "mozilla/dom/Promise.h" #include "mozilla/StaticPrefs_dom.h" @@ -145,7 +146,10 @@ already_AddRefed CredentialsContainer::Get( if (aOptions.mPublicKey.WasPassed() && StaticPrefs::security_webauth_webauthn()) { - if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) { + MOZ_ASSERT(mParent); + if (!FeaturePolicyUtils::IsFeatureAllowed( + mParent->GetExtantDoc(), u"publickey-credentials-get"_ns) || + !IsInActiveTab(mParent)) { return CreateAndRejectWithNotAllowed(mParent, aRv); } diff --git a/dom/security/featurepolicy/FeaturePolicyUtils.cpp b/dom/security/featurepolicy/FeaturePolicyUtils.cpp index 11ca5ffd06047..8427d363e864c 100644 --- a/dom/security/featurepolicy/FeaturePolicyUtils.cpp +++ b/dom/security/featurepolicy/FeaturePolicyUtils.cpp @@ -36,6 +36,8 @@ static FeatureMap sSupportedFeatures[] = { {"fullscreen", FeaturePolicyUtils::FeaturePolicyValue::eSelf}, {"web-share", FeaturePolicyUtils::FeaturePolicyValue::eSelf}, {"gamepad", FeaturePolicyUtils::FeaturePolicyValue::eAll}, + {"publickey-credentials-get", + FeaturePolicyUtils::FeaturePolicyValue::eSelf}, {"speaker-selection", FeaturePolicyUtils::FeaturePolicyValue::eSelf}, {"storage-access", FeaturePolicyUtils::FeaturePolicyValue::eAll}, }; diff --git a/dom/security/featurepolicy/test/mochitest/test_featureList.html b/dom/security/featurepolicy/test/mochitest/test_featureList.html index 34fce49f98aea..63d068f8a7e75 100644 --- a/dom/security/featurepolicy/test/mochitest/test_featureList.html +++ b/dom/security/featurepolicy/test/mochitest/test_featureList.html @@ -19,6 +19,7 @@ "microphone", "midi", "payment", + "publickey-credentials-get", "storage-access", "display-capture", "document-domain",