Re: [whatwg] Avoiding synchronous iframe load

On 10/17/13 4:04 AM, Ryosuke Niwa wrote:
> I’ll add that Firefox and Internet Explorer both load about:blank asynchronously.

Yes, but in the case of Firefox we consider that a bug.

In particular, we believe that the behavior web authors expect is for 
the document to be created synchronously.  When its onload fires is an 
open question; we believe for web compat that should be async.

Looking at your original testcase with javascript:

<script> var a = false; </script>
<iframe src="javascript:a=true" onload="a = true"></iframe>
<script> alert(a); /* or even setTimeout(function(){alert(a);},0); */ 
setTimeout(function(){alert(a);},10) </script>

What this does in Firefox (where javascript: loads async) depends on 
what the exact order of event delivery is.  The parsing of the <script> 
after the <iframe> races the async javascript: load, so this can alert 
either true or false for the first alert it makes.  For that matter, it 
can do the same for the second alert it makes.

I strongly believe that async loading of javascript: is desirable (which 
is why Gecko switched to it); if the spec requires something else I'm 
all in favor of changing the spec.

-Boris

Received on Friday, 18 October 2013 02:25:01 UTC