Skip to content

Commit ce42c2c

Browse files
committed
Spec: Specify permissionStatus + initialPermissionStatus attributes.
1 parent 99ad383 commit ce42c2c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

permission-element.bs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ time providing implementations with a better signal of user intent.
137137

138138
readonly attribute boolean isValid;
139139
readonly attribute PermissionElementBlockerReason invalidReason;
140+
readonly attribute PermissionState initialPermissionStatus;
141+
readonly attribute PermissionState permissionStatus;
140142

141143
static boolean isTypeSupported(DOMString type);
142144

@@ -235,6 +237,10 @@ The <{permission}> element has the following internal slots:
235237
{{HTMLPermissionElement/onvalidationstatuschange}} event needs to be
236238
dispatches.
237239

240+
* <dfn attribute for="HTMLPermissionElement">\[[InitialPermissionStatus]]</dfn>
241+
is a {{PermissionState}} that stores the initial {{PermissionState}} for
242+
{{[[Types]]}}.
243+
238244
## <{permission}>-supporting state at the [=/navigable=] ## {#permission-element-external-state}
239245

240246
In order to support the <{permission}> element, the [=/navigable=] maintains
@@ -291,6 +297,8 @@ The HTMLPermissionElement's {{HTMLPermissionElement/type}} setter steps are:
291297
input string.
292298
1. If |features| is None, return.
293299
1. [=list/Append=] each [=powerful feature=] name to the {{[[Types]]}} [=ordered set=].
300+
1. Set {{[[InitialPermissionStatus]]}} to the result of
301+
[=HTMLPermissionElement/get the current permission state=].
294302

295303
Note: The supported sets of [=powerful features=] is [=implementation-defined=].
296304
</div>
@@ -517,6 +525,8 @@ The {{HTMLPermissionElement}} constructor steps are:
517525
1. Initialize the internal {{[[LastNotifiedValidState]]}} with false.
518526
1. Initialize the internal {{[[LastNotifiedInvalidReason]]}} with the empty
519527
string.
528+
1. Initialize the internal {{[[InitialPermissionStatus]]}} to
529+
the result of [=HTMLPermissionElement/get the current permission state=].
520530

521531
</div>
522532

@@ -569,6 +579,25 @@ HTMLPermissionElement |element|'s <dfn attribute for="HTMLPermissionElement">inv
569579

570580
</div>
571581

582+
<div algorithm>
583+
HTMLPermissionElement |element|'s
584+
<dfn attribute for="HTMLPermissionElement">initialPermissionStatus</dfn>
585+
getter steps are:
586+
587+
1. Return |element|'s internal {{[[InitialPermissionStatus]]}}.
588+
589+
</div>
590+
591+
<div algorithm>
592+
HTMLPermissionElement |element|'s
593+
<dfn attribute for="HTMLPermissionElement">permissionStatus</dfn>
594+
getter steps are:
595+
596+
1. Return [=HTMLPermissionElement/get the current permission state=] for
597+
|element|.
598+
599+
</div>
600+
572601
<div algorithm=activation>
573602
A <{permission}> |element|'s [=EventTarget/activation behavior=] given |event| is:
574603

@@ -651,6 +680,30 @@ To <dfn for="HTMLPermissionElement">recheck type permissibility</dfn> for a
651680

652681
</div>
653682

683+
<div algorithm>
684+
To <dfn for="HTMLPermissionElement">get the current permission state</dfn> for
685+
an {{HTMLPermissionElement}} |element|:
686+
687+
1. Let |types| be |element|'s internal {{[[Types]]}}.
688+
1. If |types| is null or |types| is [=list/empty=],
689+
return {{PermissionState/prompt}}.
690+
1. Let |current| be {{PermissionState/granted}}.
691+
1. [=list/iterate|For each=] |type| of |types|:
692+
1. Let |state| be the result of [=/get the current permission state=] for
693+
|type|.
694+
1. Let |current| be the smaller of |current| and |state|, assuming the
695+
following ordering:
696+
{{PermissionState/granted}} >
697+
{{PermissionState/prompt}} >
698+
{{PermissionState/denied}}.
699+
1. Return |current|.
700+
701+
ISSUE: It's not clear what the PermissionState for 'no valid permission type'
702+
should be. Here I pick "prompt" based on Chrome's implementation; but that
703+
choice is arbitrary.
704+
705+
</div>
706+
654707
## <{permission}> element event algorithms ## {#events}
655708

656709
<div algorithm>

0 commit comments

Comments
 (0)