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

So to clarify, given that the specification doesn't say when UA may stop updating the permission status of a given realm, the behaviors of Chrome and Gecko are both spec compliant. What is rather confusing is the spec text written in [section 7.1. garbage collection](https://w3c.github.io/permissions/#permissionstatus-gc).

> While an PermissionStatus object has one or more event listeners registered for "change", there must be a strong reference from the Window or WorkerGlobalScope object that the PermissionStatus object’s constructor was invoked from to the PermissionStatus object itself.
>
> While there is a task queued by an PermissionStatus object on the permissions task source, there must be a strong reference from the Window or WorkerGlobalScope object that the PermissionStatus object’s constructor was invoked from to that PermissionStatus object.

Both of these points are tautological / redundant since if a given realm's permissions were to change, then UA must schedule a task to dispatch `change` event [per section 7](https://w3c.github.io/permissions/#permissionstatus-interface). ECMA semantics of exotic objects is such that object can't spontaneously disappear and come back into existence. So, as long as there are possibilities that an event can be fired on `PermissionStatus` interface in the future, UA must keep this JS object alive.

More specifically, in implementations such as Blink and WebKit where the exotic object consist of the underlying C++ object as well as JS wrapper objects in V8 & JSC, it would mean that such a JS wrapper object must be kept alive so long as there is a possibility that a `change` event can fired on `PermissionStatus` object such that the event is anyway observable by the author scripts.

I think a better way to communicate this intent is to specify that the permission status of a realm MUST not change when the global object is a [Window](https://html.spec.whatwg.org/multipage/window-object.html#the-window-object) and its [browsing context](https://html.spec.whatwg.org/multipage/browsers.html#browsing-context) is null.

-- 
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#issuecomment-907555545

Received on Saturday, 28 August 2021 02:49:50 UTC