The default bug view has changed. See this FAQ.

DOMImplementation createDocument does not create an HTML document

RESOLVED FIXED

Status

()

Core
DOM
RESOLVED FIXED
9 years ago
2 years ago

People

(Reporter: roc, Assigned: smaug)

Tracking

({fixed1.9.1})

Trunk
fixed1.9.1
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [verified1.9.1b4: Bv1], URL)

Attachments

(2 attachments)

The Acid3 test does something like this:

var doctype = document.implementation.createDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", doctype);
doc.documentElement.appendChild(doc.createElementNS("http://www.w3.org/1999/xhtml", "head"));
doc.documentElement.appendChild(doc.createElementNS("http://www.w3.org/1999/xhtml", "body"));
doc.body.appendChild(doc.createElementNS("http://www.w3.org/1999/xhtml", "form"));

but doc.body is not defined because we create an nsXMLDocument.

I guess all that's needed is to change the createDocument logic to behave more like the XML sink?
Setting up an nsHTMLDocument actually looks pretty hard :-(. Someone with more mojo than me should look at it.

The other option is to just move functionality up to nsDocument. HTML5 says that every document object should implement all document interfaces so this is really what we should be doing anyway. A lot of it would move up relatively easily but of course the stuff that's complicated to set up in nsHTMLDocument would be hard to move.
I'm haven't yet looked into the feasibility of what HTML5 says.

That said, it shouldn't be *that* hard to create a HTML document. XSLT does a decently good job, look at

http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xslt/txMozillaXMLOutput.cpp#844
http://mxr.mozilla.org/mozilla-central/source/content/xml/document/src/nsXMLContentSink.cpp#387
(Assignee)

Updated

9 years ago
Assignee: nobody → Olli.Pettay
(Assignee)

Updated

9 years ago
(Assignee)

Comment 3

9 years ago
Created attachment 339252 [details] [diff] [review]
an interpretation of dom 3 .createDocument

This is my interpretation of the DOM 3 Core; create document based on doc 
type's publicId. The systemId may in principle point to any place, it doesn't 
even have to be an absolute URI.

WebKit does something wrong here, it creates the document based on
the namespaceURI parameter of .createDocument().
That is not what the spec says:
  'Note that based on the DocumentType given to create the document, the 
   implementation may instantiate specialized Document objects that support 
   additional features than the "Core"'

A fun part is also that ACID3 relies on an "implementation _may_" feature :/
Anyway, the patch fixes ACID3 test 98.

Jonas, Boris, anyone, comments?
Attachment #339252 - Flags: superreview?(jonas)
Attachment #339252 - Flags: review?(bzbarsky)
> A fun part is also that ACID3 relies on an "implementation _may_" feature :/

That would make it a bug in the test.  Have you reported it to Ian?

Patch looks OK on quick skim; I'll try to do a detailed review on Monday, probably.  One question:  do we currently create docshell-less HTML documents anywhere?  If not, what sort of auditing have you done to make sure that we don't have code that assumes an HTML document is always in a docshell, has a window, etc?
(Assignee)

Comment 5

9 years ago
(In reply to comment #4)
> One question:  do we currently create docshell-less HTML documents
> anywhere?  If not, what sort of auditing have you done to make sure that we
> don't have code that assumes an HTML document is always in a docshell, has a
> window, etc?
We do support .cloneNode nowadays. And I re-checked some code and as far as I see
having docshell-less htmldocument means that contentEditable/midas isn't available
and document.open/write/close don't work (like they don't work with xhtml anyway).
> We do support .cloneNode nowadays.

You mean on documents?

Basically, did you look at the various window, script global object, container, scope object, etc users in nsHTMLDocument and in places that explicitly work on HTML documents?
(Assignee)

Comment 7

9 years ago
I searched HTMLDocument in the tree and so far nothing bad found.
.open/.write/.close and different editing things just won't work - could
file a followups to fix those if really needed.
Having those not work on in-memory HTML seems just fine to me.
Attachment #339252 - Flags: superreview?(jonas)
Attachment #339252 - Flags: superreview+
Attachment #339252 - Flags: review?(bzbarsky)
Attachment #339252 - Flags: review+
(Assignee)

Updated

9 years ago
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
XSLT has also created out-of-docshell HTML documents for a long time (through xsltprocessor.transformToDocument). Not sure that we auditid very many things though.

There is also the question of what .cookies should do when gotten/set.
Created attachment 371074 [details] [diff] [review]
(Bv1) Remove blank lines in log
[Checkin: Comment 11 & 12]

Aren't they useless ?
Attachment #371074 - Flags: review?(bzbarsky)
(Assignee)

Updated

8 years ago
Attachment #371074 - Flags: review?(bzbarsky) → review+
Comment on attachment 371074 [details] [diff] [review]
(Bv1) Remove blank lines in log
[Checkin: Comment 11 & 12]


http://hg.mozilla.org/mozilla-central/rev/ef8da5d2aeb7
Attachment #371074 - Attachment description: (Bv1) Remove blank lines in log → (Bv1) Remove blank lines in log [Checkin: Comment 11]
Flags: in-testsuite+
Comment on attachment 371074 [details] [diff] [review]
(Bv1) Remove blank lines in log
[Checkin: Comment 11 & 12]


http://hg.mozilla.org/releases/mozilla-1.9.1/rev/c8b3efbf0f48
Attachment #371074 - Attachment description: (Bv1) Remove blank lines in log [Checkin: Comment 11] → (Bv1) Remove blank lines in log [Checkin: Comment 11 & 12]
Keywords: fixed1.9.1
Whiteboard: [fixed1.9.1b4: Bv1]
(In reply to comment #12)
> http://hg.mozilla.org/releases/mozilla-1.9.1/rev/c8b3efbf0f48

This part is verified1.9.1, per
{
http://tinderbox.mozilla.org/showlog.cgi?log=SeaMonkey/1238938947.1238945640.4337.gz&fulltext=1
Linux comm-central unit test on 2009/04/05 06:42:27
}
Whiteboard: [fixed1.9.1b4: Bv1] → [verified1.9.1b4: Bv1]
You need to log in before you can comment on or make changes to this bug.