JavaScript Document featurePolicy Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental
Non-standard
Instance property

What You’ll Learn

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()

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.

Related Document tutorials: embeds, domain, Document constructor.

Understanding Document.featurePolicy

A read-only instance property on Document. Its value is a FeaturePolicy object for the current document (MDN).

  • ValueFeaturePolicy (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.

📝 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");
}

🔧 FeaturePolicy methods (MDN)

MethodWhat 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.

🛡️ Configuring policy (recommended path)

Production sites usually declare policy in HTTP, not via this JS property. Example shape (simplified):

JavaScript
Permissions-Policy: camera=(), microphone=(), geolocation=(self)

For iframes, combine the parent policy with the frame’s allow attribute. The most restrictive intersection wins.

⚡ Quick Reference

GoalCode / note
Detect support"featurePolicy" in document
Get inspectordocument.featurePolicy
Is camera allowed by policy?document.featurePolicy.allowsFeature("camera")
List allowed featuresdocument.featurePolicy.allowedFeatures()
Camera allowlistgetAllowlistForFeature("camera")
Configure in productionPermissions-Policy HTTP header
MDN statusExperimental & Non-standard

🔍 At a Glance

Four facts about document.featurePolicy.

Type
FeaturePolicy

Inspector object

Access
read-only

Instance property

Status
exp + non-std

MDN

Purpose
inspect

Not configure

📋 Example feature names

Feature stringRough meaning
"camera"Camera / media capture
"microphone"Microphone capture
"geolocation"Geolocation API
"fullscreen"Fullscreen requests
"payment"Payment Request API

Exact directive names follow Permissions Policy; unknown names may return empty allowlists.

Examples Gallery

Examples follow MDN Document: featurePolicy and the FeaturePolicy methods. Outputs vary by browser—always feature-detect.

📚 Getting Started

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");
}
Try It Yourself

How It Works

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
Try It Yourself

How It Works

Optional second argument: allowsFeature("camera", "https://example.com") for another origin.

📈 Lists, Allowlists & Safe Guards

Enumerate features and wrap calls defensively.

Example 3 — features() and allowedFeatures()

Compare what the browser supports vs what the current policy allows.

JavaScript
const fp = document.featurePolicy;
const supported = fp.features();
const allowed = fp.allowedFeatures();

console.log("supported count:", supported.length);
console.log("allowed count:", allowed.length);
console.log("sample allowed:", allowed.slice(0, 5));
Try It Yourself

How It Works

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
Try It Yourself

How It Works

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");
}
Try It Yourself

How It Works

Treat missing featurePolicy as “unknown,” not as “denied.”

🚀 Common Use Cases

  • Diagnostics — debug why camera/mic APIs fail in an embed.
  • Teaching Permissions Policy — show allowlists live in supporting browsers.
  • Optional UI hints — hide controls when policy clearly blocks a feature.
  • Iframe audits — compare document vs iframe policy where both exist.
  • Not primary config — still set policy with HTTP headers / allow.
  • Legacy Feature Policy docs — map old name to today’s Permissions Policy.

🧠 How Policy Inspection Fits

1

Server sends Permissions-Policy

Headers and iframe allow define which origins may use which features.

Configure
2

Browser applies the policy

Powerful APIs are gated before they even ask the user.

Enforce
3

document.featurePolicy inspects

Scripts may ask allowsFeature / allowlists when the API exists.

Inspect
4

User permission still separate

Even if policy allows camera, the user may still deny the prompt.

📝 Notes

  • MDN: Experimental and Non-standard — both banners shown above; not Deprecated.
  • MDN: does not appear to be defined in any specification.
  • Feature Policy was renamed to Permissions Policy; the JS property name lagged behind.
  • Always feature-detect before calling methods.
  • Related: embeds, domain, Document constructor.

Browser Support

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.

Limited Check compat
Google Chrome May expose FeaturePolicy · verify version
Partial / check
Mozilla Firefox Check current release notes
Partial / check
Apple Safari May be missing or limited
Limited / check
Microsoft Edge Chromium-based · verify
Partial / check
Opera Follow Chromium behavior
Partial / check
Internet Explorer Not supported
No support
Document.featurePolicy Experimental 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.

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.

Continue with fgColor, embeds, domain, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect with "featurePolicy" in document
  • Set policy via Permissions-Policy headers
  • Use iframe allow for embedded frames
  • Treat missing API as unknown, not denied
  • Combine with Permissions API for user grants

❌ Don’t

  • Ship critical logic that requires this API
  • Assume policy allow equals user permission
  • Ignore MDN Experimental / Non-standard warnings
  • Confuse old Feature-Policy header with Permissions-Policy
  • Skip try/catch or detection around method calls

Key Takeaways

Knowledge Unlocked

Five things to remember about document.featurePolicy

Experimental inspector for Permissions Policy — detect first.

5
Core concepts
🔬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.

Next: fgColor

Learn the deprecated document foreground text color property.

fgColor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful