Closed Bug 115262 Opened 23 years ago Closed 23 years ago

in some cases forms are not visible by JavaScript being referenced by name

Categories

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

defect

Tracking

()

VERIFIED FIXED
mozilla0.9.8

People

(Reporter: atmjav, Assigned: harishd)

References

Details

(Whiteboard: [fix in hand])

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.6+) Gecko/20011213
BuildID:    2001121313

The code
</form>
<form></form>
or
</form></form>
before the form makes it invisible by JavaScript when referencing by form name.

Reproducible: Always
Steps to Reproduce:
1. Create a page with the code below.
2. Try to remove "</form>
<form></form>" before the opening tag BODY and place it again to see when script
cannot access the form.

Actual Results:  JavaScript cannot access the form by name.

Expected Results:  JavaScript should access the form with something like
document.forms['form1'] or document.form1

Here is a sample code with 3 forms and 3 scripts (please notice this code - "</form>
<form></form>"):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Mozilla 2001121313 - bug</title>
</head>
<body bgcolor="#FFFFFF" marginwidth=0 leftmargin=0 rightmargin=0 marginheight=0
topmargin=0 bottommargin=0>
</form>
<form></form>


<form name=form1 action="/m.phtml" method=post><script language=JavaScript>
<!--
if(document.forms['form1']!=null) document.write('the form1 form object exists');
else
document.write('the form1 form object <font color=red>unavailable</font>');
//-->
</script><input type=submit name=submit1 value=" A "></form><br>

<form name=form2 action="/m.phtml" method=post><script language=JavaScript>
<!--
if(document.forms['form2']!=null) document.write('the form2 form object exists');
else
document.write('the form2 form object <font color=red>unavailable</font>');
//-->
</script><input type=submit name=submit1 value=" A "></form><br>

<form name=form3 action="/m.phtml" method=post><script language=JavaScript>
<!--
if(document.form3!=null) document.write('the form3 form object exists');
else
document.write('the form3 form object <font color=red>unavailable</font>');
//-->
</script><input type=submit name=submit1 value=" A "></form>

</body>
</html>
parser.  We seem to only create one <form> node in the case when we have </form>
before the whole thing... (all the text and inputs are children of that form
node; the other <form> nodes are never created).
Assignee: rods → harishd
Status: UNCONFIRMED → NEW
Component: HTML Form Controls → Parser
Ever confirmed: true
OS: Windows 98 → All
QA Contact: madhur → moied
Hardware: PC → All
Status: NEW → ASSIGNED
Priority: -- → P3
Whiteboard: [fix in hand]
Target Milestone: --- → mozilla0.9.8
Blocks: 115400
Blocks: 117213
I am pretty sure this broke phpmyadmin which of course i am using for a
development project woot hope this gets checked in ASAP.
Blocks: 117639
Comment on attachment 61810 [details] [diff] [review]
patch v1.0 [ Make sure that mOpenFormCount memeber doesn't go below zero. ]

r=heikki

I am still not 100% sure this will work always (now and in the future) because
we are not checking the value of mOpenFormCount before decrementing. If
somebody lied, and we had mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM we would just
decrement, which could go into negative. Maybe I am just being overtly
cautious. I would probably add an assertion just in case, but if you think this
situation will never happen it is fine as is.
Attachment #61810 - Flags: review+
>I am still not 100% sure this will work always (now and in the future) because
>we are not checking the value of mOpenFormCount before decrementing.

If NS_PARSER_FLAG_HAS_OPEN_FORM is set then mOpenFormCount will be > 0. And
mOpenFormCount value would never go below 0 because we decrement, in CloseForm,
only if NS_PARSER_FLAG_HAS_OPEN_FORM was set.
Blocks: 118136
Attachment #61810 - Flags: superreview+
Comment on attachment 61810 [details] [diff] [review]
patch v1.0 [ Make sure that mOpenFormCount memeber doesn't go below zero. ]

sr=jst
Blocks: 118706
Blocks: 118169
*** Bug 117054 has been marked as a duplicate of this bug. ***
*** Bug 119110 has been marked as a duplicate of this bug. ***
*** Bug 117213 has been marked as a duplicate of this bug. ***
*** Bug 116218 has been marked as a duplicate of this bug. ***
No longer blocks: 115400
*** Bug 115400 has been marked as a duplicate of this bug. ***
No longer blocks: 118136
*** Bug 118136 has been marked as a duplicate of this bug. ***
No longer blocks: 118169
*** Bug 118169 has been marked as a duplicate of this bug. ***
No longer blocks: 118706
*** Bug 118706 has been marked as a duplicate of this bug. ***
*** Bug 119819 has been marked as a duplicate of this bug. ***
Blocks: 118089
No longer blocks: 118089
*** Bug 118089 has been marked as a duplicate of this bug. ***
I don't see this bug in 2002011403/Win98! Thank you very much, thank you all!
Blocks: 119908
No longer blocks: 119908
*** Bug 119908 has been marked as a duplicate of this bug. ***
Forgot to mark this bug fixed. 
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 120138 has been marked as a duplicate of this bug. ***
*** Bug 120296 has been marked as a duplicate of this bug. ***
Verified with build ID 20020117 on win2k and patch checked in CVS (Rev 3.368)
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: