Changed new Event() to document.createEvent(Event) for comptability with phantom-js