Closed Bug 280713 Opened 20 years ago Closed 19 years ago

OnStopRequests can confuse the parser if there is more than one parsercontext pressent

Categories

(Core :: DOM: HTML Parser, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: mrbkap, Assigned: mrbkap)

References

()

Details

Attachments

(1 file, 3 obsolete files)

I'm not entirely certain if this is the correct fix (or exactly how this ever
worked before), but on trunk builds on the given URL, an <iframe> under the
comic strip doesn't appear. The final two lines of the page are:
<div><iframe></div></body></html>

We reach EOF on the <iframe> and return kEOF. However, when we arrive back in
CTextToken::ConsumeCharacterData(), aScanner.IsIncremental() is PR_TRUE! Thus,
we never add the <iframe> and it disappears. My fix is, in
nsParser::ConsumeInterruptedParsing(), to set the current scanner's mIncremental
member based on whether we had reached the final chunk. I'll attach a patch shortly.
Attached patch patch v1 (obsolete) — Splinter Review
I'm slightly confused as to why this is necessary (shouldn't we have gotten an
OnStopRequest before we throw these events around?) but it fixes the issue, and
basically mimics what we do in the ::Parse(const nsAString&) function.

Can anybody shed light or give this r and sr? I think this bug is pretty bad
(we lose page content).
Attachment #173127 - Flags: review?(jst)
Comment on attachment 173127 [details] [diff] [review]
patch v1

I think I like this patch as much as any patch. When the OnStopRequest comes,
our current context is still a script's parser context.

Johnny, the alternative to this patch is to make sure we always set the main
parser context's scanner's mIncremental member in nsParser::OnStopRequest. I'll
post another patch to that effect.
Attached patch alternative approach (obsolete) — Splinter Review
This is the alternate approach. Take your pick :-).
Attachment #173335 - Flags: review?(jst)
Comment on attachment 173127 [details] [diff] [review]
patch v1

I *think* I like this approach better than the alternative. But I must admit
that it's been way too long since I've tried to understand what these parser
contexts really are etc. But r=jst regardless. bz should probably have a look
at this one too...
Attachment #173127 - Flags: review?(jst) → review+
Attachment #173335 - Flags: review?(jst)
Attachment #173127 - Flags: superreview?(bzbarsky)
Comment on attachment 173127 [details] [diff] [review]
patch v1

sr=bzbarsky, but it sounds like some cleanup of incremental vs final chunk is
in order....
Attachment #173127 - Flags: superreview?(bzbarsky) → superreview+
Fix checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
OS: Windows XP → All
Hardware: PC → All
Resolution: --- → FIXED
Reopening. I still see this :-/.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch Fixed alternative approach (obsolete) — Splinter Review
This patch looks more dangerous, but it shouldn't be

What is happening is that we get a request to load a nested <script> from a
document.write(). This blocks the parser so that we can load the nested script.
However, in the meantime, we've received our stop request from the original
stream (in this case from http://www.skirtingdanger.com). So when we are
blocked and return to the event queue, we get the stop request from the stream.
However, the parser context from the original script is still on our context
list, so we were setting that context's members, and not the context that
actually had received the stop request. This patch makes sure that we always
set the correct context's members. I if()'d out the ResumeParse() call in the
case that the current context wasn't the one that received the OnStopRequest()
because it was literally just returning (I've added an assertion to this
effect). This also has the side effect of fixing bug 97886, since script parser
contexts will not ever think that they're at EOF (which is correct, if there is
an unfinished tag in a document.write(), it will be inserted into the regular
page which may contain the closing >).
Attachment #173127 - Attachment is obsolete: true
Attachment #173335 - Attachment is obsolete: true
Attachment #173980 - Flags: review?(jst)
Blocks: 97886
Status: REOPENED → ASSIGNED
Attachment #173980 - Attachment is obsolete: true
Attachment #173997 - Flags: review?(jst)
Attachment #173980 - Flags: review?(jst)
Comment on attachment 173997 [details] [diff] [review]
updated to review comments

Yeah, this looks good. r=jst
Attachment #173997 - Flags: review?(jst) → review+
Attachment #173997 - Flags: superreview?(bzbarsky)
Comment on attachment 173997 [details] [diff] [review]
updated to review comments

sr=bzbarsky.  Land this either _really_ early in 1.8b2 or in 1.9a....
Attachment #173997 - Flags: superreview?(bzbarsky) → superreview+
Really fixed now (checked in).
Status: ASSIGNED → RESOLVED
Closed: 20 years ago19 years ago
Resolution: --- → FIXED
Summary: ContinueInterruptedParsing doesn't set the current context's scanner's mIncremental member correctly → OnStopRequests can confuse the parser if there is more than one parsercontext pressent
Target Milestone: --- → mozilla1.8beta2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: