[whatwg] Resource loading in browsing context-less Documents

Ian Hickson ian at hixie.ch
Thu Oct 4 23:00:11 PDT 2012


On Thu, 4 Oct 2012, Adam Klein wrote:
>
> 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 
> (http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-n-noscript).
> 
> 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';
>
> [...]
> 
> Seems like this should be specced in HTML (not sure whether it would go 
> in each resource fetching algorithm or somewhere more general).

This is specced. The UA is allowed to send the HTTP request (that's a 
truism, of course, nothing stops the UA from sending any arbitrary HTTP 
request at any time), but there's no in-DOM visible effect of that 
request, because event loops don't process tasks for documents without 
active browsing contexts, so the tasks that the "fetch" algorithm 
generates never get executed. (A clever UA can notice this and delay 
(forever) the HTTP requests, since the "fetch" algorithm allows you to 
wait an arbitrary amount of time before doing the request.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list