window.frames not available in dart #20173
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
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.]
The text was updated successfully, but these errors were encountered: