[w3c/permissions] Definition of PermissionStatus lifetime (#266)

According to current spec (https://w3c.github.io/permissions/#permissionstatus-gc), PermissionStatus object should be kept alive if it has event listener or a task is queued. This definition may prolong the lifetime of PermissionStatus object (once client sets change event listener, the object will never be collected). 

For example, in the case where we create a PermissionStatus with an iframe and then remove the iframe:
```
iframe.contentWindow.navigator.permissions.query({name:featureName}).then((status) => {
    status.onchange = stateChangeCallback;
    iframe.contentWindow.asyncRequestPermissionForFeature(featureName); 
    setTimeout(() => { iframe.remove(); }, someTimeout);
    status = null;
}
```
Is it necessary to keep status object alive and fire events after iframe is gone?
It seems current Chrome currently stops firing events after global object is gone.

Spec should be more specific about when it's Okay to stop firing event (and stop keeping the PermissionStatus alive). "Only when PermissionStatus has no event listener" does not sound right.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/permissions/issues/266

Received on Saturday, 28 August 2021 01:35:50 UTC