Re: script execution corner case: timing of running a script created from a javascript: URL inside an IFRAME

On 1/18/11 11:53 PM, Hallvord R. M. Steen wrote:
> Chrome takes a very predictable approach: the javascript: URL *and* the
> script inside the IFRAME run immediately, before the appending script
> continues. Current releases of Opera run the javascript: URL immediately
> but postphone the frame script until after the current thread (we'll
> probably change that to postphone the javascript: URL too). IE and
> Firefox first finish both inline scripts, then deal with the IFRAME -
> this may be timing-sensitive, I don't know how they would behave if,
> say, there was an external script after the inserted IFRAME, or many
> inline scripts.

In the case of Gecko, we just treat javascript: like every other 
protocol handler: it runs asynchronously.  That means that inserting the 
iframe in this case posts an event to the event loop to run the script, 
and does nothing else.

Now how this orders with the inline scripts will depend on what other 
events were already in the event loop when this one got posted and 
whatnot.  Just like the situation for an iframe pointing to an HTTP URI 
that had an inline script.

> Does it even make sense to try to standardise the behaviour here?

Imo, yes.  At least the sync-vs-async thing for javascript: could use 
standardizing.

-Boris

Received on Wednesday, 19 January 2011 06:10:37 UTC