<?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>278553</bug_id>
          
          <creation_ts>2024-08-22 22:11:44 -0700</creation_ts>
          <short_desc>iframe&apos;s document not focusing when .focus() is called</short_desc>
          <delta_ts>2026-02-21 10:12:48 -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>WebCore Misc.</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>https://jsfiddle.net/3249g6pw/1/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>268516</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcos Caceres">marcosc</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2054881</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos Caceres">marcosc</who>
    <bug_when>2024-08-22 22:11:44 -0700</bug_when>
    <thetext>There appears to be an issue with iframes not focusing when .focus() is called on them.

Test case:

```
window.onload = async function () {
    const iframes = document.querySelectorAll(&quot;iframe&quot;);
    
    for (let iframe of iframes) {
        await new Promise(resolve =&gt; {
            iframe.onload = resolve;
            iframe.src = &quot;about:blank&quot;;
        });
        
        iframe.focus();
        console.assert(iframe.contentDocument.hasFocus(), &quot;The iframe is not focused.&quot;);
    }
};
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2056469</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-08-29 22:12:11 -0700</bug_when>
    <thetext>&lt;rdar://problem/134992720&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095734</commentid>
    <comment_count>2</comment_count>
    <who name="Marcos Caceres">marcosc</who>
    <bug_when>2025-02-18 19:18:29 -0800</bug_when>
    <thetext>Test case https://jsfiddle.net/otg682h0/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2183760</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-21 10:12:48 -0800</bug_when>
    <thetext>(In reply to Marcos Caceres from comment #2)
&gt; Test case https://jsfiddle.net/otg682h0/

*** Safari 26.4 Beta ***

&quot;iframe1 is not focused after calling focus()&quot;
&quot;iframe2 is not focused after calling focus()&quot;
&quot;iframe1 is not focused after swapping focus back&quot;
&quot;Iframe focus test completed.&quot;

*** Chrome Canary 147 (147.0.7699.0 (Official Build) canary (arm64) ) ***

&quot;Iframe focus test completed.&quot;

*** Firefox Nightly 149 (20260220092058) ***

&quot;Iframe focus test completed.&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>