f = long.chain.of.identifiers.fun error?

J

Jorge

(...)
Even if `window` and Global Object are not the same object (which is
likely, given security boundaries described in MDC article), the chances
of any browser breaking `window == Global Object` (or making their
distinction noticeable) seem to be extremely low.

The way I understand it the problem is that the ES specs expect a
single global object but in a browser there may easily be more than
one, for example when there's an iframe.

That MDC article says "The window object for tab TB must persist as
the user navigates from page to page in that tab".

Swapping global objects behind a single window reference ? But how
does that work, exactly ?

For example, let's say that you've got an iframe, and you save in the
containing window's context a reference to a function f () { return
window; }; defined inside that iframe, then that iframe is navigated
away. Shouldn't the reference to f become undefined ? If not, what is
it, a reference to a function in an unreachable global object ? what
would f() return ? the new window's global, or the old one ? What
would f().f be ? undefined ? (assuming it's not re-defined in the new
page).
 
V

VK

Jorge said:
That MDC article says "The window object for tab TB must persist as
the user navigates from page to page in that tab".

Swapping global objects behind a single window reference ? But how
does that work, exactly ?

Well, MDC is a volunteers maintained public wiki-like resource so take
everything from there highly carefully, especially taking into account
a relatively small amount of its participants: so some explicit bs
from an amateur may stay for a month or more before finally corrected.
As anyone can subscribe for editing, there is quite a lot of wrong
explanations and broken code snippets in there, at least it used to be
so since 2005. For a more serious source on Gecko windows vs. Global I
would highly suggests the recent discussion at
mozilla.dev.tech.js-engine :
http://groups.google.com/group/mozi..._frm/thread/ef207361cde3c675/5abcdf7cb5c06375
where Brendan Eich and Boris Zbarsky are very informative on the
subject IMHO
For example, let's say that you've got an iframe, and you save in the
containing window's context a reference to a function f () { return
window; }; defined inside that iframe, then that iframe is navigated
away. Shouldn't the reference to f become undefined ? If not, what is
it, a reference to a function in an unreachable global object ? what
would f() return ? the new window's global, or the old one ? What
would f().f be ? undefined ? (assuming it's not re-defined in the new
page).

Different browsers are solving it in different ways, as you may find
out by testing. The main objectives are the same: i) a robust AID
(Anti-Idiot Defence) so browser would not crash no matter what badly
written crazy script is may run and ii) do not allow memory
corruptions. The rest is on the artistic approach of this or that
team :) For IE for instance see orphaned scripts and freed scripts
(the latter is exactly on your question about inter-window scripting).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top