Closed
Bug 594767
Opened 15 years ago
Closed 15 years ago
importNode fails when using a document created with createHTMLDocument
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
| Tracking | Status | |
|---|---|---|
| blocking2.0 | --- | final+ |
People
(Reporter: sheppy, Assigned: smaug)
References
Details
(Keywords: dev-doc-complete)
Attachments
(4 files)
|
1008 bytes,
text/html
|
Details | |
|
11.75 KB,
patch
|
Details | Diff | Splinter Review | |
|
15.44 KB,
patch
|
Details | Diff | Splinter Review | |
|
6.69 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
Attempting to import nodes from a document created using createHTMLDocument is failing with NS_ERROR_DOM_PROP_ACCESS_DENIED, code 1010.
Attached is a test case.
| Assignee | ||
Comment 1•15 years ago
|
||
Seems like there are also other problems with CreateHTMLDocument.
Well, at least one. It doesn't seem to mark the created document as data document, if I read the code correctly.
| Assignee | ||
Comment 2•15 years ago
|
||
Where is the principal set the the created document?
| Assignee | ||
Comment 3•15 years ago
|
||
And seems like .innerHTML doesn't work with created document either.
| Assignee | ||
Updated•15 years ago
|
blocking2.0: --- → ?
| Assignee | ||
Comment 4•15 years ago
|
||
So, the create html document doesn't have right principal and documentURI,
and it is not marked as datadocument.
Assignee: nobody → Olli.Pettay
Doh! Sorry guys, should have caught this during review.
blocking2.0: ? → final+
| Assignee | ||
Comment 6•15 years ago
|
||
The tricky thing is that documentURI should return null, but content sink
assumes that it is non null.
I could add a hack that nsDocument::GetDocumentURI would return null also
when some specific flag is set to document.
bool mNullDocument;
mDocumentURI could point to about:blank, I think.
Ugly and hackish, but what else could be done easily?
| Assignee | ||
Comment 7•15 years ago
|
||
Or perhaps I just fix ContentSink.
It doesn't seem to use its mDocumentURI in too many places.
What do we do for XML documents created using DOMImplementation? Or HTML documents created using XSLTProcessor?
| Assignee | ||
Comment 9•15 years ago
|
||
Attachment #475060 -
Flags: review?(jonas)
| Assignee | ||
Comment 10•15 years ago
|
||
Comment on attachment 475060 [details] [diff] [review]
use the normal way to create data documents
Um, this seems to regress something in the testcase test_bug396843.html
Attachment #475060 -
Flags: review?(jonas)
| Assignee | ||
Comment 11•15 years ago
|
||
Actually, the patch reveals another (small) bug in nsDOMClassInfo.cpp.
Since that is trivial to fix, I'll
| Assignee | ||
Comment 12•15 years ago
|
||
...fix it in this bug.
| Assignee | ||
Comment 13•15 years ago
|
||
Fix the testcase.
This makes implementation.create*Document().documentURI to work per DOM 3 Core.
Attachment #475184 -
Flags: review?(jonas)
| Assignee | ||
Comment 14•15 years ago
|
||
And based on testing webkit and opera return null too for documentURI.
| Reporter | ||
Updated•15 years ago
|
Keywords: dev-doc-needed
Are you sure we're not doing any security checks based on the document URI which will behave poorly, i.e. crash or allow things it shouldn't?
Haven't we previously made DOM created documents have the URI of creating document?
| Assignee | ||
Comment 16•15 years ago
|
||
(In reply to comment #15)
> Are you sure we're not doing any security checks based on the document URI
> which will behave poorly, i.e. crash or allow things it shouldn't?
nsIDocument::GetDocumentURI() clearly says that document uri can be nsnull.
And I'd be surprised if any did security checks based on document uri.
But I'll check.
> Haven't we previously made DOM created documents have the URI of creating
> document?
DOMParser does that. implementation.createDocument creates about:blank documents.
| Assignee | ||
Comment 17•15 years ago
|
||
Attachment #476199 -
Flags: review?(jonas)
| Assignee | ||
Updated•15 years ago
|
Attachment #475184 -
Flags: review?(jonas)
Comment on attachment 476199 [details] [diff] [review]
safer
>diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp
>--- a/content/xml/document/src/nsXMLDocument.cpp
>+++ b/content/xml/document/src/nsXMLDocument.cpp
>@@ -116,19 +116,23 @@ NS_NewDOMDocument(nsIDOMDocument** aInst
> nsresult rv;
>
> *aInstancePtrResult = nsnull;
>
> nsCOMPtr<nsIDocument> d;
> PRBool isHTML = PR_FALSE;
> PRBool isXHTML = PR_FALSE;
> if (aDoctype) {
>- nsAutoString publicId;
>+ nsAutoString publicId, name;
> aDoctype->GetPublicId(publicId);
>- if (publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") ||
>+ if (publicId.IsEmpty()) {
>+ aDoctype->GetName(name);
>+ }
>+ if (name.EqualsLiteral("html") ||
>+ publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") ||
> publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Frameset//EN") ||
> publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Transitional//EN") ||
> publicId.EqualsLiteral("-//W3C//DTD HTML 4.0//EN") ||
> publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Frameset//EN") ||
> publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Transitional//EN")) {
> rv = NS_NewHTMLDocument(getter_AddRefs(d));
> isHTML = PR_TRUE;
> } else if (publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Strict//EN") ||
I don't understand these changes. Are they really related to this bug? Can you point to spec?
Looks good otherwise though.
| Assignee | ||
Comment 19•15 years ago
|
||
HTML5 requires a specific kind of doctype for createHTMLDocument.
That is a part I don't change in ::CreateHTMLDocument, but I just make
NS_NewDOMDocument to recognize that doctype.
| Assignee | ||
Comment 20•15 years ago
|
||
Attachment #476199 -
Flags: review?(jonas) → review+
| Assignee | ||
Comment 21•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 22•15 years ago
|
||
This is now fully documented:
https://developer.mozilla.org/En/DOM/DOMImplementation.createHTMLDocument
With a working sample and linked to from the appropriate places.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•