@@ -118,8 +118,8 @@ time providing implementations with a better signal of user intent.
118118 <dd> {{HTMLPermissionElement/type}} — Type of permission this element applies to.</dd>
119119 <dd> {{HTMLPermissionElement/isValid}} — query whether the element can currently be activated.</dd>
120120 <dd> {{HTMLPermissionElement/invalidReason}} — Return a string representation of why the element currently cannot be activated.</dd>
121- <dd> {{HTMLPermissionElement/ondismiss }} — notifies when the user has dismissed the permission prompt.</dd>
122- <dd> {{HTMLPermissionElement/onresolve }} — notifies when a permission prompt has been answered by the user (positively or negatively).</dd>
121+ <dd> {{HTMLPermissionElement/onpromptdismiss }} — notifies when the user has dismissed the permission prompt.</dd>
122+ <dd> {{HTMLPermissionElement/onpromptaction }} — notifies when a permission prompt has been answered by the user (positively or negatively).</dd>
123123 <dd> {{HTMLPermissionElement/onvalidationstatuschange}} — notifies when the validation status changes.</dd>
124124 <dt> [=Accessibility considerations=] :</dt>
125125 <dd></dd>
@@ -134,8 +134,8 @@ time providing implementations with a better signal of user intent.
134134 readonly attribute boolean isValid;
135135 readonly attribute PermissionElementBlockerReason invalidReason;
136136
137- attribute EventHandler onresolve ;
138- attribute EventHandler ondismiss ;
137+ attribute EventHandler onpromptaction ;
138+ attribute EventHandler onpromptdismiss ;
139139 attribute EventHandler onvalidationstatuschange;
140140 };
141141 </pre>
@@ -168,8 +168,8 @@ observed by the <{permission}> element to select localized text.
168168The following are the [=event handlers=] (and their corresponding [=event handler event types=] ) that must be supported on <{permission}> elements [=event handler IDL attributes=] :
169169
170170<pre class=simpledef>
171- onresolve : Event
172- ondismiss : Event
171+ onpromptaction : Event
172+ onpromptdismiss : Event
173173onvalidationstatuschange: Event
174174</pre>
175175
@@ -208,6 +208,18 @@ The <{permission}> element has the following internal slots:
208208 {{DOMRectReadOnly}} that stores the most recently seen intersection, i.e.
209209 the position of the <{permission}> relative to the [=viewport=] .
210210
211+ * <dfn attribute for="HTMLPermissionElement">\[[LastNotifiedValidState]]</dfn>
212+ is a [=boolean=] that stores the most recently notified state of
213+ {{HTMLPermissionElement/isValid}} .
214+
215+ * <dfn attribute for="HTMLPermissionElement">\[[LastNotifiedInvalidReason]]</dfn>
216+ is a [=string=] that stores the most recently notified state of
217+ {{HTMLPermissionElement/invalidReason}} .
218+ {{[[LastNotifiedValidState]]}} and {{[[LastNotifiedInvalidReason]]}} are
219+ used to determine whether an
220+ {{HTMLPermissionElement/onvalidationstatuschange}} event needs to be
221+ dispatches.
222+
211223## <{permission}> -supporting state at the [=/navigable=] ## {#permission-element-external-state}
212224
213225In order to support the <{permission}> element, the [=/navigable=] maintains
@@ -464,6 +476,9 @@ The {{HTMLPermissionElement}} constructor steps are:
464476
4654771. Initialize the internal {{[[Types]]}} slot to null.
4664781. Initialize the internal {{[[BlockerList]]}} to «[]».
479+ 1. Initialize the internal {{[[LastNotifiedValidState]]}} with false.
480+ 1. Initialize the internal {{[[LastNotifiedInvalidReason]]}} with the empty
481+ string.
467482
468483</div>
469484
@@ -488,6 +503,7 @@ The {{HTMLPermissionElement}} [=insertion steps=] are:
488503 [=this=]
489504 is a [=fenced navigable=] , then [=add a permanent blocker=]
490505 with {{PermissionElementBlockerReason/illegal_subframe}} .
506+ 1. [=Maybe dispatch onvalidstatechange=] on [=this=] .
491507
492508</div>
493509
@@ -496,6 +512,7 @@ The {{HTMLPermissionElement}} [=removing steps=] are:
496512
4975131. [=list/Remove=] [=this=] from [=node navigable=] 's {{[[PermissionElements]]}} .
4985141. [=Recheck type permissibility=] for [=this=] 's [=node navigable=] .
515+ 1. [=Maybe dispatch onvalidstatechange=] on [=this=] .
499516
500517</div>
501518
@@ -521,10 +538,23 @@ A <{permission}> |element|'s [=EventTarget/activation behavior=] given |event| i
5215381. If |element|'s {{[[Types]]}} [=list/is empty=] , then return.
5225391. If |event|.{{Event/isTrusted}} is false, then return.
5235401. If |element|.{{HTMLPermissionElement/isValid}} is false, then return.
524- 1. [=Request permission to use=] the [=powerful features=] named in |element|'s
525- {{[[Types]]}} .
541+ 1. [=Request permission to use=] the [=powerful features=] named in
542+ |element|'s {{[[Types]]}} .
543+ 1. If the previous step was cancelled or dismissed by the user, then
544+ [=dispatch onpromptdismiss=] on [=this=] and return.
545+
546+ Issue: The [[PERMISSIONS]] spec assumes that [=request permission to use=]
547+ will always succeed. That is, it assumes that the user will always make a
548+ choice and that the algorithm will always deliver a `grant`/`deny`
549+ answer corresponding to that choice. But you can't force a user to do that.
550+ Some [=user agents=] may have different UI affordances for an explicit
551+ denial (e.g. a "deny" button) on one hand, and cancelling or dismissing the
552+ request dialog (e.g. an "X" button in the top right corner). Here, we
553+ distinguish between these two actions, despite no clear hook for this
554+ in the underlying specification.
555+
556+ 1. [=Dispatch onpromptaction=] on [=this=] .
526557
527- Issue: What about event handlers?
528558</div>
529559
530560<div algorithm="HTMLPermissionElement/IntersectionObserver callback">
@@ -551,6 +581,7 @@ The HTMLPermissionElement's <dfn for="HTMLPermissionElement">IntersectionObserve
551581 {{PermissionElementBlockerReason/intersection_changed}} .
5525821. Set {{[[IntersectionRect]]}} to
553583 |entry|.{{IntersectionObserverEntry/intersectionRect}}
584+ 1. [=Maybe dispatch onvalidstatechange=] on [=this=] .
554585
555586ISSUE: Do I need to define dictionary equality?
556587</div>
@@ -583,6 +614,61 @@ To <dfn for="HTMLPermissionElement">recheck type permissibility</dfn> for a
583614
584615</div>
585616
617+ ## <{permission}> element event algorithms ## {#events}
618+
619+ <div algorithm>
620+ To <dfn for=HTMLPermissionElement>maybe dispatch onvalidstatechange</dfn> for |element|:
621+
622+ 1. Let |oldState| be {{[[LastNotifiedValidState]]}} .
623+ 1. Let |newState| be whether |element|’s [=blocker=] is Nothing.
624+ 1. Set {{[[LastNotifiedValidState]]}} to |newState|.
625+ 1. Let |oldReason| be {{[[LastNotifiedInvalidReason]]}} .
626+ 1. Let |newReason| be whether |element|’s
627+ {{HTMLPermissionElement/invalidReason}} .
628+ 1. Set {{[[LastNotifiedInvalidReason]]}} to |newReason|.
629+ 1. If |oldState| != |newState| or |oldReason| != |newReason|, then:
630+ 1. Let |event| be a new {{Event}} .
631+ 1. [=Event/Initialize=] |event| with
632+ <a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
633+ "{{HTMLPermissionElement/onvalidationstatuschange}} ",
634+ <a argument for="Event/initEvent(type, bubbles, cancelable)">bubbles</a>
635+ true, and
636+ <a argument for="Event/initEvent(type, bubbles, cancelable)">cancelable</a>
637+ true.
638+ 1. [=/Dispatch=] |event| to |element|.
639+
640+ </div>
641+
642+ <div algorithm>
643+ To <dfn for=HTMLPermisssionElement>dispatch onpromptaction</dfn> for |element|:
644+
645+ 1. Let |event| be a new {{Event}} .
646+ 1. [=Event/Initialize=] |event| with
647+ <a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
648+ "{{HTMLPermissionElement/onpromptaction}} ",
649+ <a argument for="Event/initEvent(type, bubbles, cancelable)">bubbles</a>
650+ true, and
651+ <a argument for="Event/initEvent(type, bubbles, cancelable)">cancelable</a>
652+ true.
653+ 1. [=/Dispatch=] |event| to |element|.
654+
655+ </div>
656+
657+ <div algorithm>
658+ To <dfn for=HTMLPermisssionElement>dispatch onpromptdismiss</dfn> for |element|:
659+
660+ 1. Let |event| be a new {{Event}} .
661+ 1. [=Event/Initialize=] |event| with
662+ <a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
663+ "{{HTMLPermissionElement/onpromptdismiss}} ",
664+ <a argument for="Event/initEvent(type, bubbles, cancelable)">bubbles</a>
665+ true, and
666+ <a argument for="Event/initEvent(type, bubbles, cancelable)">cancelable</a>
667+ true.
668+ 1. [=/Dispatch=] |event| to |element|.
669+
670+ </div>
671+
586672# Rendering the <{permission}> Element # {#rendering}
587673
588674The <{permission}> element is a [=non-devolvable widget=] and is chiefly
0 commit comments