Skip to content

Commit ed73db0

Browse files
authored
Add unconditional support for navigator.userActivation.isActive (#26859)
Add unconditional support for navigator.userActivation.isActive if targeting modern enough browsers.
1 parent c97d342 commit ed73db0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/lib/libhtml5.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,21 @@ var LibraryHTML5 = {
111111
},
112112

113113
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
114116
if (navigator.userActivation) {
115117
// Verify against transient activation status from UserActivation API
116118
// whether it is possible to perform a request here without needing to defer. See
117119
// https://developer.mozilla.org/en-US/docs/Web/Security/User_activation#transient_activation
118120
// and https://caniuse.com/mdn-api_useractivation
119-
// At the time of writing, Firefox does not support this API: https://bugzil.la/1791079
120121
return navigator.userActivation.isActive;
121122
}
122123

123124
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
124129
},
125130

126131
runDeferredCalls() {

0 commit comments

Comments
 (0)