Bug 3714 - REGRESSION: HTMLLabelElement.form returns null
Summary: REGRESSION: HTMLLabelElement.form returns null
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-25 15:23 PDT by Curt Arnold
Modified: 2005-06-29 13:29 PDT (History)
0 users

See Also:


Attachments
Web page and associated scripts (5.51 KB, application/octet-stream)
2005-06-25 15:24 PDT, Curt Arnold
no flags Details
Traverse parent nodes looking for a form element (2.36 KB, patch)
2005-06-27 12:31 PDT, Anders Carlsson
darin: review-
Details | Formatted Diff | Diff
Test of HTMLLabelElement.form outside of a form (expect null) (5.49 KB, application/octet-stream)
2005-06-27 16:57 PDT, Curt Arnold
no flags Details
Update test case (2.66 KB, patch)
2005-06-28 14:46 PDT, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Curt Arnold 2005-06-25 15:23:16 PDT
The attached tarball contains a production of the HTMLLabelElement01 test case from the DOM L2 Test 
suite.  The test passes on Safari build 412 and Firefox but will fail on the current WebKit CVS HEAD due to 
the CVS HEAD returning null on the call to HTMLLabelElement.form in HTMLLabelElement01.js (fNode = 
testNode.form;).
Comment 1 Curt Arnold 2005-06-25 15:24:46 PDT
Created attachment 2646 [details]
Web page and associated scripts

Open HTMLLabelElement01.html in Safari.  Will display green success message in
stock Safari and Firefox, red error with CVS HEAD.
Comment 2 Curt Arnold 2005-06-25 16:27:14 PDT
IE 6 and Opera 8.01 on Windows also pass test.

Bug 3715 is related (involves HTMLObjectElement) but is not a regression.
Comment 3 Joost de Valk (AlthA) 2005-06-26 12:30:55 PDT
confirmed
Comment 4 Anders Carlsson 2005-06-27 12:31:36 PDT
Created attachment 2674 [details]
Traverse parent nodes looking for a form element

Turns out that the form() method was buggy. Also, it tried to get the form of
the element set as "for", which is broken (Neither Gecko nor WinIE does this)
Comment 5 Darin Adler 2005-06-27 16:35:35 PDT
Comment on attachment 2674 [details]
Traverse parent nodes looking for a form element

A few comments:

    1) The old version of HTMLLabelElementImpl::form has a bug -- it's calling
isGenericFormElement() on this rather than on element. That's fine if we are
rewriting it, but worth noting.
    2) The loop looking for a ID_FORM in parents is the same as the existing
getForm() function; we should not write a new copy of that function. (Although
perhaps we should rename it.)
    3) I don't think this is significantly different from the form function in
the base class. Can we just remove the override of the base form class's form
function?

Do we have a test for the case where the <label> element is outside the form
and the form element it points to is inside? What about when the <label> is in
one form, and the form element is in another?
Comment 6 Curt Arnold 2005-06-27 16:57:25 PDT
Created attachment 2677 [details]
Test of HTMLLabelElement.form outside of a form (expect null)
Comment 7 Curt Arnold 2005-06-27 16:58:01 PDT
There only appear to be two tests in the DOM L2 HTML test suite that address HTMLLabelElement.form: 
HTMLLabelElement01 and HTMLLabelElement02.  Both load the same document, but test different 
elements.  HTMLLabelElement02 checks that a label outside the range of a form returns null for 
HTMLLabelElement.form.  I've attached HTMLLabelElement02 as an attachment to the bug report, though 
it passed in the original implementation.  I'm not sure if I understand the third case you are suggesting.

The DOM TS distributions contain reports that break down tests by name, functions tested, etc.  If you 
download the suite, open dom2-html-matrix.html in a browser.  Hopefully pretty explanatory.  
Unfortunately due to a strange nature of the L2 HTML suite, the links to the XML test definitions are 
broken except for tests that are not shared with the L1 HTML suite, but the links to the Java rendering 
should still be good.
Comment 8 Anders Carlsson 2005-06-28 14:46:40 PDT
Created attachment 2691 [details]
Update test case

Note that HTMLLabelElementImpl doesn't inherit from HTMLGenericFormElementImpl,
so we can't use its form() method. 

I've updated the test case with a label outside a form but its for element
inside a form.
Comment 9 Darin Adler 2005-06-29 08:14:54 PDT
Comment on attachment 2691 [details]
Update test case

r=me