Closed Bug 59024 Opened 25 years ago Closed 24 years ago

named forms contain elements not contained in form

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9

People

(Reporter: hrunting, Assigned: jst)

References

()

Details

(Keywords: dom0, regression, Whiteboard: [HAVE FIX])

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) BuildID: 2000110304 If I have a setup like so: <form name="name1"> <input type="hidden" name="blah" value="blah"> </form> <form name="name2"> <input type="submit" name="submit" value="blah"> </form> Then if I do a document.forms['name1'].submit(), it has an assigned value for document.forms['name1'].submit.value of 'blah'. Only document.forms['name2'] should have a submit element with value='blah'. Furthermore, you can't actually submit the 'name1' form then, because the engine doesn't recognize submit() as a method anymore, only as an element within form 'name1'. Of course, this last problem is a problem with JavaScript itself and manifests itself in every other browser that supports it. The problem with form 'name1' getting form 'name2' elements just appeared in this nightly build. I've been using previous builds and it's been working flawlessly. Reproducible: Always Steps to Reproduce: 1.Create those two forms and try to submit the first one. Actual Results: Get an error, 'form.name1.submit' is not an object. form.name1.submit.value == 'blah' Expected Results: form.name1 should've been submitted successfully
Browser, not engine ---> DOM Level 0
Assignee: rogerl → jst
Component: Javascript Engine → DOM Level 0
Keywords: regression
QA Contact: pschwartau → desale
Oops, I guess you can't run this on the Bugzilla server because of the "submit". Sorry -
I've updated the bug with a URL that shows the problem case.
Worksforme: Platform: PC OS: WIndows 98 Mozilla: #2000120604 M18 Trunk Build Marking as such. Reopen if its still a problem.
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → WORKSFORME
Windows 2000 2000121204 MTrunk The bug still manifests itself. If you go to the test case URL (http://hrunting.home.texas.net/mozilla-js-test.html) and make a selection in the pull-down menu under 'Form 1', you'll get a popup box. You'll notice that a value for submit is being returned of 'A Submit Button'. This is the value of the submit input from Form 2. If this is working properly, you should get no popup box, as theForm.submit (the element) will not exist and thus, the check for theForm.submit.value will fail. Form objects still contain elements/values from outside their form definition.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Confirmed reporters claim on Win98 2000121404. Marking as NEW.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Ok, so I finally got around to looking into this and I know how to fix it, I don't have a complete patch since I had the fix intermingled with a whole bunch of other unrelated changes but the idea is to add something like this into nsHTMLFormeElement::Resolve() after it searches the document for named elements: + + nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node)); + + // If htmlDoc->GetElementsByName() found a formcontrol we + // check to see if the formcontrol is part of this form, if + // it's not we don't define the property here... + if (formControl) { + nsCOMPtr<nsIDOMHTMLFormElement> formElement; + + formControl->GetForm(getter_AddRefs(formElement)); + + if (formElement.get() != NS_STATIC_CAST(nsIDOMHTMLFormElement *, + this)) { + // Set node to null so that we don't define the property + // here... + node = nsnull; + } + } + I'll try to get this fixed once I get my huge cleanup patch checked in.
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Hardware: PC → All
Whiteboard: [HAVE FIX, almost]
Target Milestone: --- → mozilla0.9
Keywords: dom0
I don't see a valid testcase in this bug that shows the problem, the testcase that URL in this bug points to doesn't work as described any more, I don't see a popup in neither current mozilla builds nor in IE, did the testcase change? I doubt the real problem here is fixed yet.
The test case at that web page is still valid, and the nightlies have been working correctly with it for some time. You shouldn't get a popup unless the test fails (which it isn't).
Ah, that's right, I did check this in a while ago, that's why I thought the testcase wasn't working :-) I'm leaving this bug open so that I can check that I don't break this with my upcoming change to this code.
Whiteboard: [HAVE FIX, almost] → [HAVE FIX]
My changes are checked in, marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: