JavaScript Document featurePolicy Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

document.featurePolicy is a read-only property that returns a FeaturePolicy object for inspecting Permissions Policy settings on the current document (MDN).

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.featurePolicy. Start with this line.

JavaScript
document.featurePolicy
CallWhat it does
document.featurePolicyPrimary signature.

Built into the browser. Read or assign document.featurePolicy — no import required.

Library declarations
JavaScript
document.featurePolicy

Parameters

ParameterDescription
Writable?Optional. Read-only
Feature-detectRequired. "featurePolicy" in document

Return Value

Return ValueDescription
*FeaturePolicy object

JavaScript Examples

Example 1 — Feature-Detect First

Never assume the property exists.

JavaScript
if ("featurePolicy" in document) {
  console.log("available");
  console.log(typeof document.featurePolicy);
} else {
  console.log("Not supported in this browser");
}
Try It Yourself

How It Works

  1. Use in. Safe check for the property on document.
  2. Read only when present. Avoids errors on unsupported engines.
  3. Log type. Confirms you have an object, not a boolean.
  4. Deprecated API. Prefer HTTP Permissions Policy for real control (MDN).

Example 2 — allowsFeature("camera")

Ask whether Permissions Policy allows the camera feature.

JavaScript
if (!("featurePolicy" in document)) {
  console.log("document.featurePolicy not available");
} else {
  const ok = document.featurePolicy.allowsFeature("camera");
  console.log(ok ? "FP allows camera." : "FP does not allow camera.");
}
Try It Yourself

How It Works

  1. Guard missing support. Exit early when the inspector is absent.
  2. Call allowsFeature. Returns a boolean for that feature name (MDN).
  3. Policy only. Does not mean the user clicked Allow on a prompt.
  4. Still need getUserMedia for actual camera capture.

Example 3 — List Features and an Allowlist

Compare supported vs allowed names, then read one allowlist.

JavaScript
if (!("featurePolicy" in document)) {
  console.log("document.featurePolicy not available");
} else {
  const fp = document.featurePolicy;
  const supported = fp.features();
  const allowed = fp.allowedFeatures();
  const cameraOrigins = fp.getAllowlistForFeature("camera");

  console.log("supported:", supported.length);
  console.log("allowed:", allowed.length);
  console.log("camera allowlist:", cameraOrigins.join(", ") || "(empty)");
}
Try It Yourself

How It Works

  1. features(). Names the UA knows about (MDN).
  2. allowedFeatures(). Names allowed by the current policy.
  3. getAllowlistForFeature. Origins allowed for one feature.
  4. Debug aid only. Prefer configuring policy on the server, not in JS.

Browser Support

Document.featurePolicy is marked Deprecated, Experimental, and Non-standard on MDN. Support varies — always feature-detect. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Deprecated · Experimental

Document.featurePolicy

Inspector for Permissions Policy settings. Prefer the Permissions-Policy HTTP header for new work.

Limited Non-standard
Google Chrome Partial / Chromium engines
Partial
Microsoft Edge Partial / Chromium
Partial
Mozilla Firefox Limited / may differ
Limited
Apple Safari Limited / may differ
Limited
Opera Partial / Chromium
Partial
Internet Explorer Not supported
No
document.featurePolicy Feature-detect required

Bottom line: Learn it to read old demos. See the MDN Document.featurePolicy reference and configure policy with Permissions-Policy instead.

Frequently Asked Questions

A FeaturePolicy object used to inspect Permissions Policy settings applied to the document (MDN).
Yes. MDN marks Document.featurePolicy (and FeaturePolicy) as Deprecated. Feature Policy was superseded by Permissions Policy.
Yes. MDN marks it Experimental and Non-standard, and notes it does not appear in a formal specification. Always feature-detect.
Permissions Policy is the modern name. Configure with the Permissions-Policy HTTP header (and iframe allow). The JS inspector property is still named document.featurePolicy in some browsers.
No. It only reflects Permissions Policy allowlists. Camera and similar APIs may still need a separate user permission (for example via getUserMedia).
No for new projects. Prefer configuring policy with Permissions-Policy headers. If you inspect policy in JS, feature-detect and treat missing support as unknown — not as denied.

Next: Document fgColor

Learn the deprecated document foreground text color property.

fgColor tutorial →

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.

11 people found this page helpful