Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use window.ontouchstart to detect Safari on iPad. #13328

Merged
merged 1 commit into from
Jun 30, 2023
Merged

Use window.ontouchstart to detect Safari on iPad. #13328

merged 1 commit into from
Jun 30, 2023

Conversation

denschub
Copy link
Member

@denschub denschub commented Jun 29, 2023

One-line summary

With yesterday's release of Safari Tech Preview 173, Safari on macOS now supports Web Apps. This results in navigator.standalone existing, which in turn means that Safari on macOS users will be prompted to install the iOS version of Firefox on https://www.mozilla.org/en-US/firefox/new/

Significant changes and points to review

This PR changes that to look for window.ontouchstart instead, as Safari on macOS does not support those. Thanks to @nt1m for that suggestion.

Issue / Bugzilla link

n/a

Screenshots

n/a

Checklist

If relevant:

  • Tests added
  • Feature flags added to www-config
  • New secrets added to the secrets repository
  • If new dependencies are added, I've checked their license is appropriate

Testing

Demo server URL: (or None)

To test this work:

  • Open /en-US/firefox/new/ in Safari Tech Preview 173 on macOS and verify that the user is promoted to download the Mac versoin.

@zcorpan
Copy link
Member

zcorpan commented Jun 29, 2023

FYI https://w3c.github.io/touch-events/#dfn-expose-legacy-touch-event-apis is defined but only used for hiding ontouchstart et al event handlers, not window.TouchEvent (per spec). Also see whatwg/dom#952

@denschub denschub changed the title Use window.TouchEvent to detect Safari on iPad. Use window.ontouchstart to detect Safari on iPad. Jun 29, 2023
@denschub
Copy link
Member Author

I changed the patch to check for ontouchstart instead. :)

Copy link
Member

@alexgibson alexgibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this works locally with Safari tech preview and iOS simulator.

Thanks for the report, and the fix! 💯

@alexgibson alexgibson merged commit c7a7012 into mozilla:main Jun 30, 2023
@denschub denschub deleted the safari-ipad-detection branch July 1, 2023 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants