()
| 111 | }, |
| 112 | |
| 113 | canPerformEventHandlerRequests() { |
| 114 | // Browsers that support navigator.userActivation.isActive: https://developer.mozilla.org/en-US/docs/Web/API/UserActivation/isActive |
| 115 | #if MIN_CHROME_VERSION < 72 || MIN_FIREFOX_VERSION < 120 || MIN_SAFARI_VERSION < 160400 |
| 116 | if (navigator.userActivation) { |
| 117 | // Verify against transient activation status from UserActivation API |
| 118 | // whether it is possible to perform a request here without needing to defer. See |
| 119 | // https://developer.mozilla.org/en-US/docs/Web/Security/User_activation#transient_activation |
| 120 | // and https://caniuse.com/mdn-api_useractivation |
| 121 | return navigator.userActivation.isActive; |
| 122 | } |
| 123 | |
| 124 | return JSEvents.inEventHandler && JSEvents.currentEventHandler.allowsDeferredCalls; |
| 125 | #else |
| 126 | // We are targeting modern browsers where navigator.userActivation.isActive is unconditionally supported. |
| 127 | return navigator.userActivation.isActive; |
| 128 | #endif |
| 129 | }, |
| 130 | |
| 131 | runDeferredCalls() { |
| 132 | if (!JSEvents.canPerformEventHandlerRequests()) { |
nothing calls this directly
no outgoing calls
no test coverage detected