diff --git a/index.bs b/index.bs index 4d01fe35..17ec2bae 100644 --- a/index.bs +++ b/index.bs @@ -210,6 +210,14 @@ spec: HR-TIME; urlPrefix: https://w3c.github.io/hr-time/ spec: RFC4648; urlPrefix: https://tools.ietf.org/html/rfc4648 type: dfn text: Base64 Encode; url: section-4 +spec: PERMISSIONS; urlPrefix: https://www.w3.org/TR/permissions/ + type: dfn + text: permission descriptor; url: #dom-permissiondescriptor + text: permission name; url: #permission-name + text: permission state; url: #dom-permissionstate + text: permissions task source; url: #permissions-task-source + text: permissions; url: #permissions + text: set permission; url: #set-permission-command spec: CSS-VALUES-3; urlPrefix: https://drafts.csswg.org/css-values-3/ type: dfn text: absolute lengths; url: #absolute-lengths @@ -3963,6 +3971,133 @@ opened steps given |window|, |type|, |message|, and optional |default valu +## The permissions Module ## {#module-permissions} + +The permissions module contains commands and +events relating to browser [=/permissions=]. [[!PERMISSIONS]] + +### Definition ### {#module-permissions-definition} + +[=remote end definition=] + +
+ +PermissionsCommand = ( + permissions.SetPermission +) + +TODO: Add more commands: QueryPermission, ResetPermission, ResetAllPermissions, etc. + ++ +### Types ### {#module-permissions-types} + +#### The permissions.PermissionDescriptor Type #### {#type-permissions-PermissionDescriptor} + +
+permissions.PermissionDescriptor = { + type: "permissionDescriptor", + name: text, +} ++ +The
permissions.PermissionDescriptor
type represents a [=permission descriptor=].
+
+#### The permissions.PermissionState Type #### {#type-permissions-PermissionState}
+
++permissions.PermissionState = "granted" / "denied" / "prompt" ++ +The
permissions.PermissionState
type represents a [=permission state=].
+
+### Commands ### {#module-permissions-commands}
+
+#### The permissions.setPermission Command #### {#command-permissions-setPermission}
+
+The permissions.setPermission command simulates
+user modification of a {{PermissionDescriptor}}'s [=permission state=].
+
++ permissions.setPermission = ( + method: "permissions.setPermission", + params: permissions.SetPermissionParameters + ) + + permissions.SetPermissionParameters = { + descriptor: permissions.PermissionDescriptor, + state: permissions.PermissionState, + ? context: browsingContext.BrowsingContext, + } ++
+ EmptyResult ++
descriptor
field of
+ |command parameters|.
+
+1. Let |state| be the value of the state
field of |command
+ parameters|.
+
+1. Let |context id| be the value of the context
field of
+ |command parameters|.
+
+1. If |context id| is not present, let |context| be the [=top-level browsing context=]
+ of |session|. Otherwise, let |context| be the result of [=trying=] to
+ [=get a browsing context=] with |context id|.
+
+1. Let |permission name| be the value of the name
field of
+ |descriptor| representing [=permission name=].
+
+1. Convert to an IDL value (|descriptor|, |state|) of type {{PermissionSetParameters}}.
+ If this conversion throws an exception, return [=error=] with [=error code=] [=invalid argument=].
+
+1. Let |typedDescriptor| be the object |descriptor| refers to, converted to an IDL
+ value of |permission name|'s [=powerful
+ feature/permission descriptor type=]. If this throws an exception,
+ return [=error=] with [=error code=] [=invalid argument=].
+
+1. If |state| is an inappropriate [=permission state=] for any
+ implementation-defined reason, return [=error=] with [=error code=] [=invalid argument=].
+
+1. Let |settings| be the [=current settings object=].
+
+1. Let |targets| be a [=/list=] containing all [=environment settings object=]
+ whose [=environment settings object/origin=] is the same as
+ the [=environment settings object/origin=] of |settings|.
+
+1. Let |tasks| be an empty [=/list=].
+
+1. For each [=environment settings object=] |target| in |targets|:
+
+ 1. [=Queue a task=] |task| on the [=permissions task source=] of |target|'s
+ [=relevant settings object=]'s [=environment settings object/global object=]'s
+ [=Window/browsing context=] to perform the following step:
+
+ 1. Interpret |state| as if it were the result of an invocation of [=permission state=]
+ for |typedDescriptor| with the argument |target| made at this moment.
+
+ 1. [=list/Append=] |task| to |tasks|.
+
+1. Wait for all tasks in |tasks| to have executed.
+
+1. Return [=success=] with data null.
+
+