The "initialization" steps for Web browsers

Ian Hickson ian at hixie.ch
Mon Jul 21 16:59:17 PDT 2014


On Mon, 21 Jul 2014, Allen Wirfs-Brock wrote:
> 
> Yes, this is pretty much what I had in mind.

Cool, thanks.


> I mentioned in other message, I can refractor things a bit to make it a 
> bit easier to express.

Cool, ok. Let me know when I should start speccing things on my end.


> However, Realms don't provide the isolation that is required for 
> different origin documents. See the discussion at 
> https://github.com/dslomov-chromium/ecmascript-structured-clone/issues/7 

I think this is confusing two things: the same-origin policy, and event 
loops. Multiple documents with different effective script origins can (and 
frequently do) share one event loop, with script from one origin on the 
stack below script from another origin. In single-process browsers, 
there's only one event loop, even though they support cross-origin 
iframes, tabs, etc. In fact, to make it worse, scripts can on-the-fly 
change their origin using document.domain. Exactly how this works isn't 
exactly defined yet, but the work to define this is described here:

   https://www.w3.org/Bugs/Public/show_bug.cgi?id=20701

It's defined at a level slightly above ES itself. It doesn't re-use the 
"realm" machinery per se. What prevents two realms from different origins 
from ever sharing anything isn't anything in ES, it's just that we never 
actually provide a way for references to make it across (except in edge 
cases involving document.domain manipulation, though those only allow it 
for what we call "similar origins").

Event loops, though, are true isolation. If a browser has two documents in 
two different event loops, they can never share anything. They have 
different heaps, stacks, etc.

Structured cloning was invented to allow data to be passed between event 
loops. However, even with one event loop, you still need structured 
cloning to tranfser data between realms sometimes, because the Web 
platform logically isolates them, as discussed above.

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


More information about the es-discuss mailing list