connection ceremony for iframe postMessage communications

2012-02-09 Thread John J Barton
Recently I've been working with iframe messaging. The postMessage solution has a lot of advantages and good traction across iframes, WebWorkers, and browser extensions, with lots of overlap with Web Sockets. However the technology has two significant problems. First is the "contentWindow that is

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread Boris Zbarsky
On 2/9/12 1:15 PM, John J Barton wrote: This leads developers to look for events that will tell them about 'load' on iframes, and that leads them to try iframe.contentWindow.addEventListener(). It works fine for same-domain iframes, but fails for cross-domain. Adding a load listener to the ifra

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread John J Barton
On Thu, Feb 9, 2012 at 11:49 AM, Boris Zbarsky wrote: > On 2/9/12 1:15 PM, John J Barton wrote: >> >> This leads developers to look for events that will tell them about >> 'load' on iframes, and that leads them to try >> iframe.contentWindow.addEventListener(). It works fine for same-domain >> ifr

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread John J Barton
On Thu, Feb 9, 2012 at 11:49 AM, Boris Zbarsky wrote: > That doesn't help with the second problem, of course Ok here are some ideas, riffing off the web messaging doc 1 To iframe element add: readonly attribute MessagePort port; 'message' events from the iframe to the containing window

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread Ian Hickson
On Thu, 9 Feb 2012, John J Barton wrote: > > However the solution has two significant problems: > 1. There is no way to know if portToOtherWindow is connected before > you issue postMessage() Just have the target message you when it's ready. > 2. All iframes send messages to the same "handl

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread John J Barton
On Thu, Feb 9, 2012 at 4:42 PM, Ian Hickson wrote: > On Thu, 9 Feb 2012, John J Barton wrote: >> >> However the solution has two significant problems: >>   1. There is no way to know if portToOtherWindow is connected before >> you issue postMessage() > > Just have the target message you when it's

Re: connection ceremony for iframe postMessage communications

2012-02-09 Thread Ian Hickson
On Thu, 9 Feb 2012, John J Barton wrote: > On Thu, Feb 9, 2012 at 4:42 PM, Ian Hickson wrote: > > On Thu, 9 Feb 2012, John J Barton wrote: > >> > >> However the solution has two significant problems: > >>   1. There is no way to know if portToOtherWindow is connected before > >> you issue postMess

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread John J Barton
On Thu, Feb 9, 2012 at 11:53 PM, Ian Hickson wrote: > On Thu, 9 Feb 2012, John J Barton wrote: >> On Thu, Feb 9, 2012 at 4:42 PM, Ian Hickson wrote: >> > On Thu, 9 Feb 2012, John J Barton wrote: >> >> >> >> However the solution has two significant problems: >> >>   1. There is no way to know if p

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread Ian Hickson
On Fri, 10 Feb 2012, John J Barton wrote: > > > > What I meant was just to do this on the receiving side (inside the > > iframe), after the onmessage handler has been set up (which we are > > assuming happens after the 'load' event for some reason): > > > >   parent.postMessage('load', '*'); > >

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread John J Barton
On Fri, Feb 10, 2012 at 10:58 AM, Ian Hickson wrote: > On Fri, 10 Feb 2012, John J Barton wrote: >> >> Just to clarify, I want to see the layer you just outlined be standard >> so we can design iframe components and apps to mix and match. This can >> be two simple layers on the current messaging:

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread Ian Hickson
On Fri, 10 Feb 2012, John J Barton wrote: > On Fri, Feb 10, 2012 at 10:58 AM, Ian Hickson wrote: > > On Fri, 10 Feb 2012, John J Barton wrote: > >> > >> Just to clarify, I want to see the layer you just outlined be > >> standard so we can design iframe components and apps to mix and > >> match.

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread John J Barton
On Fri, Feb 10, 2012 at 10:58 AM, Ian Hickson wrote: > On Fri, 10 Feb 2012, John J Barton wrote: >> > >> > What I meant was just to do this on the receiving side (inside the >> > iframe), after the onmessage handler has been set up (which we are >> > assuming happens after the 'load' event for som

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread Ian Hickson
On Fri, 10 Feb 2012, John J Barton wrote: > > I think there are two more cases. Because the messages are all async, > the 'it gets missed case" can be "it gets delayed". That causes > additional messages. > > - parent opens iframe, then sets up communications, iframe is quicker: >- iframe

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread John J Barton
On Fri, Feb 10, 2012 at 1:37 PM, Ian Hickson wrote: > On Fri, 10 Feb 2012, John J Barton wrote: >> On Fri, Feb 10, 2012 at 10:58 AM, Ian Hickson wrote: >> > On Fri, 10 Feb 2012, John J Barton wrote: >> >> >> >> Just to clarify, I want to see the layer you just outlined be >> >> standard so we can

Re: connection ceremony for iframe postMessage communications

2012-02-10 Thread Charles Pritchard
On 2/10/2012 3:44 PM, John J Barton wrote: Thanks. As a hint for the next person, it seems like the asymmetric messages (parent 'ping', iframe 'load') is easier than symmetric ('hello'/'ack') I think there are two more cases. Because the messages are all async, the 'it gets missed case" can be "

Re: connection ceremony for iframe postMessage communications

2012-02-13 Thread Ian Hickson
On Fri, 10 Feb 2012, John J Barton wrote: > > > > Why would the connectivity part of this be the hard part? > > Because the existing information on cross-domain iframe communications > is incomplete and written in terms few Web app developers understand, > the browser implementations are new and

Re: connection ceremony for iframe postMessage communications

2012-02-13 Thread John J Barton
On Mon, Feb 13, 2012 at 12:57 PM, Ian Hickson wrote: > On Fri, 10 Feb 2012, John J Barton wrote: >> > >> > Why would the connectivity part of this be the hard part? >> >> Because the existing information on cross-domain iframe communications >> is incomplete and written in terms few Web app develo