Implement cache or equality on _DOMWindowCrossFrame #20174
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
closed-obsolete
Closed as the reported issue is no longer relevant
library-html
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Windows/IFrames of different origin communicate with each other via the postMessage() mechanism. A script on a window can listen for incoming messages, but needs to know from where the message originated. This is possible by looking at [MessageEvent.source].
The following conceptual program works in dartium but not after compiling it with dart2js:
import 'dart:html';
main() {
var iframe = new IFrameElement();
iframe.src = "...";
document.body.append(iframe);
window.onMessage.listen((MessageEvent event) {
if (event.source == iframe.contentWindow) {
// This message is coming from [iframe].
// => We get in here in dartium but not in dart2js.
}
});
}
The root cause is that the two _DOMWindowCrossFrame objects are not the same. There is a TODO in the following code to fix this:
dart/tools/dom/src/dart2js_DOMImplementation.dart:
...
47 static WindowBase _createSafe(w) {
48 if (identical(w, window)) {
49 return w;
50 } else {
51 // TODO(vsm): Cache or implement equality.
52 return new _DOMWindowCrossFrame(w);
53 }
54 }
...
@vsm/blois: Is there any chance someone could work on this? Would be highly appreciated.
The text was updated successfully, but these errors were encountered: