2011/9/5 Mike Schwartz <[email protected]> > So you can share objects among contexts? Do you need to do anything > special to allow it? > > As far as I know, both contexts must share the same security tokens, that's all: http://bespin.cz/~ondras/html/classv8_1_1Context.html#288d8549547f6bdf4312f5333f60f24d
O. > > > On Monday, September 5, 2011, Rico Wind <[email protected]> wrote: > > Hi, > > > > So the simple answer to your simple question :-) > > > > Each iframe does _not_ have its own process, but it does, as you > > write, have its own context. > > If it had chrome could easily spawn several hundred processes for just > > a few iframe heavy pages, plus it would need to do a lot of > > inter-process communication. Actually, every tab does not necessarily > > end up in its own process (you can see the processes chrome is > > currently running in about:memory) > > > > Cheers, > > Rico > > > > > > > > On Fri, Sep 2, 2011 at 4:55 PM, mykes <[email protected]> wrote: > >> Forgive me for what is likely a simple question. > >> > >> In the browser, you can have a WWW page with an IFrame. If the main > >> page has a JavaScript function: > >> > >> function foo(obj) { > >> console.dir(obj); > >> } > >> > >> And the IFrame has JavaScript that calls top.foo(some_object), it > >> works as expected. > >> > >> But it seems to me that the main page and IFrame each have their own > >> context - separate processes, right? And some_object was created in > >> the IFrame context, yet it can be examined in the page context. > >> > >> How is this achieved? > >> > >> To add to my questioning... > >> > >> If these are two different contexts, isn't it possible that there's > >> code running in the main page's context at the exact moment the > >> IFrame calls top.foo() ? > >> > >> I would like to understand how in two separate processes running > >> nothing but V8, I can pass one context's variable to the other, and if > >> it's possible to have both contexts literally share the same object. > >> > >> For example, what if foo() in the main context looks like this: > >> > >> function foo(obj) { > >> setInterval(function() { console.log(obj.bar); }, 1); > >> } > >> > >> And the code in the IFrame looks like this: > >> > >> top.foo(obj); > >> setInterval(function() { obj.bar++; }, 1); > >> > >> In fact, how is "top" itself implemented? (A reference to one context > >> within another) > >> > >> Thanks in advance > >> > >> -- > >> v8-users mailing list > >> [email protected] > >> http://groups.google.com/group/v8-users > >> > > > > -- > > v8-users mailing list > > [email protected] > > http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
