Closed
Bug 78622
Opened 25 years ago
Closed 25 years ago
DOMParser and XMLHttpRequest failures when parser blocked (xml-stylesheet PI etc. in data)
Categories
(Core :: XML, defect, P2)
Core
XML
Tracking
()
VERIFIED
FIXED
mozilla0.9.5
People
(Reporter: pwilson, Assigned: hjtoi-bugzilla)
Details
(Keywords: regression, Whiteboard: [fixed on trunk and 0.9.4 branch], PDT+)
Attachments
(1 file, 3 obsolete files)
|
39.79 KB,
patch
|
harishd
:
review+
vidur
:
superreview+
|
Details | Diff | Splinter Review |
After parsing an XUL document using
domParser = this.getComponent("@mozilla.org/xmlextras/domparser;1",
"nsIDOMParser");
dom = domParser.parseFromString(xml, "text/xml")
The method dom.documentElement returns null. This only happens when stylesheet
processing instruction are present (or possibly any PI). Removing the PI's from
the document yields a correct element value.
This is unfortunate as an easy way to check for a failed parse is
dom.documentElement.localName == "PARSERERROR"
I believe the problem lies in XULContentSink.
not bookmarks...
Assignee: ben → waterson
Component: Bookmarks → DOM Mozilla Extensions
QA Contact: claudius → lchiang
Comment 2•25 years ago
|
||
The XUL document object doesn't really know what children are, this would be
solved if we'd merge it with nsDocument...
| Reporter | ||
Comment 3•25 years ago
|
||
I believe I have an explanation of the problem which might also explain bugs
75844 and 76039.
When parsing an XUL document (and possibly HTML - but not tried). I believe an
asynchronous parse of the referenced stylesheet/overlay/javascript documents is
invoked. Is it possible that parseFromStream/String is returning while this
parsing is continuing? In effect I would be examining a partially completed
document. hence the missing element id. in getElementById (Bug 76039) and the
missing documentElement in this bug. This would also explain why removing the
styleshhet PI enables the parse to complete earlier and successfully.
Bug 75844 might also be explained.
| Reporter | ||
Comment 4•25 years ago
|
||
Seee bug 83477 where this bug is incidentaly present. The test files and
comments explain further.
Updated•25 years ago
|
Status: UNCONFIRMED → ASSIGNED
Component: DOM Mozilla Extensions → XP Toolkit/Widgets: XUL
Ever confirmed: true
Priority: -- → P4
Target Milestone: --- → mozilla1.0
| Reporter | ||
Comment 6•25 years ago
|
||
I have retested this. Initially I thought it was still broken.
For an XUL document the following line:
debug("srcDOM:" + srcDOM + " docElem:" + srcDOM.documentElement);
gives: >>srcDOM:[object Document] docElem:null<<
Then I ran it again several times (from a new invocation of Mozilla each time)
and got a different result about one time in five:
gives: >>srcDOM:[object Document] docElem:[object XULElement]<<
Ughh! a timing related bug. Is some asynchronous thread building the document?
| Assignee | ||
Updated•25 years ago
|
Assignee: waterson → heikki
Status: ASSIGNED → NEW
Target Milestone: mozilla1.0 → mozilla0.9.5
| Assignee | ||
Comment 7•25 years ago
|
||
Looking at the code, it does seem the document is built asynchronously. I'll
take this to investigate (might be XML Extras bug).
Peter, if you could provide a self contained minimal testcase it would be great.
| Assignee | ||
Comment 8•25 years ago
|
||
Oh boy, this is a mess... I haven't yet tested this for DOMParser, but I am
pretty sure I dissected this from the code with harishd yesterday, and I now
checked that this really happens with XMLHttpRequest. Testcase for
XMLHttpRequest is:
file:///C:/builds/mozilla/extensions/xmlextras/tests/getdisplay.html You see the
bug if "responseXML serialized" has no result. Just by commenting out the
xml-stylesheet PI in the XML file that it tries to load the sample works fine.
If you have xml-stylesheet PI or any other construct that blocks the parser, we
fire the load event too soon (XMLHttpRequest) or return too soon (DOMParser).
With DOMParser, it looks like our call to OnDataAvailable() can return with
message that the parser is blocked (while it is retrieving stylesheet or some
such), but DOMParser thinks the parsing is complete. DOMParser should probably
be fixed to be a load listener for the document and only return when the load
event has been received.
With my quite recent change to XMLHttpRequest, if the parser is blocked we can
receive OnStopRequest() before the document actually loaded, meaning we fire the
load event too soon (because we do it from OnStopRequest()). XMLHttpRequest is
more complicated to fix. For non-wellformed documents we must fire the load
event from OnStopRequest() - for other cases the load event must be fired when
the document informs it has loaded.
This is not XUL-specific, so I have changed the component and summary, as well
as some other fields.
Severity: normal → major
Status: NEW → ASSIGNED
Component: XP Toolkit/Widgets: XUL → XML
Keywords: nsbranch+
OS: Windows 2000 → All
Priority: P4 → P2
Hardware: PC → All
Summary: xuldocument.documentElement returns null if PI's present → DOMParser and XMLHttpRequest failures when parser blocked (xml-stylesheet PI etc. in data)
Whiteboard: worksforme?
| Assignee | ||
Comment 9•25 years ago
|
||
For XMLHttpRequest this is a regression, adding keyword. I am fixing both
objects under this one bug since the cause is the same and the fix very similar
for each case.
Keywords: regression
| Assignee | ||
Comment 10•25 years ago
|
||
| Assignee | ||
Comment 11•25 years ago
|
||
| Assignee | ||
Updated•25 years ago
|
Attachment #49049 -
Attachment is obsolete: true
| Assignee | ||
Comment 12•25 years ago
|
||
There, I basically copied the way we do synchronous loading from XMLHttpRequest
into DOMParser. In DOMParser we now wait for the document load event before
returning from parseFromString/Stream.
Harish, can you r=?
Whiteboard: [fixinhand]
Comment 13•25 years ago
|
||
+ if (modalEventQueue) {
+ eventQService->PopThreadEventQueue(modalEventQueue);
+ }
Not sure why that check in necessary.
Other than that r=harishd.
Attachment #49139 -
Flags: review+
| Assignee | ||
Comment 14•25 years ago
|
||
Currently nsEventQueueServiceImpl::PopThreadEventQueue(nsIEventQueue *aQueue)
will crash if !aQueue. Dunno if we gan get that situation, but... All of that
stuff is basically copied from XMLHttpRequest where it has worked for a year(?)
without crash problems as is. Eventually the whole event queue thing must be
replaced with something better, but since there does not seem to be a simple way
to make a simple event loop a la Windows this is what we have now...
| Assignee | ||
Comment 15•25 years ago
|
||
| Assignee | ||
Comment 16•25 years ago
|
||
The latest patch is otherwise identical to the previous, except that at the end
of parseFromStream() in DOMParser we PopThreadEventQueue() even if we have no
mChromeWindow (which happens if the parser was not blocked). Good catch from vidur!
Comment 17•25 years ago
|
||
Comment on attachment 49272 [details] [diff] [review]
Make sure to PopThreadEventQueue() even if no mChromeWindow
The latest patch will call ExitModalEventLoop even if we haven't entered a modal event loop. Not ideal, but is at least safe?
| Assignee | ||
Comment 18•25 years ago
|
||
| Assignee | ||
Comment 19•25 years ago
|
||
Ok, in the 4th patch we have:
+// See if we have a modal event loop
+static inline PRBool IsModal(nsIWebBrowserChrome *aWindow)
+{
+ if (aWindow) {
+ PRBool isModal;
+ if (NS_SUCCEEDED(aWindow->IsWindowModal(&isModal))) {
+ return isModal;
+ }
+ }
+
+ return PR_FALSE;
+}
+
and we call that to check if we should ExitModal (like this):
+nsDOMParser::Load(nsIDOMEvent* aEvent)
+{
+ if (IsModal(mChromeWindow)) {
+ mChromeWindow->ExitModalEventLoop(NS_OK);
+ }
+
+ mChromeWindow = nsnull;
+
+ return NS_OK;
+}
The IDL comment for exitModalEventLoop() implies (in my opinion) but does not
say for sure that it would be safe to call it even if there is no modal event
loop. Some of the implementations are safe, but I am not so sure about all of
them, so the new patch should take care of that.
Comment 20•25 years ago
|
||
Comment on attachment 49281 [details] [diff] [review]
Call ExitModal only if we are modal
sr=vidur
Attachment #49281 -
Flags: superreview+
| Assignee | ||
Comment 21•25 years ago
|
||
Checked in on the trunk, leaving open to track situation with 0.9.4 branch.
Whiteboard: [fixinhand] → [fixed on trunk]
Comment 22•25 years ago
|
||
Pls give this to the DIG guys to test, and make sure it doesn't affect them. - PDT
Attachment #49281 -
Flags: review+
| Assignee | ||
Updated•25 years ago
|
Attachment #49139 -
Attachment is obsolete: true
| Assignee | ||
Updated•25 years ago
|
Attachment #49272 -
Attachment is obsolete: true
| Assignee | ||
Comment 23•25 years ago
|
||
I was in contact with the DIG people, got some instructions on how to test, and
I tested this on an online version of their app - no difference in behaviour.
The DIG group also felt that based on the description of this bug this is
unlikely to affect them.
| Assignee | ||
Comment 25•25 years ago
|
||
Checked in on the 0.9.4 branch as well, marking fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Whiteboard: [fixed on trunk], PDT+ → [fixed on trunk and 0.9.4 branch], PDT+
Comment 26•25 years ago
|
||
pwilson@gorge.net (Peter Wilson)- would you mind verifying that this if fine for
you on the branch 0.9.4 and trunk builds?
| Reporter | ||
Comment 27•25 years ago
|
||
I have sucessfully loaded my forms
a. The same form repeatedly.
b. a variety of differnet forms with different xml includes.
No problems detected.
This appears to be fixed for the nightly build of 9/22/2001 on win32.
I am unable to test 0.9.4 as the most recent release, 9/13/2001, pre-dates the
check-in for this bug.
Comment 28•25 years ago
|
||
as per the reporters comments, looks like this is fixed on trunk. peter can u
please verify on branch. (the fix landed on branch too)
Comment 29•25 years ago
|
||
the fix landed on both branch and trunk as per developer's comments.
the reporter verified this bug on trunk. marking as verified
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•