<?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>247593</bug_id>
          
          <creation_ts>2022-11-07 15:39:29 -0800</creation_ts>
          <short_desc>Fix form association behavior when a form and a control with form= are removed from a document together</short_desc>
          <delta_ts>2022-11-13 12:49:19 -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>Forms</component>
          <version>Safari Technology Preview</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=247651</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1910907</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-11-07 15:39:29 -0800</bug_when>
    <thetext>Hi Team,

I came across another Blink Commit, where Safari Technology Preview 157 is failing one particular test case:

Commit - https://src.chromium.org/viewvc/blink?revision=197887&amp;view=revision

Webkit Source - https://github.com/WebKit/WebKit/blob/7f186f0d780258408c1166c9432377365fa5d5b3/Source/WebCore/html/FormAssociatedElement.cpp#L94

Test Case - https://jsfiddle.net/f407psh1/show

Failing Test Case below:

- Check if a form and a control are disassociated when they are removed from the document together.
PASS owner.elements.length is 1
FAIL owner.elements.length should be 0. Was 1.

____

To do:

if (!insertionType.connectedToDocument &amp;&amp; element.hasAttributeWithoutSynchronization(formAttr)) {
** Whatever is here already. ***
resetFormOwner();
return
}

We might need to add InsertionType to definition to &quot;FormAssociatedElement.h&quot; for &quot;removedFromAncestor&quot;:

https://github.com/WebKit/WebKit/blob/7f186f0d780258408c1166c9432377365fa5d5b3/Source/WebCore/html/FormAssociatedElement.h#L97

___

Just wanted to create bug. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1910953</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-11-07 18:32:35 -0800</bug_when>
    <thetext>
The test case being

debug(&apos;- Check if a form and a control are disassociated when they are removed from the document together.&apos;);
container.innerHTML = &apos;&lt;div&gt;&lt;input form=owner&gt;&lt;form id=owner&gt;&lt;/form&gt;&lt;/div&gt;&apos;;
owner = document.getElementById(&apos;owner&apos;);
shouldBe(&apos;owner.elements.length&apos;, &apos;1&apos;);
container.firstChild.remove();
shouldBe(&apos;owner.elements.length&apos;, &apos;0&apos;);



There is another sets of tests failing in this example.
https://jsfiddle.net/f407psh1/show
Probably worth a separate bug.


With  a form/option without a select element
  data:text/html,&lt;form%20id=firstOwner&gt;&lt;option%20id=firstOption&gt;&lt;/option&gt;&lt;/form&gt;

and in the console:

  document.querySelector(&apos;#firstOption&apos;).form 

returns

  null in Firefox and Chrome
  The current HTMLFormElement() in Safari

Same for

  data:text/html,&lt;form id=secondOwner&gt;&lt;optgroup&gt;&lt;option id=secondOption&gt;&lt;/option&gt;&lt;/optgroup&gt;&lt;/form&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911127</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-11-08 15:19:09 -0800</bug_when>
    <thetext>I tried doing this change in following PR but failing because of HTMLObjectElement.cpp using same &quot;removedFromAncestor&quot; and when I modify it as well then I get following build error while also modifying &quot;HTMLObjectElement.h&quot;:

error: non-virtual member function marked &apos;final&apos; hides virtual member function

I am still learning C++ so I might not be able to solve it and is closing my PR for someone else to fix this:

https://github.com/WebKit/WebKit/pull/6229</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912051</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-11-12 19:59:43 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/6437</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912098</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-11-13 12:48:38 -0800</bug_when>
    <thetext>Committed 256620@main (d16d7ec79683): &lt;https://commits.webkit.org/256620@main&gt;

Reviewed commits have been landed. Closing PR #6437 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912099</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-13 12:49:19 -0800</bug_when>
    <thetext>&lt;rdar://problem/102295475&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>