<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>236349</bug_id>
          
          <creation_ts>2022-02-08 23:12:51 -0800</creation_ts>
          <short_desc>Permission API: PermissionStatus with registered &quot;change&quot; listeners shouldn&apos;t be GC&apos;d</short_desc>
          <delta_ts>2022-02-15 09:31:12 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>https://github.com/w3c/permissions/pull/360</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>229504</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcos Caceres">marcos</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>marcos</cc>
    
    <cc>sihui_liu</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1839027</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos Caceres">marcos</who>
    <bug_when>2022-02-08 23:12:51 -0800</bug_when>
    <thetext>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&apos;d) 

For example: 

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

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

Changing the permission of Geolocation in the above should produce &quot;pass&quot; in the developer console.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1839028</commentid>
    <comment_count>1</comment_count>
    <who name="Marcos Caceres">marcos</who>
    <bug_when>2022-02-08 23:15:58 -0800</bug_when>
    <thetext>Noting the works in Blink-based browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1840245</commentid>
    <comment_count>2</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-02-11 00:28:48 -0800</bug_when>
    <thetext>Right, we do not support yet onchange event handler but when it is the case, we should definitely do something about it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1841754</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-02-15 09:31:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/88969778&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>