FIX: Long poll if window becomes active (PR #13825)

This commit fixes two bugs. The first one is that onPresenceChange was called with invalid arguments and it did not register a callback. The second bug is that it triggered the wrong visibilitychange event. The function it tried to call does not exist in all versions of MessageBus. It is safer to trigger an event instead because that exists in all versions.

The test was intentionally omitted because we do not test MessageBus and it requires a lot of stubs which do not make the test useful anymore.


This pull request has been mentioned on Discourse Meta. There might be relevant details there: