Closed Bug 489178 Opened 15 years ago Closed 14 years ago

Script tag <script> causes style color to change to surrounding font color

Categories

(Core :: DOM: HTML Parser, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: jm, Unassigned)

References

Details

(Whiteboard: [fixed by the HTML5 parser])

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8

The presence or absence of a script tag should never influence a color on the page yet does.

<HTML>

<BODY>

<FONT COLOR="green">

<p style="color:red">Should always be red</p>

<script></script>

</FONT>

</BODY>

</HTML>

If the <script> tag in the above is commented out then the text color changes to red. If the script tag is present then the text color is that of the surrounding <font> tag namely green. Tested on Firefox 3.0.8 in normal and in safe mode. Also tested on SeaMonkey 1.1.11 and it does the same.

Reproducible: Always

Steps to Reproduce:
1. Comment out the script tag
2. Put back the script tag

Actual Results:  
No script tag  - text color red
With script tag - text color green

Expected Results:  
No script tag  - text color red
With script tag - text color red

Script tag shouldn't make a difference.
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a5pre) Gecko/20100420 Minefield/3.7a5pre

I tried several variants of the test case, and was able to re-produce the bug in Minefield 3.7a5. The problem seems to be the <font> tag:  the following code reproduces the bug:

<!DOCTYPE html>
<html>
<style>
.test {color: green;}
</style>
<body>
<font class="test">
<p style="color: red;">Should always be red</p>
<script></script>
</font>
</body>
</html>


but changing the <font> tag to, say, <div> causes the text "Should always be red" to render in red as expected:

<!DOCTYPE html>
<html>
<style>
.test {color: green;}
</style>
<body>
<div class="test">
<p style="color: red;">Should always be red</p>
<script></div>
</font>
</body>
</html>
Could you check how the latest nightly build works with the HTML5 parser turned on (http://hsivonen.iki.fi/test-html5-parsing/) and preferably also whether it matches the specified algorithm: http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html :)
Component: General → HTML: Parser
Product: Firefox → Core
QA Contact: general → parser
(In reply to comment #2)
> Could you check how the latest nightly build works with the HTML5 parser turned
> on (http://hsivonen.iki.fi/test-html5-parsing/)

New Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a5pre) Gecko/20100426 Minefield/3.7a5pre

With the HTML5 parser enabled, the text "Should always be red" is rendered in red with the test case:
<!DOCTYPE html>
<html>
<style>
.test {color: green;}
</style>
<body>
<font class="test">
<p style="color: red;">Should always be red</p>
<script></script>
</font>
</body>
</html>


The text even renders in red with the original test case:
<HTML>
<BODY>
<FONT COLOR="green">
<p style="color:red">Should always be red</p>
<script></script>
</FONT>
</BODY>
</HTML>
Depends on: html5-parsing
Thanks for testing! As you probably deduced from the set dependency, this means that this will be fixed by switching to the HTML5 parser.
Marking FIXED per comment 4.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [fixed by the HTML5 parser]
You need to log in before you can comment on or make changes to this bug.