Closed Bug 14223 Opened 25 years ago Closed 25 years ago

JavaScript code not executed if a form appears first in the page

Categories

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

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: gerardok, Assigned: pollmann)

References

Details

Attachments

(1 file)

Overview Description: If you have a page that contains a form element and some
JavaScript code, the code is not executed. If the form is removed, the
JavaScript code runs fine.

Steps to Reproduce:
1) Open the attached testcase in the Browser, or create an HTML file with the
following content and open it:

<HTML>
<HEAD>
<TITLE>Form followed by JavaScript</TITLE>
</HEAD>
<BODY>
<FORM ACTION="donothing.cgi" METHOD="post">
</FORM>

<SCRIPT>
//dump("hello");   //uncomment for viewer
alert("hello");
</SCRIPT>

</BODY>
</HTML>

Actual Results: Alert dialog not displayed

Expected Results: Alert dialog displayed on screen

Build ID & Platform Bug Found: 1999-09-17-13-M11 on Win NT

Additional Builds and Platforms Failed On: 1999-09-17-08-M11 on Mac OS and
1999-09-17-08-M11 on Linux

Additional Information: If the <FORM> and </FORM> tags are removed, the
JavaScript code runs fine.
QA Contact: janc → gerardok
Attached file testcase
Priority: P3 → P1
Changed priority to P1, as it may prevent enough HTML pages from running
properly.
Assignee: rickg → pollmann
Eric -- please take a look.
Blocks: 11349
Status: NEW → ASSIGNED
Thanks to a lead by Harish, found out where the logic for the processing of this
script tag is turned off:

layout/html/document/src/HTMLContentSink::ProcessSCRIPTTag()

3336   // Don't process scripts that aren't JavaScript and don't process
3337   // scripts that are inside iframes
3338   if (isJavaScript && !mNumOpenIFRAMES) {

In this case, mNumOpenIFRAMES is equal to -1, and thus the script isn't
evaluated.  Why is mNumOpenIFRAMES -1 here?
Found it, it was a missing break here:

1097   case eHTMLTag_form:
1098     {
1099       nsHTMLTag parserNodeType = nsHTMLTag(aNode.GetNodeType());
1100
1101       // If there's a FORM on the stack, but this close tag doesn't
1102       // close the form, then close out the form *and* close out the
1103       // next container up. This is since the parser doesn't do fix up
1104       // of forms. When the end FORM tag comes through, we'll ignore
1105       // it.
1106       if (parserNodeType != nodeType) {
1107         result = CloseContainer(aNode);
1108       }
1109     }
1110
1111   case eHTMLTag_iframe:
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Target Milestone: M11
Just checked in a fix.
Status: RESOLVED → VERIFIED
Verified on 1999-09-23-09-M11 build.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: