Bug 236349 - Permission API: PermissionStatus with registered "change" listeners shouldn't be GC'd
Summary: Permission API: PermissionStatus with registered "change" listeners shouldn't...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://github.com/w3c/permissions/pu...
Keywords: InRadar
Depends on:
Blocks: 229504
  Show dependency treegraph
 
Reported: 2022-02-08 23:12 PST by Marcos Caceres
Modified: 2022-02-15 09:31 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos Caceres 2022-02-08 23:12:51 PST
Related spec change:
https://github.com/w3c/permissions/pull/360

It should be possible to get a PermissionStatus object, register a listener on it, and allow it to go out of scope (but not have it GC'd) 

For example: 

```JS
(async () => {
  const perm = await navigator.permissions.query({ name: "geolocation" });
  perm.onchange = () => { console.log("pass") };
  console.log("going out of scope");
  // bye bye perm
})();

// prompts for permission
navigator.geolocation.getCurrentPosition(console.log);
```

Changing the permission of Geolocation in the above should produce "pass" in the developer console.
Comment 1 Marcos Caceres 2022-02-08 23:15:58 PST
Noting the works in Blink-based browsers.
Comment 2 youenn fablet 2022-02-11 00:28:48 PST
Right, we do not support yet onchange event handler but when it is the case, we should definitely do something about it.
Comment 3 Radar WebKit Bug Importer 2022-02-15 09:31:12 PST
<rdar://problem/88969778>