[Webkit-unassigned] [Bug 31801] New: If there's <!-- inside a <script> block, the document will be parsed in two different ways

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Nov 23 04:05:12 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=31801

           Summary: If there's <!-- inside a <script> block, the document
                    will be parsed in two different ways
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: New Bugs
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: jtarrio+bugz at gmail.com


Created an attachment (id=43701)
 --> (https://bugs.webkit.org/attachment.cgi?id=43701)
Files that illustrate the problem

Instructions:
1. Unpack the attached testcase.tgz in a web server.
2. Load index.html
3. Open the iframe in a new tab.
4. Reload the new tab.

Expected:
- After (2), an iframe appears with the text "Hi!" inside.
- After (3), the tab has the same contents as the iframe.
- After (4), the text "Hi!" remains in the tab.

Actual:
- After (2), an empty iframe appears.
- After (3), the tab is not empty, but contains the text "Hi!".
- After (4), the text "Hi!" disappears.

Description:

I have found a situation where Webkit seems to parse a document differently in
different circumstances when it finds the beginning of a HTML comment inside a
<script> tag.

If you load a HTML file like this in your browser:

<html>
<body>
<script>/* <!-- */</script>
<p>Hi!</p>
</body>
</html>

You'll be able to see "Hi!" in the page. If you inspect the document, you'll
see a <script> block that contains /* <!-- */ followed by the <p> block.

However, if, before the script block, you add an external Javascript file with
<script src="">, the page will be blank, and inspecting the document you'll see
that the <script> block is now empty and there's no <p> block after it. (It
doesn't matter if the <script> tags are inside the head or the body of the
document.)

If you include this file in a different HTML file as an iframe, the iframe will
appear empty. However, if you right-click and select "open frame in new tab",
you will see "Hi!" in the tab that opens. If you inspect the document, you'll
see the <script src=""> block, the <script> block with /* <!-- */ inside and
the <p>Hi!</p> block.

However, if you now reload the tab, the "Hi!" will disappear. If you inspect
the document now, you'll only see the <script src=""> block and an empty
<script> block and nothing else, like in the previous case.

If you remove the <script src=""> and try the previous steps, you will see
"Hi!" at every step.

I have reproduced this with Safari 4.04 (531.21.10) and Chrome 4.0.223.16
(532.3) in Windows, and Chrome 4.0.245.1 (532.5) in Linux. I have also been
able to reproduce it with Konqueror. Firefox and Opera always show "Hi!".

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list