function handleCustomVisibilityChange(event) {
    document.dispatchEvent(new CustomEvent(`visibility${document.visibilityState}`, {
        detail: {
            cause: event
        }
    }));
}
Dispatches a custom visibility event at the document derived
from the value of {@see document.visibilityState}.

@listens document#visibilitychange

@fires PageVisibility#visibilityhidden
@fires PageVisibility#visibilityvisible

@param  {Event} event
@return {void}