<?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>282849</bug_id>
          
          <creation_ts>2024-11-08 11:57:37 -0800</creation_ts>
          <short_desc>HTMLElement.requestPointerLock does not return a Promise</short_desc>
          <delta_ts>2024-11-14 10:19:08 -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>UI Events</component>
          <version>Safari 18</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew Hodel">andrewhodel</reporter>
          <assigned_to name="Abrar Rahman Protyasha">a_protyasha</assigned_to>
          <cc>a_protyasha</cc>
    
    <cc>brandonstewart</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>ntim</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2073908</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-08 11:57:37 -0800</bug_when>
    <thetext>HTMLElement.requestPointerLock is specified as returning a Promise at https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074743</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-12 23:11:36 -0800</bug_when>
    <thetext>Andrew,
what are you testing on?
what is the code you are using to test?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074782</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-13 05:19:17 -0800</bug_when>
    <thetext>Karl Dubost

I have confirmed this in Safari with `console.log(HTMLElement.requestPointerLock);`</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074874</commentid>
    <comment_count>3</comment_count>
    <who name="Abrar Rahman Protyasha">a_protyasha</who>
    <bug_when>2024-11-13 11:05:16 -0800</bug_when>
    <thetext>While MDN has documented the Promise return type for a while, the spec change to materialize this return type has only changed relatively recently: https://github.com/w3c/pointerlock/commit/0e99fcf3daa23269bf2b019f5269a154088d2347

We currently do return a Promise type if the &quot;Pointer Lock Options&quot; web preference is enabled: https://github.com/WebKit/WebKit/blob/45ccb551a4e879774bdfbd0204476fcd1ff0ea48/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml#L5700-L5713

Andrew, you can use this feature flag as a workaround.

In the meantime, we should consider making the feature flag stable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074876</commentid>
    <comment_count>4</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-13 11:43:41 -0800</bug_when>
    <thetext>@comment #3

Abrar Rahman Protyasha

That is incorrect as you linked to a document that explains the concept of a pointer lock, not a document that documents the HTMLElement.requestPointerLock function.

No change in either of the documents you linked include changes of the HTMLElement.requestPointerLock function returning a Promise instead of the Object that it returns now.

You may be confused in that it returns an Object that has a Promise inside of it, but in proper English nomenclature of a programming language function, it does not return anything other than an Object.  The reason for this is because you could otherwise validate saying that any function returns an Error causing invalidation of all existing documentation of functions that return Object with Error as the value of a named field property inside the Object.

I&apos;m sorry that you are involved in a story relating this to a feature flag.  That is unrelated to this work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074881</commentid>
    <comment_count>5</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-13 11:50:30 -0800</bug_when>
    <thetext>@comment #3

There is no argument that HTMLElement.requestPointerLock must return a Promise.

In Safari it does not.

The confusion in your writing is of https://github.com/mdn/content/issues/36766 and it is completely unrelated to any feature flag and completely unrelated to this issue.

Again, HTMLElement.requestPointerLock must return a Promise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074882</commentid>
    <comment_count>6</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-13 11:53:33 -0800</bug_when>
    <thetext>@comment #3

Abrar Rahman Protyasha

There is no possibility of making the feature flag stable.

The only possibility not requiring a feature flag for the function to work as the specification indicates.

Again, HTMLElement.requestPointerLock must return a Promise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074885</commentid>
    <comment_count>7</comment_count>
    <who name="Andrew Hodel">andrewhodel</who>
    <bug_when>2024-11-13 11:57:12 -0800</bug_when>
    <thetext>@comment #3

Abrar Rahman Protyasha

It is not acceptable to require that a feature flag be enabled in the browser settings for a standardized specification to work as specified because it would mean that all users of any website using that specification are required to enable the feature flag.  That is unacceptable.

Again, HTMLElement.requestPointerLock must return a Promise to be valid per the specification it is implemented of.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074975</commentid>
    <comment_count>8</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2024-11-13 16:35:23 -0800</bug_when>
    <thetext>To be clear, we agree with you, this bug report is accurate, and we need to make this change.

The reason why returning a Promise is currently behind a feature flag is that the specification hasn&apos;t been yet finalized when our code was written. At this time, the feature flag is not needed any more. Can you confirm that enabling the feature provides what you need?

If it does, we&apos;ll go ahead and looking into removing that feature flag, to make the change available to everyone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074986</commentid>
    <comment_count>9</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-13 17:12:52 -0800</bug_when>
    <thetext>const element = document.createElement(&apos;div&apos;); 
console.log(&apos;requestPointerLock: &apos;, element.requestpointerLock());

Safari:  undefined
Firefox: undefined 
Chrome:  Promise

Tested in 

Safari Technology Preview  206           20621.1.3.21.1
Firefox Nightly            134.0a1       13424.11.7
Google Chrome Canary       133.0.6835.0  6835.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074989</commentid>
    <comment_count>10</comment_count>
    <who name="Abrar Rahman Protyasha">a_protyasha</who>
    <bug_when>2024-11-13 17:18:39 -0800</bug_when>
    <thetext>And, to add to Karl&apos;s latest findings, with the &quot;Pointer Lock Options&quot; feature flag enabled, this is what I see with ToT MiniBrowser:

```
requestPointerLock:  Promise {}
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075012</commentid>
    <comment_count>11</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-13 22:37:31 -0800</bug_when>
    <thetext>&lt;rdar://problem/139854530&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075013</commentid>
    <comment_count>12</comment_count>
    <who name="Abrar Rahman Protyasha">a_protyasha</who>
    <bug_when>2024-11-13 22:43:56 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/36631</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075112</commentid>
    <comment_count>13</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-11-14 10:19:06 -0800</bug_when>
    <thetext>Committed 286597@main (2f0bfa7da8bb): &lt;https://commits.webkit.org/286597@main&gt;

Reviewed commits have been landed. Closing PR #36631 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>