[whatwg] onclose events for MessagePort

Ian Hickson ian at hixie.ch
Wed Oct 30 13:33:58 PDT 2013


On Tue, 29 Oct 2013, Ian Hickson wrote:
> 
> Consider these three scenarios:
> 
> A. Page Alpha opens a shared worker, and they communicate using a pair of 
> MessagePorts. Alpha is navigated away, going to Beta in a different 
> origin. Later, the user hits back, and since Alpha is still in the 
> bfcache, the shared worker can still communicate, and the messages that 
> were sent while Alpha was away get delivered.
> 
> B. Page Gamma is has an iframe. In that iframe, there's page Alpha, which 
> opens a shared worker, and they communicate using a pair of MessagePorts. 
> Alpha is navigated away, leading the iframe to Beta in a different origin. 
> Later, the user hits back, and since Alpha is still in the bfcache, the 
> shared worker can still communicate, and the messages that were sent while 
> Alpha was away get delivered.
> 
> C. Page Gamma is has an iframe. In that iframe, there's page Alpha, which 
> opens a shared worker, and they communicate using a pair of MessagePorts. 
> Alpha then passes a reference to the port to Gamma. Then, Alpha is 
> navigated away, leading the iframe to Beta in a different origin. Gamma 
> and the shared worker can communicate.
> 
> A and C are mutually exclusive. Either the port's messages get delivered 
> while Alpha is away, or they don't.

Looks like Safari, Chrome, and (according to Anne, thanks!) IE10, all act 
in a manner that makes C impossible:

   http://www.hixie.ch/tests/adhoc/dom/web-apps/postMessage/ports/001.html

Basically, when a frame receives a port, it gets assigned to that frame, 
and when the frame is navigated, the port stops firing events on itself.

Unless someone objects, that's what I'm going to spec.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list