Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.frames not available in dart #20173

Open
mkustermann opened this issue Jul 23, 2014 · 2 comments
Open

window.frames not available in dart #20173

mkustermann opened this issue Jul 23, 2014 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries

Comments

@mkustermann
Copy link
Member

Issue #2312 and issue #1928 were closed a while ago as "Fixed, removed frames API".

The proposed workaround is to use window.queryAll('iframe'). Though it looks to me as this workaround doesn't work properly.

"window.frames" in JavaScript is used for something very important: It allows different windows/iframes to find each other and talk to each despite different origin windows/iframes in between.

Here is a concrete use-case. Let's assume we have a window from www.example.com, it has a hidden iframe from www.google.com and it also opens a new popup window with www.google.com domain. i.e.

Window[www.example.com]
=> contains IFrame[www.google.com] in <body>
=> opens PopUp[www.google.com] window

In this case the popup window can communicate with the iframe by doing something like this:

window.opener.frames[0].postMessage('foo', 'www.google.com')

So the popup is able to discover the iframe (which is from the same origin) and can communicate with it. Though it cannot access 'window.opener.document' (the document property is protected, accessing it will result in a "security/cross-origin violation" error), and therefore cannot query elements.

Does anyone know how we can provide this functionality in dart?
Are there alternatives to to window.frames and, if not, could/should we expose something like window.frames?

[Personally I don't have a concrete use case, but I've looked through some important JS code which uses this pattern, so I wondered whether we should support this feature as well.]

@vsmenon
Copy link
Member

vsmenon commented Jul 28, 2014

I don't think there is any technical reason we could not provide this API. Somewhat irritatingly, window.frames returns a Window (which has an indexed getter). If we did provide this, we'd want to introduce some sort of wrapper class (that implements List<Window>).

That said, we did not consider this a particularly useful API - i.e., the case where it breaks feels contrived.

Do you have pointers to JS libraries that use this pattern where there is a different security origin in between?


Set owner to @efortuna.
Added Area-Library label.

@alan-knight
Copy link
Contributor

Added Accepted label.

@mkustermann mkustermann added Type-Enhancement library-html area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Mar 12, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@efortuna efortuna removed their assignment Nov 16, 2017
@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 20, 2019
@sigmundch sigmundch added the web-libraries Issues impacting dart:html, etc., libraries label Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

6 participants