Fixed detection of CustomEvent method

The "CustomEvent" method is from "window.document" not from "window".

This should fix the reported bug for Firefox on Android.

Sorry about that mistake. I should've removed it doing a refactor.

This actual code was tested on Firefox for Android an Firefox OS.