Movatterモバイル変換


[0]ホーム

URL:


W3C

Permissions

Interacting with Permissions for Powerful Features

W3C Editor's Draft

More details about this document
This version:
https://w3c.github.io/permissions/
Latest published version:
https://www.w3.org/TR/permissions/
Latest editor's draft:
https://w3c.github.io/permissions/
History:
https://www.w3.org/standards/history/permissions/
Commit history
Editors:
Marcos Cáceres (Apple Inc.)
Mike Taylor (Google LLC)
Former editors:
Mounir Lamouri (Google LLC)
Jeffrey Yasskin (Google LLC)
Feedback:
GitHub w3c/permissions (pull requests,new issue,open issues)
Browser support:
Chrome logo43
Edge logo79
Firefox logo46
Safari logo16.0
desktop
Android Chrome logo141
Android Firefox logo143
Android UC logo15.5
iOS Safari logo16.0
Samsung Internet logo4
mobile
More info

Copyright © 2025World Wide Web Consortium.W3C®liability,trademark andpermissive document license rules apply.


Abstract

This specification defines common infrastructure that other specifications can use to interact with browser permissions. These permissions represent a user's choice to allow or deny access to "powerful features" of the platform. For developers, the specification standardizes an API to query the permission state of a powerful feature, and be notified if a permission to use a powerful feature changes state.

Status of This Document

This section describes the status of this document at the time of its publication. A list of currentW3C publications and the latest revision of this technical report can be found in theW3C standards and drafts index.

This is a work in progress.

This document was published by theWeb Application Security Working Group as an Editor's Draft.

Publication as an Editor's Draft does not imply endorsement byW3C and its Members.

This is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress.

This document was produced by a group operating under theW3C Patent Policy.W3C maintains apublic list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes containsEssential Claim(s) must disclose the information in accordance withsection 6 of theW3C Patent Policy.

This document is governed by the18 August 2025W3C Process Document.

1. Introduction

This section is non-normative.

Specifications can define features that are explicitly identified as apowerful feature. These features are said to be "powerful" in that they can have significant privacy, security, and performance implications. As such, users rely on user agents to deny sites the ability to use these features until they have given express permission, and usually only granting this ability for a limited amount of time. Express permission to allow a site to use a powerful feature is generally given and controlled through browser UI, as illustrated below.

On the left, a mockup of a notifications prompt with an allow and don't allow buttons that states 'the website example.com would like to send you notifications'. On the right, a prompt near the URL bar asking to give permission to the camera and microphone to the example site.
Figure1 Sketches of possible permission prompt types

In this sense, a permission represents the current state of user consent for certain types of features, and particularly "powerful features". Ultimately the user retains control of these permissions and have the ability to manually grant or deny permissions through user preferences. Further, user agents assist users in managing permissions by, for example, hiding and automatically denying certain permission prompts that would otherwise be a nuisance, and automatically expiring granted permissions if a user doesn't visit a website for some time.

A mockup of a settings page that would allow a user to set or reset defaults for location, camera, microphone, motion sensors, and notifications permissions.
Figure2 A sketch of a possible site-specific permissions controls UI

2. Examples of usage

This section is non-normative.

This example uses the Permissions API to decide whether local news should be shown using the Geolocation API or with a button offering to add the feature.

Example 1: Using .state attribute
const { state } =await navigator.permissions.query({name:"geolocation"});switch (state) {case"granted":showLocalNewsWithGeolocation();break;case"prompt":showButtonToEnableLocalNews();break;case"denied":showNationalNews();break;}

This example simultaneously checks the state of the"geolocation" and"notifications"powerful features:

Example 2: Checking the state of multiple permissions
const queryPromises = ["geolocation","notifications"].map(name => navigator.permissions.query({ name }));forawait (const statusof queryPromises) {console.log(`${status.name}:${status.state}`);}

This example is checking the permission state of the available cameras.

Example 3: Checking permission state of multiple cameras
const devices =await navigator.mediaDevices.enumerateDevices();// filter on video inputs, and map to query objectconst queries = devices  .filter(({ kind }) => kind ==="videoinput")  .map(({ deviceId }) => ({name:"camera", deviceId }));const promises = queries.map((queryObj) =>  navigator.permissions.query(queryObj));try {const results =awaitPromise.all(promises);// log the state of each camera  results.forEach(({ state }, i) =>console.log("Camera", i, state));}catch (error) {console.error(error);}

3. Model

This section specifies a model forpermissions to usepowerful features on the Web platform.

3.1 Permissions

Apermission represents a user's decision to allow a web application to use apowerful feature. This decision is represented as a permissionstate.

Express permission refers to the usergranting the web application the ability to use apowerful feature.

Note: Limitations and extensibility

Current Web APIs have different ways to deal with permissions. For example, theNotifications API Standard allows developers to request a permission and check the permission status explicitly. Others expose the status to web pages only when they try to use the API, e.g., theGeolocation which fails if the permission was not granted without allowing the developer to check beforehand.

The solution described in this document is meant to be extensible, but isn't expected to be applicable to all the current and future permissions available in the web platform. Working Groups that are creating specifications whose permission model doesn't fit in the model described in this document should contact the editors byfiling an issue.

Conceptually, apermission for apowerful feature can be in one of the followingstates:

