Discussion:
FireFox 4 crashes when trying to find the parent document for an internal document using DOM API GetParentDocument()
Madhu Tadiparthi
2011-05-03 11:36:36 UTC
Permalink
I have a web application where I have frames/Iframes in that. What I am
trying is to get the top level document from the internal document which is
a child of Frame/Iframe. I am facing an issue in getting the parent document
node from an internal document node in FireFox 4 using GetParentDocument
API. The browser is crashing at the Line 7 in the sample code. Here is the
sample code that I tried. The same is working good till Firefox 3.6

nsIDocument* getParentDocument(nsIDOMHTMLDocumentPtr htmlDocument )
{
nsIDocumentPtr document = do_QueryInterface(htmlDocument) ;
nsIDocument* parentDoc ;
parentDoc = document->GetParentDocument(); //Line 7
return parentDoc;
}

How can I get the parent document for the internal documents. Any
inputs/comments are higly appreciated.

Thanks
Madhu Tadiparthi
smaug
2011-05-03 11:49:53 UTC
Permalink
Post by Madhu Tadiparthi
I have a web application where I have frames/Iframes in that. What I am
trying is to get the top level document from the internal document which is
a child of Frame/Iframe. I am facing an issue in getting the parent document
node from an internal document node in FireFox 4 using GetParentDocument
API. The browser is crashing at the Line 7 in the sample code. Here is the
sample code that I tried. The same is working good till Firefox 3.6
nsIDocument* getParentDocument(nsIDOMHTMLDocumentPtr htmlDocument )
{
nsIDocumentPtr document = do_QueryInterface(htmlDocument) ;
nsIDocument* parentDoc ;
parentDoc = document->GetParentDocument(); //Line 7
return parentDoc;
}
How can I get the parent document for the internal documents. Any
inputs/comments are higly appreciated.
Have you debugged why the code is crashing?
Is 'document' null when you call GetParentDocument()?
If so, I assume also htmlDocument is null, unless you use
the same binary for Fx3.6 and Fx4.0.
(nsIDocument interface has changed in Fx4.0, so you can't use the
exactly *binary* code to access the object in Fx3.6 and Fx4.0.
You need to at least recompile the code.)

-Olli
Post by Madhu Tadiparthi
Thanks
Madhu Tadiparthi
mads
2011-05-03 13:52:18 UTC
Permalink
HI Olli,
Thanks for the quick response. Here are my comments.
Post by smaug
Have you debugged why the code is crashing?
Is 'document' null when you call GetParentDocument()?
If so, I assume also htmlDocument is null, unless you use
the same binary for Fx3.6 and Fx4.0.
Madhu : I have taken care of NULL pointer checks. They are not NULL
pointers.
Post by smaug
(nsIDocument interface has changed in Fx4.0, so you can't use the
  exactly *binary* code to access the object in Fx3.6 and Fx4.0.
  You need to at least recompile the code.)
Madhu: I have extension to the browser, which has a dll compiled with
the Gecko SDK 2.0 latest. Our code will try to traverse over the DOM
tree for the web application in FF4.0 to get the DOM hierarchy and
other stuff. Could you elaborate more on this recompiling the code?

Appreciate any inputs/comments.

Thanks
Madhu Tadiparthi

Loading...