also detect functions coming from other JavaScript contexts

Fix #362.