-
Notifications
You must be signed in to change notification settings - Fork 1.7k
postMessage and other cross-frame operations are broken in dart2js #3175
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
Comments
The cross-frame object can't really have any type since it is impossible to make an is-check work on it, or to have a type-checking. We will have to generate code like (dart2js syntax): An alternative would be to have a new kind of native class somewhat like GWT's overlay types. |
As far as I can tell, this is the source from lib/html/frog/html_frog.dart: void postMessage(Dynamic message, If _window is from a different frame, then it needs to be treated as a native object. I'm also suspecting that calling the method with two different arguments wouldn't be necessary if this was ordinary Dart code. So this is another hint to me that this may actually be native code. Based on these observations, I wonder if this would work: void postMessage(Dynamic message, _pm3(w, m, t) native "return w.postMessage(m, t);"; _pm4(w, m, t, p) native "return w.postMessage(m, t, p);"; |
Hi Peter, That is what we are doing - we are treating _window like a handle without any members of its own. Small detail - _pm3 etc can be a static member. We have a manually generated version for postMessage to get some basic Dromaeo tests unblocked, but we need to change the generator to emit the dozens of other methods to get full coverage. |
Posting a message to another frame breaks today in dart2js. The problem is here in the generated code:
Isolate.$defineClass("_DOMWindowCrossFrameImpl", "Object", ["dartObjectLocalStorage", "_lib_window?"], {
postMessage$3: function(message, targetOrigin, messagePorts) {
if ($.eqNullB(messagePorts)) {
this._lib_window.postMessage$2(message, targetOrigin);
} else {
this._lib_window.postMessage$3(message, targetOrigin, messagePorts);
}
},
The object "this._lib_window" is a Window object in a different frame - which means it is not affected by any patching we need. In particularly, it has no "postMessage$2" object.
This happens to work in Frog since the frog optimizer replaces postMessage$2 with postMessage at compile time.
Marking high as this is coming up in Dromaeo benchmarks.
The text was updated successfully, but these errors were encountered: