gimite / web-socket-js

HTML5 Web Socket implementation powered by Flash
BSD 3-Clause "New" or "Revised" License
2.74k stars 490 forks source link

TypeError: event.initMessageEvent is not a function #142

Closed cope closed 10 years ago

cope commented 10 years ago

Since FF 26 this error message started showing up, crashing the application.

I believe event.initMessageEvent is only called in web_socket.js on line 208?

nvidia alsius_2013-12-12_10-07-50

cope commented 10 years ago

I filed a firefox bug (https://bugzilla.mozilla.org/show_bug.cgi?id=949376) for this, since I do not believe that this is a web-socket-js issue.

cope commented 10 years ago

ups... https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/26/Site_Compatibility

MessageEvent has been updated

Bug 848294 – Update MessageEvent to be compatible with the spec

The MessageEvent interface has been updated to comply with the latest spec. The initMessageEvent method has been removed while the interface is now a constructor.

cope commented 10 years ago

found a solution

if (event.initMessageEvent) { // IE does not accept 'new MessageEvent' so this has to stay event.initMessageEvent("message", false, false, data, null, null, window, null); } else if (event.initEvent) { // needed for FF 26 and possible others soon... var event = new MessageEvent('message', { 'view': window, 'bubbles': false, 'cancelable': false, 'data': data }); }