W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2012

[whatwg] Resource loading in browsing context-less Documents

From: Adam Klein <adamk@chromium.org>
Date: Thu, 4 Oct 2012 14:53:33 -0700
Message-ID: <CAEvLGcLPgrxc9kCKtufX8-L8iDUu2ziVsGJMUmxti04o8y40sw@mail.gmail.com>
To: whatwg@whatwg.org
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
Received on Thursday, 4 October 2012 21:54:04 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:17 UTC