W3C home > Mailing lists > Public > public-html@w3.org > January 2011

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

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Wed, 19 Jan 2011 13:53:44 +0900
To: public-html@w3.org
Message-ID: <op.vpjg7ui0a3v5gv@hr-opera.oslo.opera.com>
I noticed that browsers are fairly incompatible here:

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

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:45:29 UTC