Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[devtools][firefoxos] Don't use window.top, window.parent and window.frameElement

83 views
Skip to first unread message

Paul Rouget

unread,
Sep 17, 2013, 5:33:21 AM9/17/13
to dev-devel...@lists.mozilla.org
In Gecko, if an iframe uses the `mozbrowser` attribute, from the point of view of
the inner windows, the iframe is the top level window.

In these iframes, this is true: window.parent === window.

And we often use that to determine if a window is the top level window.
(bug 896523 & 897960).

In Firefox OS, the mozbrowser attribute is used often.

>From MDN:

> <iframe mozbrowser>
> Indicates that the frame is to appear like a top-level browser window
> to the embedded content. This means that window.top, window.parent,
> window.frameElement, etc. will not reflect the frame hierarchy. This
> allows for a web browser UI to be implemented entirely with web
> technology, given the right permissions. See Using the Browser API for
> details. Available in Gecko 13.0 and later.

Instead, it's better to use the docshell hierarchy (see nsIDocShellTreeItem).
Some example:
http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/LayoutHelpers.jsm#367

-- Paul
0 new messages