Skip to content

A WindowBase subclass does not implement addEventListener #16937

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

Closed
DartBot opened this issue Feb 19, 2014 · 6 comments
Closed

A WindowBase subclass does not implement addEventListener #16937

DartBot opened this issue Feb 19, 2014 · 6 comments
Assignees
Labels
closed-as-intended Closed as the reported issue is expected behavior web-libraries Issues impacting dart:html, etc., libraries

Comments

@DartBot
Copy link

DartBot commented Feb 19, 2014

This issue was originally filed by [email protected]


https://api.dartlang.org/apidocs/channels/stable/#dart-dom-html.WindowBase reads:

void addEventListener(String type, EventListener listener, [bool useCapture])
Register an event handler of a specific event type on the EventTarget.

but the following code fails:

  IFrameElement ife=new IFrameElement();
  document.body.append(ife);
  WindowBase nw=ife.contentWindow;
  nw.addEventListener("message", (Event event) {
    print("ev=$event");
  });
  

Exception: Class '_DOMWindowCrossFrame' has no instance method 'addEventListener'.

@lrhn
Copy link
Member

lrhn commented Feb 19, 2014

Added Area-HTML, Triaged labels.

@efortuna
Copy link
Contributor

What build are you using? I'm pretty sure this very bug was fixed last week.


Set owner to @efortuna.
Added NeedsInfo label.

@DartBot
Copy link
Author

DartBot commented Feb 25, 2014

This comment was originally written by [email protected]


http://storage.googleapis.com/dart-archive/channels/stable/release/latest/editor/darteditor-linux-ia32.zip still contains version 1.1.3 (Thu Feb 6 00:04:09 2014)

@efortuna
Copy link
Contributor

Any build after Feb 12 has this problem fixed.


Added AssumedStale label.

@DartBot
Copy link
Author

DartBot commented Mar 12, 2014

This comment was originally written by [email protected]


Chromium 33.0.1750.48, updated by tools/test.py, still throws the exception

@efortuna
Copy link
Contributor

So the issue in this specific case is you can't register an event listener on a window other than yourself. It is the good ol' same origin policy issues, but Dart is slightly stricter than JavaScript. So the way to accomplish that chunk of code would be to ask the contentWindow to add its own event listener, and post a message to the parent window when it has completed so you know when you're ready to start receiving messages.

In the meanwhile, I'll update the error thrown, so that is less confusing.


Added AsDesigned label.

@DartBot DartBot added Type-Defect web-libraries Issues impacting dart:html, etc., libraries closed-as-intended Closed as the reported issue is expected behavior labels Mar 12, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-intended Closed as the reported issue is expected behavior web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

4 participants