"denied":
The user, or the user agent on the user's behalf, has denied access to thispowerful feature. The caller won't be able to use the feature.
"granted":
The user, or the user agent on the user's behalf, has givenexpress permission to use apowerful feature. The caller will be able to use the feature possibly without having theuser agent asking the user's permission.
"prompt":
The user has not givenexpress permission to use the feature (i.e., it's the same as"denied"). It also means that if a caller attempts to use the feature, theuser agent will either be prompting the user for permission or access to the feature will be"denied".

To ascertainnew information about the user's intent, a user agentMAY collect and interpret information about a user's intentions. This information can come from explicit user action, aggregate behavior of both the relevant user and other users, orimplicit signals this specification hasn't anticipated.

Note: What constitutes an implicit signal?

Theimplicit signals could be, for example, theinstallation status of a web application or frequency and recency of visits. A user that has installed a web application and used it frequently and recently is more likely to trust it. Implementations are advised to exercise caution when relying on implicit signals.

Everypermission has alifetime, which is the duration for which a particular permission remains"granted" before it reverts back to itsdefault state. Alifetime could be until a particularRealm is destroyed, until a particulartop-level browsing context is destroyed, a particular amount of time, or be infinite. The lifetime is negotiated between the end-user and theuser agent when the user givesexpress permission to use afeature—usually via some permission UI or user-agent defined policy.

Every permission has adefault state (usually"prompt"), which is thestate that the permission is in when the user has not yet givenexpress permission to use thefeature or it has been reset because itslifetime has expired.

3.2 Permission Store

The user agent maintains a singlepermission store which is alist ofpermission store entries. Each particularentry denoted by itsdescriptor andkey can only appear at most once in this list.

The user agentMAY removeentries from thepermission store when their respectivepermission'slifetime has expired.

Apermission store entry is atuple ofPermissionDescriptordescriptor,permission keykey, andstatestate.

Toget a permission store entry given aPermissionDescriptordescriptor andpermission keykey:

  1. If the user agent'spermission storecontains anentry whosedescriptor isdescriptor, and whosekeyis equal tokey givendescriptor, return that entry.
  2. Return null.

Toset a permission store entry given aPermissionDescriptordescriptor, apermission keykey, and astatestate, run these steps:

  1. LetnewEntry be a newpermission store entry whosedescriptor isdescriptor, and whosekey iskey, and whosestate isstate.
  2. If the user agent'spermission storecontains anentry whosedescriptor isdescriptor, and whosekeyis equal tokey givendescriptor,replace that entry withnewEntry and abort these steps.
  3. AppendnewEntry to the user agent'spermission store.

Toremove a permission store entry given aPermissionDescriptordescriptor andpermission keykey, run these steps:

  1. Remove theentry whosedescriptor isdescriptor, and whosekeyis equal tokey givendescriptor, from the user agent'spermission store.

Apermission key has its type defined by a feature'spermission key type.

Note
The permission key defines the scope of a permission grant, which is usually per-origin. Powerful features may override thepermission key type to specify a custom permission key. This is useful for features that want to change the granularity of permissions based on additional context, such as double-keying on both an embedded origin and a top-level origin.

To determine whether apermission keykey1is equal to apermission keykey2, given aPermissionDescriptordescriptor, run the following steps:

  1. Ifkey1 is not ofdescriptor'spermission key type orkey2 is not ofdescriptor'spermission key type, return false.
  2. Return the result of running thepermission key comparison algorithm for the feature named bydescriptor'sname, passingkey1 andkey2.

3.3 Powerful features

Apowerful feature is a web platform feature (usually an API) for which a user givesexpress permission before the feature can be used. Except for a few notable exceptions (e.g., theNotifications API Standard), most powerful features are alsopolicy-controlled features. For powerful features that are alsopolicy-controlled features, [Permissions-Policy] controls whether adocument isallowed to use a given feature. That is, a powerful feature can only requestexpress permission from a user if thedocument has permission delegated to it via the correspondingpolicy-controlled feature (see example below). Subsequent access to the feature is determined by the user having"granted" permission, or by satisfying some criteria that is equivalent to a permissiongrant.

Example 4: Powerful features are policy-controlled features

This example shows how the permissions policy set through theallow attribute controls whether theiframe isallowed to use a powerful feature. Because"geolocation" is allowed, theiframe's document can request permission from the user to use theGeolocation (i.e., it will prompt the user for express permission to access their location information). However, requesting permission to use any other feature will be automatically denied, because they are not listed in theallow attribute.

<iframesrc="https://example.com/"allow="geolocation"></iframe>

SeeA. Relationship to the Permissions Policy specification for more information.

Apowerful feature is identified by itsname, which is a string literal (e.g., "geolocation").

The user agent tracks whichpowerful features the user haspermission to use via theenvironment settings object.

3.3.1 Aspects

Eachpowerful feature can define zero or more additionalaspects. An aspect is defined as WebIDLdictionary thatinherits fromPermissionDescriptor and serves as a WebIDL interface'spermission descriptor type.

Example 5: Defining your own permission descriptor type

A hypotheticalpowerful feature "food detector API" has twoaspects that allow sensing taste and smell. So, a specification would define a new WebIDL interface thatinheritsPermissionDescriptor:

dictionary SensesPermissionDescriptor :PermissionDescriptor {booleancanSmell=false;booleancanTaste=false;};

Which would then be queried via the API in the following way:

// Check if the "senses" powerful feature is allowed to smell thingsconst status =await navigator.permissions.query({name:"senses",canSmell:true,});// Do something interesting with the status.

A user can restrict the "senses" powerful feature to only "taste", in which case thePermissionStatus'sstate above would be "denied" .

3.4 Permissions task source

Thepermissions task source is atask source used to perform permissions-relatedtasks in this specification.

4. Specifying a powerful feature

When a conformingspecificationspecifies a powerful feature it:

  1. MUST give thepowerful feature aname in the form of aascii lowercase string.
  2. MAY define apermission descriptor type that inherits fromPermissionDescriptor.
  3. MAY define zero or moreaspects.
  4. MAY override the algorithms and types given below if the defaults are not suitable for a particularpowerful feature.
  5. MUST register thepowerful feature in thePermissions Registry.

Registering the newly specifiedpowerful features in thePermissions Registry gives this Working Group an opportunity to provide feedback and check that integration with this specification is done effectively.

Apermission descriptor type:

PermissionDescriptor or one of its subtypes. If unspecified, this defaults toPermissionDescriptor.

The feature can define apartial order on descriptor instances. IfdescriptorA isstronger thandescriptorB, then ifdescriptorA'spermission state is "granted",descriptorB'spermission state must also be "granted", and ifdescriptorB'spermission state is "denied",descriptorA'spermission state must also be "denied".

Example 6: A permission descriptor that defines a partial order

{name: "midi", sysex: true} ("midi-with-sysex") isstronger than{name: "midi", sysex: false} ("midi-without-sysex"), so if the user denies access to midi-without-sysex, the UA must also deny access to midi-with-sysex, and similarly if the user grants access to midi-with-sysex, the user agent must also grant access to midi-without-sysex.

permission state constraints:
Constraints on the values that the user agent can return as a descriptor'spermission state. Defaults to no constraints beyond the user's intent.
extra permission data type:

Somepowerful features have more information associated with them than just aPermissionState. Each of these features defines anextra permission data type.

Note

For example,getUserMedia() needs to determinewhich cameras the user has granted permission to access.

If aDOMStringname names one of these features, thenname'sextra permission data for an optionalenvironment settings objectsettings is the result of the following algorithm:

  1. Ifsettings wasn't passed, set it to thecurrent settings object.
  2. If there was a previous invocation of this algorithm with the samename andsettings, returningpreviousResult, and the user agent has not receivednew information about the user's intent since that invocation, returnpreviousResult.
  3. Return the instance ofname'sextra permission data type that matches the UA's impression of the user's intent, taking into account anyextra permission data constraints forname.

If specified, theextra permission data algorithm is usable for this feature.

Optionalextra permission data constraints:
Constraints on the values that the user agent can return as apowerful feature'sextra permission data. Defaults to no constraints beyond the user's intent.
Apermission result type:
PermissionStatus or one of its subtypes. If unspecified, this defaults toPermissionStatus.
Apermission query algorithm:

Takes an instance of thepermission descriptor type and a new or existing instance of thepermission result type, and updates thepermission result type instance with the query result. Used byPermissions'query(permissionDesc) method and thePermissionStatus update steps. If unspecified, this defaults to thedefault permission query algorithm.

Thedefault permission query algorithm, given aPermissionDescriptorpermissionDesc and aPermissionStatusstatus, runs the following steps:

  1. Setstatus'sstate topermissionDesc's permission state.
Apermission key type:

The type ofpermission key used by the feature. Defaults toorigin. A feature that specifies a custompermission key typeMUST also specify apermission key generation algorithm.

Apermission key generation algorithm:

Takes anoriginorigin and anoriginembedded origin, and returns a newpermission key. If unspecified, this defaults to thedefault permission key generation algorithm. A feature that specifies a custompermission key generation algorithmMUST also specify apermission key comparison algorithm.

Thedefault permission key generation algorithm, given anoriginorigin and anoriginembedded origin, runs the following steps:

  1. Returnorigin.
Note: Permission Delegation
Most powerful features grant permission to the top-level origin and delegate access to the requesting document viaPermissions Policy. This is known as permission delegation.
Apermission key comparison algorithm:

Takes twopermission keys and returns aboolean that shows whether the two keys are equal. If unspecified, this defaults to thedefault permission key comparison algorithm.

Thedefault permission key comparison algorithm, givenpermission keyskey1 andkey2, runs the following steps:

  1. Returnkey1 issame origin withkey2.
Apermission revocation algorithm:

Takes no arguments. Updates any other parts of the implementation that need to be kept in sync with changes in the results ofpermission states orextra permission data.

If unspecified, this defaults to runningreact to the user revoking permission.

A permissionlifetime:

Specifications that define one or morepowerful featuresSHOULD suggest apermissionlifetime that is best suited for the particular feature. Some guidance on determining the lifetime of a permission is noted below, with a strong emphasis on user privacy. If nolifetime is specified, the user agent provides one.

When the permissionlifetime expires for an origin:

  1. Set the permission back to its defaultpermission state (e.g., by setting it back to"prompt").
  2. For eachbrowsing context associated with the origin (if any),queue a global task on thepermissions task source with thebrowsing context'sglobal object to run thepermission revocation algorithm.
Note: Determining the lifetime of a permission

For particularly privacy-sensitivefeatures, such asMedia Capture and Streams, which can provide a web application access to a user's camera and microphone, some user agents expire a permissiongrant as soon as a browser tab is closed ornavigated. For other features, like theGeolocation, user agents are known to offer a choice of only granting the permission for the session, or for one day. Others, like theNotifications API Standard andPush API APIs, remember a user's decision indefinitely or until the user manually revokes the permission. Note that permissionlifetimes can vary significantly between user agents.

Finding the right balance for the lifetime of a permission requires a lot of thought and experimentation, and often evolves over a period of years. Implementers are encouraged to work with their UX security teams to find the right balance between ease of access to apowerful feature (i.e., reducing the number of permission prompts), respecting a user's privacy, and making users aware when a web application is making use of a particular powerful feature (e.g., via some visual or auditory UI indicator).

If you are unsure about whatlifetime to suggest for apowerful feature, please contact thePrivacy Interest Group for guidance.

Default permission state:

AnPermissionState value that serves as apermission'sdefault state of apowerful feature.

If not specified, thepermission'sdefault state is "prompt".

Adefault powerful feature is apowerful feature with all of the above types and algorithms defaulted.

5. Algorithms to interface with permissions

5.1 Reading the current permission state

Toget the current permission state, given anamename and an optionalenvironment settings objectsettings, run the following steps. This algorithm returns aPermissionState enum value.

  1. Letdescriptor be a newly-createdPermissionDescriptor withname initialized toname.
  2. Return thepermission state ofdescriptor withsettings.

Adescriptor'spermission state, given an optionalenvironment settings objectsettings is the result of the following algorithm. It returns aPermissionState enum value:

  1. Ifsettings wasn't passed, set it to thecurrent settings object.
  2. Ifsettings is anon-secure context, return "denied".
  3. Letfeature bedescriptor'sname.
  4. If there exists apolicy-controlled feature forfeature andsettings'relevant global object has anassociatedDocument run the following step:
    1. Letdocument besettings'relevant global object'sassociatedDocument.
    2. Ifdocument is notallowed to usefeature, return "denied".
  5. Letkey be the result ofgenerating a permission key fordescriptor withsettings'stop-level origin andsettings'sorigin.
  6. Letentry be the result ofgetting a permission store entry withdescriptor andkey.
  7. Ifentry is not null, return aPermissionState enum value fromentry'sstate.
  8. Return thePermissionState enum value that represents the permission state offeature, taking into account anypermission state constraints fordescriptor'sname.

As a shorthand, aDOMStringname'spermission state is thepermission state of aPermissionDescriptor with itsname member set toname.

5.2 Requesting permission to use a powerful feature

Torequest permission to use adescriptor, the user agent must perform the following steps. This algorithm returns either "granted" or "denied".

  1. Letcurrent state be thedescriptor'spermission state.
  2. Ifcurrent state is not "prompt", returncurrent state and abort these steps.
  3. Ask the user forexpress permission for the calling algorithm to use the powerful feature described bydescriptor.
  4. If the user givesexpress permission to use the powerful feature, setcurrent state to "granted"; otherwise to "denied". The user's interaction may providenew information about the user's intent for theorigin.
    Note

    This is intentionally vague about the details of the permission UI and how the user agent infers user intent. User agents should be able to explore lots of UI within this framework.

  5. Letsettings be thecurrent settings object.
  6. Letkey be the result ofgenerating a permission key fordescriptor withsettings'stop-level origin andsettings'sorigin.
  7. Queue a task on thecurrent settings object'sresponsible event loop toset a permission store entry withdescriptor,key, andcurrent state.
  8. Returncurrent state.

As a shorthand,requesting permission to use aDOMStringname, is the same asrequesting permission to use aPermissionDescriptor with itsname member set toname.

5.3 Prompt the user to choose

Toprompt the user to choose one or moreoptions associated with a givendescriptor and an optionalbooleanallowMultiple (default false), the user agent must perform the following steps. This algorithm returns either "denied" or the user's selection.

  1. Ifdescriptor'spermission state is "denied", return "denied" and abort these steps.
  2. Ifdescriptor'spermission state is "granted", the user agent may return one (or more ifallowMultiple is true) ofoptions chosen by the user and abort these steps. If the user agent returns without prompting, then subsequentprompts for the user to choose from the same set of options with the samedescriptor must return the same option(s), unless the user agent receivesnew information about the user's intent.
  3. Ask the user to choose one or moreoptions or deny permission, and wait for them to choose:
    1. If the calling algorithm specified extra information to include in the prompt, include it.
    2. IfallowMultiple is false, restrict selection to a single item fromoptions; otherwise, any number may be selected by the user.
  4. If the user chose one or more options, return them; otherwise return "denied".
    Note

    This is intentionally vague about the details of the permission UI and how the user agent infers user intent. User agents should be able to explore lots of UI within this framework (e.g., a permission prompt could time out and automatically return "denied" without the user making an explicit selection).

As a shorthand,prompting the user to choose from options associated with aDOMStringname, is the same asprompting the user to choose from those options associated with aPermissionDescriptor with itsname member set toname.

5.4 Reacting to users revoking permission

When the user agent learns that the user no longer intends to grant permission to use a feature described by thePermissionDescriptordescriptor in the context described by thepermission keykey,react to the user revoking permission by running these steps:

  1. Rundescriptor'sname'spermission revocation algorithm.
  2. Remove a permission store entry withdescriptor andkey.

6. Permissions API

MDNNavigator/permissions

This feature is in all major engines.

Chrome43+
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo
MDNWorkerNavigator/permissions
Chrome43+
Chrome Android?
Edge?
Edge Mobile?
FirefoxNo
Firefox Android?
Opera?
Opera Android?
Safari16.4+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.1 Extensions to theNavigator andWorkerNavigator interfaces

WebIDL[Exposed=(Window)]partial interfaceNavigator {  [SameObject] readonly attributePermissionspermissions;};[Exposed=(Worker)]partial interfaceWorkerNavigator {  [SameObject] readonly attributePermissionspermissions;};
MDNPermissions

This feature is in all major engines.

Chrome43+
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.2Permissions interface

WebIDL[Exposed=(Window,Worker)]interfacePermissions {Promise<PermissionStatus>query(objectpermissionDesc);};dictionaryPermissionDescriptor {  requiredDOMStringname;};
MDNPermissions/query

This feature is in all major engines.

Chrome43+
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.2.1query() method

When thequery() method is invoked, theuser agentMUST run the followingquery a permission algorithm, passing the parameterpermissionDesc:

  1. Ifthis'srelevant global object is aWindow object, then:
    1. If thecurrent settings object'sassociatedDocument is notfully active, returna promise rejected with an "InvalidStateError"DOMException.
  2. LetrootDesc be the objectpermissionDesc refers to,converted to an IDL value of typePermissionDescriptor.
  3. If the conversionthrows anexception, returna promise rejected with that exception.
  4. IfrootDesc["name"] is not supported, returna promise rejected with aTypeError.
    Note: Why is this not an enum?

    This is deliberately designed to work the same as WebIDL'senumeration (enum) and implementers are encouraged to use their own customenum here. The reason this is not an enum in the specification is that browsers vary greatly in the powerful features they support. Using aDOMString to identify a powerful feature gives implementers the freedom to pick and choose which of the powerful features from thePermissions Registry they wish to support.

  5. LettypedDescriptor be the objectpermissionDesc refers to,converted to an IDL value ofrootDesc'sname'spermission descriptor type.
  6. If the conversionthrows anexception, returna promise rejected with that exception.
  7. Letpromise bea new promise.
  8. Returnpromise and continuein parallel:
    1. Letstatus becreate aPermissionStatus withtypedDescriptor.
    2. Letquery bestatus's[[query]] internal slot.
    3. Runquery'sname'spermission query algorithm, passingquery andstatus.
    4. Queue a global task on thepermissions task source withthis'srelevant global object toresolvepromise withstatus.
MDNPermissionStatus

This feature is in all major engines.

Chrome43+
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.3PermissionStatus interface

WebIDL[Exposed=(Window,Worker)]interfacePermissionStatus :EventTarget {  readonly attributePermissionStatestate;  readonly attributeDOMStringname;  attributeEventHandleronchange;};enumPermissionState {"granted","denied","prompt",};

PermissionStatus instances are created with a[[query]] internal slot, which is an instance of a feature'spermission descriptor type.

The "granted", "denied", and "prompt" enum values represent the concepts of"granted","denied", and"prompt" respectively.

6.3.1 Creating instances

Tocreate aPermissionStatus for a givenPermissionDescriptorpermissionDesc:

  1. Letname bepermissionDesc'sname.
  2. Assert: Thefeature identified byname is supported by the user agent.
  3. Letstatus be a new instance of thepermission result type identified byname:
    1. Initializestatus's[[query]] internal slot topermissionDesc.
    2. Initializestatus'sname toname.
  4. Returnstatus.
MDNPermissionStatus/name

This feature is in all major engines.

Chrome97+
Chrome Android?
Edge?
Edge Mobile?
Firefox93+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.3.2name attribute

Thename attribute returns the value it was initialized to.

MDNPermissionStatus/state

This feature is in all major engines.

Chrome?
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.3.3state attribute

Thestate attribute returns the latest value that was set on the current instance.

MDNPermissionStatus/change_event

This feature is in all major engines.

Chrome43+
Chrome Android?
Edge?
Edge Mobile?
Firefox46+
Firefox Android?
Opera?
Opera Android?
Safari16.4+
Safari iOS?
Samsung Internet?
WebView AndroidNo

6.3.4onchange attribute

Theonchange attribute is anevent handler whose correspondingevent handler event type ischange.

Whenever theuser agent is aware that the state of aPermissionStatus instancestatus has changed, it asynchronously runs thePermissionStatus update steps:

  1. Ifthis'srelevant global object is aWindow object, then:
    1. Letdocument bestatus'srelevant global object'sassociated Document.
    2. Ifdocument is null ordocument is notfully active, terminate this algorithm.
  2. Letquery bestatus's[[query]] internal slot.
  3. Runquery'sname'spermission query algorithm, passingquery andstatus.
  4. Queue a task on thepermissions task source tofire an event namedchange atstatus.

6.3.5 Garbage collection

APermissionStatus objectMUST NOT be garbage collected if it has anevent listener whose type ischange.

7.Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

The key wordsMAY,MUST,MUST NOT,OPTIONAL, andSHOULD in this document are to be interpreted as described inBCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

Two classes of product can claim conformance to this specification:user agents and otherspecifications (i.e., a technical report thatspecifies a powerful feature in a manner that conforms to the requirements of this specification).

A. Relationship to the Permissions Policy specification

This section is non-normative.

Although both this specification and thePermissions Policy specification deal with "permissions", each specification serves a distinct purpose in the platform. Nevertheless, the two specifications do explicitly overlap.

On the one hand, this specification exclusively concerns itself withpowerful features whose access is managed through a user-agent mediated permissions UI (i.e., permissions where the user gives express consent before that feature can be used, and where the user retains the ability to deny that permission at any time for any reason). These powerful features are registered in thePermissions Registry.

On the other hand, thePermissions Policy specification allows developers to selectively enable and disable policy-controlled features through a "permissions policy" (be it a HTTP header or theallow attribute). In that sense, the Permissions Policy subsumes this specification in thatPermissions Policy governs whether a feature is available at all, independently of this specification. These policy-controlled features are also registered in thePermissions Registry.

A powerful feature that has been disabled by thePermissions Policy specification always has itspermission state reflected as "denied" by this specification. This occurs becausereading the current permission relies on [HTML]'s "allowed to use" check, which itself calls into thePermissions Policy specification. Important to note here is the sharing of permission names across both specifications. Both this specification and thePermissions Policy specification rely on other specifications defining the names of the permission andname, and they are usually named the same thing (e.g., "geolocation" of theGeolocation, and so on).

Finally, it's not possible for a powerful feature to ever become "granted" through any means provided by thePermissions Policy specification. The only way that apowerful feature can be"granted" is by the user givingexpress permission or by some user agent policy.

B. Automated testing

For the purposes of user-agent automation and application testing, this document defines extensions to the [WebDriver] and [WebDriver-BiDi] specifications. It isOPTIONAL for a user agent to support them.

WebIDLdictionaryPermissionSetParameters {  requiredobjectdescriptor;  requiredPermissionStatestate;};

Toset a permission given aPermissionDescriptordescriptor, aPermissionStatestate, an optionalpermission keykey, and an optionaluser agent:

  1. Lettarget key be the result ofgenerating a permission key fordescriptor withcurrent settings object'stop-level origin andcurrent settings object'sorigin ifkey is null, orkey otherwise.
  2. Letsettings list be alist containing allenvironment settings objects which belong to theuser agent if provided, or all user agents otherwise.
  3. Lettargets be an emptylist.
  4. For eachenvironment settings objectsettings insettings list:
    1. Letsettings key be be the result ofgenerating a permission key fordescriptor withsettings'stop-level origin andsettings'sorigin.
    2. Letmatches be the result of running thepermission key comparison algorithm fordescriptor, givensettings key andkey.
    3. Ifmatches, thenappendsettings totargets.
  5. Lettasks be an emptylist.
  6. For eachenvironment settings objecttarget intargets:
    1. Queue a tasktask on thepermissions task source oftarget'srelevant settings object'sglobal object'sbrowsing context to perform the following step:
      1. Interpretstate as if it were the result of an invocation ofpermission state fordescriptor with the argumenttarget made at this moment.
    2. Appendtask totasks.
  7. Wait for alltasks intasks to have executed and return.

B.1 Automated testing with [WebDriver]

This document defines the followingextension commands for the [WebDriver] specification.

B.1.1 Set Permission

HTTP MethodURI Template
POST /session/{session id}/permissions

TheSet Permissionextension command simulates user modification of aPermissionDescriptor'spermission state.

Theremote end steps are:

  1. LetparametersDict be theparameters argument,converted to an IDL value of typePermissionSetParameters. If this throws an exception, return aninvalid argumenterror.
  2. IfparametersDict.state is an inappropriatepermission state for any implementation-defined reason, return aninvalid argumenterror.
    Note

    For example,user agents that define the "midi"powerful feature as "always on" can choose to reject a command to set thepermission state to "denied" at this step.

  3. LetrootDesc beparametersDict.descriptor.
  4. LettypedDescriptor be the objectrootDesc refers to,converted to an IDL value ofpermission descriptor type matching the result ofGet(rootDesc, "name"). If this throws an exception, return ainvalid argumenterror.
  5. Set a permission withtypedDescriptor andparametersDict.state.
  6. Returnsuccess with datanull.
Example 7: Setting a permission via WebDriver

Toset permission for{name: "midi", sysex: true} of thecurrent settings object of thesession with ID 23 to "granted", the local end would POST to/session/23/permissions with the body:

{"descriptor":{"name":"midi","sysex":true},"state":"granted"}

B.2 Automated testing with [WebDriver-BiDi]

This document defines the followingextension modules for the [WebDriver-BiDi] specification.

B.2.1 The permissions Module

Thepermissions module contains commands for managing the remote end browser permissions.

B.2.1.1 Definition

{^remote end definition^}

PermissionsCommand = (  permissions.setPermission)
B.2.1.2 Types
B.2.1.2.1 The permissions.PermissionDescriptor Type
permissions.PermissionDescriptor = {  name: text,}

Thepermissions.PermissionDescriptor type represents aPermissionDescriptor.

B.2.1.2.2 The permissions.PermissionState Type
permissions.PermissionState = "granted" / "denied" / "prompt"

Thepermissions.PermissionState type represents aPermissionState.

B.2.1.3 Commands
B.2.1.3.1 The permissions.setPermission Command

TheSet Permissioncommand simulates user modification of aPermissionDescriptor'spermission state.

Command Type
permissions.setPermission = (  method: "permissions.setPermission",  params: permissions.SetPermissionParameters)permissions.SetPermissionParameters = {  descriptor: permissions.PermissionDescriptor,  state: permissions.PermissionState,  origin: text,  ? embeddedOrigin: text,  ? userContext: text,}
Result Type
EmptyResult

Theremote end steps withsession andcommand parameters are:

  1. Letdescriptor be the value of thedescriptor field ofcommand parameters.
  2. Letpermission name be the value of thename field ofdescriptor representingname.
  3. Letstate be the value of thestate field ofcommand parameters.
  4. Letuser context id be the value of theuserContext field ofcommand parameters, if present, anddefault otherwise.
  5. Ifstate is an inappropriatepermission state for any implementation-defined reason, returnerror witherror codeinvalid argument.
  6. LettypedDescriptor be the objectdescriptor refers to,converted to an IDL value (descriptor,state) ofPermissionSetParameterspermission name'spermission descriptor type. If this conversion throws an exception, returnerror witherror codeinvalid argument.
  7. Letorigin be the value of theorigin field ofcommand parameters.
  8. Letembedded origin be the value of theembeddedOrigin field ofcommand parameters, if present, andorigin otherwise.
  9. Letkey be the result ofgenerating a permission key fordescriptor withorigin andembedded origin.
  10. Letuser agent be theuser agent that represents theuser context with the iduser context id.
  11. Set a permission withtypedDescriptor,state,key, anduser agent.
  12. Returnsuccess with datanull.

C. Permissions Registry

This section is non-normative.

C.1 Purpose

ThisW3C Registry provides a centralized place to find thepolicy-controlled features and/orpowerful features of the web platform. Through thechange process it also helps assure permissions in the platform are consistently specified across various specifications.

By splitting the registry into standardized permissions and provisional permissions, the registry also provides a way to track the status of these features.

C.2 Change Process

Thechange process for adding and/or updating this registry is as follows:

  1. If necessary, add a "Permissions Policy" section to your specification which includes the following:
    1. The string that identifies the policy controlled feature (e.g.,"super-awesome"). Make sure the string is linkable by wrapping it adfn element.
    2. Thedefault allowlist value (e.g.'self').
      Example 8: Specifying a Permissions Policy

      An typical example that would meet this criteria:

      The Super Awesome API defines apolicy-controlled feature identified by the string "super-awesome". Itsdefault allowlist is'self'.
  2. Determine if your feature meets the definition of apowerful feature (i.e., requiresexpress permission to be used). If it does:
    1. Specify a powerful feature in your specification in conformance with thePermissions specification.
  3. Modify either thetable of standardized permissions or thetable of provisional permissions filling out each column with the required information.
  4. Submit a pull request to thePowerful Features Registry Repository on GitHub with your changes. The maintainers of the repository will review your pull request and check that everything integrates properly.

C.3 Registry table of standardized permissions

For a permission to appear in the table of standardized permissions, and thus be considered astandardized permission, it needs to meet the following criteria:

Eachpermission is identified by a unique literal string. In the case ofPermissions Policy, the string identifies apolicy-controlled features. Similarly, in thePermissions specification the string identifies apowerful feature.

Note: Permissions and Permissions Policy

Not everypolicy-controlled feature ispowerful features. For example, "web-share" is apolicy-controlled feature that is not classified as apowerful feature because it doesn't requireexpress permission to be used. However, with very few exceptions, mostpowerful features are alsopolicy-controlled features. For example, "geolocation" is both apolicy-controlled feature and apowerful feature, as it requiresexpress permission to be used. Please refer to thePermissions specification for guidance on how tospecify a powerful feature.

Table of standardized permissions of the web platform
Identifying string Ispolicy-controlled feature? Ispowerful feature? Specification Implementations
ChromiumGeckoWebKit
"geolocation" YES YESGeolocation YES YES YES
"notifications" NO YESNotifications API Standard YES YES YES
"push" NO YESPush API YES YES YES
"web-share" YES NOWeb Share API YES YES YES

C.4 Registry table of provisional permissions

Provisional permissions are permissions that are not yetstandardized (i.e., they are either experimental, still in the incubation phase, or are only implemented in a single browser engine).

Table of provisional permissions
Identifying string Ispolicy-controlled feature? Ispowerful feature? Specification Implementations
ChromiumGeckoWebKit
"accelerometer" YES YESDevice Orientation and Motion YES NO NO
"window-management" YES YESWindow Management YES NO NO
"local-fonts" YES YESLocal Font Access API YES NO NO

D. Privacy considerations

An adversary could use apermission state as an element in creating a "fingerprint" corresponding to an end-user. Although an adversary can already determine the state of a permission by actually using the API, that often leads to a UI prompt being presented to the end-user (if the permission was not already"granted"). Even though this API doesn't expose new fingerprinting information to websites, it makes it easier for an adversary to have discreet access to this information.

A user agentSHOULD provide a means for the user to review, update, and reset thepermissionstate ofpowerful features associated with anorigin.

E. Security considerations

There are no documented security considerations at this time. Readers are instead encouraged to read sectionD. Privacy considerations.

F.IDL Index

WebIDL[Exposed=(Window)]partial interfaceNavigator {  [SameObject] readonly attributePermissionspermissions;};[Exposed=(Worker)]partial interfaceWorkerNavigator {  [SameObject] readonly attributePermissionspermissions;};[Exposed=(Window,Worker)]interfacePermissions {Promise<PermissionStatus>query(objectpermissionDesc);};dictionaryPermissionDescriptor {  requiredDOMStringname;};[Exposed=(Window,Worker)]interfacePermissionStatus :EventTarget {  readonly attributePermissionStatestate;  readonly attributeDOMStringname;  attributeEventHandleronchange;};enumPermissionState {"granted","denied","prompt",};dictionaryPermissionSetParameters {  requiredobjectdescriptor;  requiredPermissionStatestate;};

G. Acknowledgments

This section is non-normative.

The editors would like to thank Adrienne Porter Felt, Anne van Kesteren, Domenic Denicola, Jake Archibald and Wendy Seltzer for their help with the API design and editorial work.

H.References

H.1Normative references

[dom]
DOM Standard. Anne van Kesteren. WHATWG. Living Standard. URL:https://dom.spec.whatwg.org/
[ecma-262]
ECMAScript Language Specification. Ecma International. URL:https://tc39.es/ecma262/multipage/
[HTML]
HTML Standard. Anne van Kesteren; Domenic Denicola; Dominic Farolino; Ian Hickson; Philip Jägenstedt; Simon Pieters. WHATWG. Living Standard. URL:https://html.spec.whatwg.org/multipage/
[infra]
Infra Standard. Anne van Kesteren; Domenic Denicola. WHATWG. Living Standard. URL:https://infra.spec.whatwg.org/
[Notifications]
Notifications API Standard. Anne van Kesteren. WHATWG. Living Standard. URL:https://notifications.spec.whatwg.org/
[Permissions-Policy]
Permissions Policy. Ian Clelland. W3C. 6 August 2025. W3C Working Draft. URL:https://www.w3.org/TR/permissions-policy-1/
[permissions-registry]
Permissions Registry. W3C. Draft Registry. URL:https://w3c.github.io/permissions-registry/
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL:https://www.rfc-editor.org/rfc/rfc2119
[RFC8174]
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. IETF. May 2017. Best Current Practice. URL:https://www.rfc-editor.org/rfc/rfc8174
[WebDriver]
WebDriver. Simon Stewart; David Burns. W3C. 5 June 2018. W3C Recommendation. URL:https://www.w3.org/TR/webdriver1/
[WebDriver-BiDi]
WebDriver BiDi. James Graham; Alex Rudenko; Maksim Sadym. W3C. 1 October 2025. W3C Working Draft. URL:https://www.w3.org/TR/webdriver-bidi/
[webdriver2]
WebDriver. Simon Stewart; David Burns. W3C. 8 September 2025. W3C Working Draft. URL:https://www.w3.org/TR/webdriver2/
[WEBIDL]
Web IDL Standard. Edgar Chen; Timothy Gu. WHATWG. Living Standard. URL:https://webidl.spec.whatwg.org/

H.2Informative references

[appmanifest]
Web Application Manifest. Marcos Caceres; Kenneth Christiansen; Diego Gonzalez-Zuniga; Daniel Murphy; Christian Liebel. W3C. 3 September 2025. W3C Working Draft. URL:https://www.w3.org/TR/appmanifest/
[Geolocation]
Geolocation. Marcos Caceres; Reilly Grant. W3C. 23 September 2025. W3C Recommendation. URL:https://www.w3.org/TR/geolocation/
[GETUSERMEDIA]
Media Capture and Streams. Cullen Jennings; Jan-Ivar Bruaroey; Henrik Boström; youenn fablet. W3C. 25 September 2025. CRD. URL:https://www.w3.org/TR/mediacapture-streams/
[local-font-access]
Local Font Access API. W3C. Draft Community Group Report. URL:https://wicg.github.io/local-font-access/
[orientation-event]
Device Orientation and Motion. Reilly Grant; Marcos Caceres. W3C. 12 February 2025. CRD. URL:https://www.w3.org/TR/orientation-event/
[Permissions]
Permissions. Marcos Caceres; Mike Taylor. W3C. 26 September 2025. W3C Working Draft. URL:https://www.w3.org/TR/permissions/
[push-api]
Push API. Marcos Caceres; Kagami Rosylight. W3C. 25 September 2025. W3C Working Draft. URL:https://www.w3.org/TR/push-api/
[w3c-process]
W3C Process Document. Elika J. Etemad (fantasai); Florian Rivoal. W3C. 18 August 2025. URL:https://www.w3.org/policies/process/
[Web-Share]
Web Share API. Marcos Caceres; Eric Willigers; Matt Giuca. W3C. 30 May 2023. W3C Recommendation. URL:https://www.w3.org/TR/web-share/
[window-management]
Window Management. Joshua Bell; Mike Wasserman. W3C. 7 June 2024. W3C Working Draft. URL:https://www.w3.org/TR/window-management/


[8]ページ先頭

©2009-2025 Movatter.jp