Open Bug 1273544 Opened 8 years ago Updated 2 years ago

Something smells off with IsUnstyledDocument, IsLoadedAsData and IsLoadedAsInteractiveData

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

People

(Reporter: jwatt, Unassigned)

References

Details

IsLoadedAsData and IsLoadedAsInteractiveData are undocumented, which makes their meaning unclear. When I added IsUnstyledDocument in bug 1008455 I made it return true if either of these methods return true since that seemed correct for "data" documents. I've since noticed that IsLoadedAsInteractiveData seems to be quite misleadingly named though, so I'm not sure IsUnstyledDocument is doing the right thing.

Digging into IsLoadedAsInteractiveData it seems like this is set for XBL bindings documents (it came into existance way back in bug 172372). For documents for which it returns true:

 * nsDocument::GetAnimationController() returns null

 * clone->SetFlags(NODE_FORCE_XBL_BINDINGS) will not be called in
   nsNodeUtils::CloneAndAdopt when cloning a XUL element to be a
   child of some other element

 * XMLDocument::StartDocumentLoad passes "loadAsData" to
   nsParser::SetCommand which prevents the parser loading <link>
   style sheets (nsXMLContentSink::ProcessStyleLink returns early)

 * XMLDocument::EndLoad sets mSynchronousDOMContentLoaded to true

Note that a document's nsScriptLoader and css::Loader are _not_ disabled, since XMLDocument::StartDocumentLoad passes "loadAsInteractiveData" to nsDocument::StartDocumentLoad _before_ changing |aCommand| to "loadAsData" for passing off to the parser. 

So I'm not sure to what extent documents that return true from IsLoadedAsInteractiveData are actually "data" documents. They seem much more like normal documents with a few XBL binding specific quirks. Even the bit where <link> style sheets are prevented seems suspect, since the XBL bindings document is still allowed and - according to bug 172372 - must be able to load style and script in other ways.
The idea is that IsLoadedAsInteractiveData should prevent anonymous content from doing random loads in the context of that document.  That is, if your binding template has an <img> in it, we should NOT load that <img> in the XBL document.  It should get loaded once the binding actually gets instantiated into the bound document.  This also applies to <script src>, <link href> etc.

I'm happy to rename IsLoadedAsInteractiveData as needed....
What are we going to do here, if anything?
Flags: needinfo?(jwatt)
(In reply to Andrew Overholt [:overholt] from comment #2)
> What are we going to do here, if anything?

I'd really like to see some documentation added to these two methods. Their meaning, finer details and how they differ are far from obvious to someone like me who sometimes has to deal with them, but not often enough to recall the details each time that happens.
Flags: needinfo?(jwatt)
Priority: -- → P3
Component: DOM → DOM: Core & HTML
See Also: → 1616964
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.