Document.featurePolicy is a read-only instance property that returns a FeaturePolicy object for inspecting Permissions Policy on the document. Learn feature detection, allowsFeature, allowlists, the Feature Policy → Permissions Policy rename, and five examples with try-it labs.
01
Kind
Read-only property
02
Returns
FeaturePolicy
03
Status
Experimental
04
Also
Non-standard
05
Inspect
Permissions Policy
06
Key method
allowsFeature()
Fundamentals
Introduction
Browsers can restrict powerful features (camera, microphone, geolocation, fullscreen, and more) with Permissions Policy—formerly called Feature Policy. Sites usually set it with the Permissions-Policy HTTP response header and with iframe allow attributes.
MDN: document.featurePolicy returns the FeaturePolicy interface, a simple API for inspecting those policies on a document. It does not replace the HTTP header; it only lets scripts ask what is currently allowed.
💡
Name history
The web renamed Feature Policy to Permissions Policy. The HTTP header is now Permissions-Policy, but this Document property is still named featurePolicy in browsers that expose it.
A read-only instance property on Document. Its value is a FeaturePolicy object for the current document (MDN).
Value — FeaturePolicy (inspect Permissions Policy).
Read-only — you do not assign a new object to document.featurePolicy.
Experimental + Non-standard — not for portable production apps (MDN).
Iframe twin — some engines also expose HTMLIFrameElement.featurePolicy.
Not user permission — policy allow ≠ user clicked “Allow” in a prompt.
Foundation
📝 Syntax
JavaScript
document.featurePolicy
Value
A FeaturePolicy object that can be used to inspect the Permissions Policy settings applied to the document (MDN).
Feature detection
JavaScript
if ("featurePolicy" in document) {
const policy = document.featurePolicy;
// Safe to call methods on browsers that expose it
} else {
console.log("document.featurePolicy not available");
}
API surface
🔧 FeaturePolicy methods (MDN)
Method
What it does
allowsFeature(feature)
true if the feature is allowed in the default context
allowsFeature(feature, origin)
Same check for a specific origin
features()
Names of features the user agent supports
allowedFeatures()
Supported features also allowed by the current policy
getAllowlistForFeature(feature)
Array of allowed origins (may include "*")
All of these methods are themselves experimental and non-standard on MDN. Unknown feature names may yield empty allowlists or warnings.
Compare
⚖️ Policy vs permission vs this API
Layer
What it controls
How you set / read it
Permissions Policy
Which origins may use a feature
Permissions-Policy header, iframe allow
document.featurePolicy
Inspect that policy in JS
Experimental inspector (this page)
Permissions API
User grant (Allow / Block)
navigator.permissions.query(...)
Feature itself
Actual camera/mic/etc.
e.g. getUserMedia
Server side
🛡️ Configuring policy (recommended path)
Production sites usually declare policy in HTTP, not via this JS property. Example shape (simplified):
Detect the property, then ask if a feature is allowed.
Example 1 — Feature-Detect document.featurePolicy
Never assume the inspector exists.
JavaScript
if ("featurePolicy" in document) {
console.log("FeaturePolicy available");
console.log(typeof document.featurePolicy);
} else {
console.log("Not supported in this browser");
}
On unsupported engines the in check is false—skip the rest of the API.
Example 2 — allowsFeature("camera") (MDN)
Ask whether Permissions Policy allows camera in the default context.
JavaScript
const featurePolicy = document.featurePolicy;
const allowed = featurePolicy.allowsFeature("camera");
if (allowed) {
console.log("FP allows camera.");
} else {
console.log("FP does not allow camera.");
}
// User may still need to grant permission separately
MDN: items on allowedFeatures() may still need a user permission grant.
Example 4 — getAllowlistForFeature("camera") (MDN)
Print origins allowed to use camera under the current policy.
JavaScript
const featurePolicy = document.featurePolicy;
const allowlist = featurePolicy.getAllowlistForFeature("camera");
for (const origin of allowlist) {
console.log(origin);
}
// Often ["*"] or ["https://your-site.example"] depending on headers
If the feature name is unknown, MDN notes you may get an empty array (and possibly a console warning).
Example 5 — Safe Helper Before Using Camera UI
Combine detection + policy check before showing a camera button.
JavaScript
function policyAllowsCamera() {
if (!("featurePolicy" in document)) {
// Unknown — do not hard-block; fall back to trying the API
return null;
}
return document.featurePolicy.allowsFeature("camera");
}
const result = policyAllowsCamera();
if (result === false) {
console.log("Hide camera UI — blocked by Permissions Policy");
} else if (result === true) {
console.log("Policy OK — still need user permission for getUserMedia");
} else {
console.log("Inspector missing — feature-detect getUserMedia instead");
}
Document.featurePolicy is Experimental and Non-standard on MDN. Support is incomplete — feature-detect always. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Experimental · Non-standard
Document.featurePolicy
Inspect Permissions Policy via an experimental FeaturePolicy object — not a portable production API.
LimitedCheck compat
Google ChromeMay expose FeaturePolicy · verify version
Partial / check
Mozilla FirefoxCheck current release notes
Partial / check
Apple SafariMay be missing or limited
Limited / check
Microsoft EdgeChromium-based · verify
Partial / check
OperaFollow Chromium behavior
Partial / check
Internet ExplorerNot supported
No support
Document.featurePolicyExperimental support
Bottom line: Use Permissions-Policy headers to configure features. Treat document.featurePolicy as an optional inspector where it exists — never as a hard dependency.
Wrap Up
Conclusion
Document.featurePolicy is an experimental, non-standard way to inspect Permissions Policy from JavaScript. Learn it for debugging and teaching—configure real policies with HTTP headers and iframe allow, and never confuse policy allowlists with user grants.
Confuse old Feature-Policy header with Permissions-Policy
Skip try/catch or detection around method calls
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.featurePolicy
Experimental inspector for Permissions Policy — detect first.
5
Core concepts
📄01
Returns
FeaturePolicy
API
🔬02
Status
exp + non-std
MDN
🛡️03
Inspects
Permissions Policy
Policy
✓04
Key call
allowsFeature
Method
🔒05
Configure
HTTP header
Prefer
❓ Frequently Asked Questions
A FeaturePolicy object you can use to inspect the Permissions Policy settings applied to the document (MDN).
No. MDN marks it Experimental and Non-standard, not Deprecated. It does not appear in a formal specification on MDN.
Permissions Policy is the modern name for what used to be called Feature Policy. The HTTP header is Permissions-Policy; the JS inspector property is still named document.featurePolicy.
FeaturePolicy exposes allowsFeature(), features(), allowedFeatures(), and getAllowlistForFeature() — all experimental and non-standard on MDN.
No. It only reflects Permissions Policy allowlists. Camera (and similar APIs) may still require a separate user permission via the Permissions API.
MDN does not recommend non-standard features in production. Feature-detect carefully, and prefer configuring policy with the Permissions-Policy HTTP header (and iframe allow attributes) rather than depending on this inspector API.
Did you know?
MDN’s Permissions Policy guide still points developers at Document.featurePolicy (and iframe featurePolicy) for programmatic inspection—even though the HTTP mechanism was renamed from Feature Policy. The old name lives on in the JavaScript property.