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

I noticed that browsers are fairly incompatible here:
http://testsuites.opera.com/script-execution/080.html

IE8 and Firefox 4 agree (and I've just changed the test to flag their  
behaviour as a pass), Chrome does another thing and Opera a third. Here's  
the issue:

We create an IFRAME through the DOM, set its src to a javascript: URL that  
creates a string of HTML which also contains a script element, and append  
the IFRAME to the document. There is one more inline script below the one  
that appends the IFRAME. So we're dealing with

* the remainder of inline script #1 (after appendChild() call)
* inline script #2
* javascript: URL
* the script inside the IFRAME

and the question is in what order these should run.

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.

Does it even make sense to try to standardise the behaviour here? If yes,  
what makes more sense and how should it be spec'ed?

-- 
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/

Received on Wednesday, 19 January 2011 04:53:48 UTC