<?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>267569</bug_id>
          
          <creation_ts>2024-01-16 00:12:25 -0800</creation_ts>
          <short_desc>Quirks: ceac.state.gov requires document.activeElement to be HTMLInputElement</short_desc>
          <delta_ts>2026-04-02 18:34:06 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=267623</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=276709</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=22261</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=311383</see_also>
          <bug_file_loc>http://ceac.state.gov/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>193478</dependson>
    
    <dependson>267449</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2005200</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-16 00:12:25 -0800</bug_when>
    <thetext>There is a webcompat issue created by a different behavior in between Firefox/Chrome on one side and Safari on the other side related to the way the OS is built. 

It would be great if ceac.state.gov fixes the issue, but in the mean time, there is probably a need for a Quirk to solve it. 

This is related to Bug 267449
`document.activeElement` for an `onclick` on a `&lt;input type=checkbox&gt;` returns HTMLBodyElement instead of HTMLInputElement


There is a beforeunload

if (window.addEventListener) {
    window.addEventListener(&quot;beforeunload&quot;, ClearSession, false);
} else if (window.attachEvent) {
    window.attachEvent(&quot;onbeforeunload&quot;, ClearSession)
}

It fires a ClearSession.

Which triggers

else if (document.location.pathname.indexOf(&quot;Default.aspx&quot;) &lt; 0 &amp;&amp;
                typeof document.activeElement != &quot;undefined&quot; &amp;&amp;
            document.activeElement.toString().indexOf(&quot;HTMLBodyElement&quot;) &gt; 0 ||
            document.activeElement.toString().indexOf(&quot;HTMLInputElement&quot;) &gt; 0) {
        validNavigation = false;
    }

And triggers:

this.ExitClearSession()

Which triggers the e.preventDefault()

    if (validNavigation == false &amp;&amp;
             e != undefined) {
        if (ieMode == &quot;True&quot;) {
            e.returnValue = undefined;
        } else {
            e.preventDefault();
        }

And when the return is happening at the end of ClearSession it opens the alert. 



Firefox in the clear session is 

    } else if ((typeof document.activeElement != &quot;undefined&quot; &amp;&amp;
                document.activeElement != &quot;object&quot; &amp;&amp;
                typeof document.activeElement.name != &quot;undefined&quot;) &amp;&amp; (
                document.activeElement.toString().indexOf(&quot;aspx&quot;) &gt; 0 || //for the left menu exclusion                
                document.activeElement.name.indexOf(&quot;btn&quot;) &gt; 0 ||  //check for button click
                document.activeElement.name.indexOf(&quot;Button&quot;) &gt; 0 ||
                document.activeElement.type == &quot;button&quot;) ||
                document.activeElement.id.indexOf(&quot;cbx&quot;) &gt; 0 ||
                document.activeElement.id.indexOf(&quot;Radio&quot;) &gt; 0 ||
                document.activeElement.id.indexOf(&quot;radio&quot;) &gt; 0 ||
                document.activeElement.id.indexOf(&quot;chkbx&quot;) &gt; 0 ||
                document.activeElement.id.indexOf(&quot;Button&quot;) &gt; 0 ||
                document.activeElement.id.indexOf(&quot;button&quot;) &gt; 0) { // for button
        validNavigation = true;


Firefox: document.activeElement is input
Safari: document.activeElement is body

This will decide if validNavigation is true or false
And then will make WebKit fail for the next step.


For the purpose of this quirk, it is necessary that the document.activeElement returns HTMLInputElement at this stage.


This is not the first time that there is an issue with this site.
And probably the previous Quirks was done to solve this issue but this is not working anymore. 
See Bug 193478 
https://searchfox.org/wubkat/rev/581e116dc6ce254811dbe2da9d1c1168762fc30c/Source/WebCore/page/Quirks.cpp#130-141</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005201</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-16 00:12:47 -0800</bug_when>
    <thetext>&lt;rdar://110953808&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005512</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-16 23:53:32 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/22854</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2006462</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-01-21 18:11:40 -0800</bug_when>
    <thetext>Committed 273282@main (0b543cc9ff31): &lt;https://commits.webkit.org/273282@main&gt;

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

    </bug>

</bugzilla>