W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2013

Re: [whatwg] Avoiding synchronous iframe load

From: Elliott Sprehn <esprehn@chromium.org>
Date: Thu, 17 Oct 2013 15:14:32 -0700
Message-ID: <CAO9Q3iLsd2-_8Xxdbuuqp0-_TOAq_jmvQvR-cg5pWnfWpGsmtw@mail.gmail.com>
To: Ryosuke Niwa <rniwa@apple.com>
Cc: whatwg <whatwg@lists.whatwg.org>
Note that loads can never be fully async, you'd break tons of content.
Navigating to about:blank is synchronous.

frame = document.createElement('iframe');
frame.contentDocument; // synchronously available

Also javascript: URLs are not async in Firefox:

frame = document.createElement('iframe');
frame.src = 'javascript:alert(1);'

This alerts 1 and then 2.

Presumably all this behavior is required by spec. If it wasn't then we
should fix the spec since not having that behavior would break nearly ever
major web app.

On Tue, Oct 15, 2013 at 7:02 PM, Ryosuke Niwa <rniwa@apple.com> wrote:

> Hi,
> I'm trying to make page loads on iframe always asynchronous in WebKit.
>  However, the current specification appears to indicate that the navigation
> happens synchronously.
> Namely, in the following example, the first alert should be "true" as far
> as I read the specification.
> <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>
> On the other hand, Firefox and Internet Explorer do not synchronously load
> iframes, and the first alert in the example above yields "false" although
> it yields "true" on WebKit and Blink.
> Am I reading the specification wrong/missing something?  If not, could you
> amend the specification to make page loads on an iframe always asynchronous?
> - R. Niwa
Received on Thursday, 17 October 2013 22:15:38 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:12 UTC