[whatwg] Resource loading in browsing context-less Documents

Adam Klein adamk at chromium.org
Thu Oct 4 14:53:33 PDT 2012

With DOMImplementation.createDocument and createHTMLDocument, it's
possible to create Document objects that have no associated browsing
context. The behavior of elements created by that document is, in some
cases, well-specified. For example, <script> tags do not execute if
there is no browsing context

But some behavior is left unspecified, and is implemented differently
across browsers. For example, the following snippet:

    var doc = document.implementation.createHTMLDocument('myTitle');
    var img = doc.createElement('img');
    img.src = 'http://foo.com/myImage.png';

causes the img's src to be fetched by Opera, IE (only tested in 9,
since previous versions do not implement createHTMLDocument()), while
neither Gecko nor WebKit load the image. I haven't tested all elements
that load external resources, but I suspect that the behavior is
similar for, e.g., <audio> and <video>, where supported (<script src>
is something of an oddball: only IE tries to load that file when in a
context-less document).

I'd propose that the Gecko and WebKit behavior is the most sensible.
For one, it seems more consistent to make everything in the
context-less Document inactive in the same way <script> is. And at
least some developers already depend on this behavior (see, e.g., this
StackOverflow discussion:

Seems like this should be specced in HTML (not sure whether it would
go in each resource fetching algorithm or somewhere more general).

- Adam

More information about the whatwg mailing list