Skip to content

Support Android WebView for browser support detection#9557

Merged
aduth merged 5 commits intomainfrom
aduth-browser-support-android
Nov 8, 2023
Merged

Support Android WebView for browser support detection#9557
aduth merged 5 commits intomainfrom
aduth-browser-support-android

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Nov 7, 2023

🛠 Summary of changes

Enhances BrowserSupport to account for Android WebViews.

Previously, WebView user agents were often parsed as "Chrome", and would satisfy constraints for Chrome browser support. However, actual support in these WebView browsers would differ from the native Chrome browser. Since we were not treating these as "unsupported", we were seeing many errors being reported to our frontend error logger from webviews.

Updating the browserslist database also has the effect of including an Android minimum version (119).

The expected result here is that this will silence errors we're seeing from older WebView browsers.

📜 Testing Plan

Verify new browser support includes Android target:

  1. make browsers.json
  2. Observe "android 119" exists in browsers.json

Run BrowserSupport tests:

rspec spec/services/browser_support_spec.rb

If you're feeling ambitious, you can use one of the user agents in the specs to override the user agent string and confirm that error logging will not be added to the layout for an unsupported browser.

aduth added 2 commits November 7, 2023 13:32
changelog: Internal, Browser Support, Improve browser detection for browser support
and_chr: ->(browser, version) { browser.android? && !browser.platform.android_webview? && browser.chrome?(version) },
and_uc: ->(browser, version) { browser.android? && browser.uc_browser?(version) },
chrome: ->(browser, version) { browser.chrome?(version) },
android: ->(browser, version) { browser.platform.android_webview? && browser.send(:detect_version?, browser.version, version) },
Copy link
Contributor Author

@aduth aduth Nov 7, 2023

Choose a reason for hiding this comment

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

I don't love the send here, but android_webview? doesn't accept parameters like the other browser matchers. Internally, detect_version? is what the browser gem uses for parameterized methods (example).

An alternative implementation could be to use the same underlying core logic, but this risks some drift in the logic, and is more verbose.

@aduth
Copy link
Contributor Author

aduth commented Nov 7, 2023

Specs caught a real issue, I'll need to add support for op_mob (Opera Mobile)

https://gitlab.login.gov/lg/identity-idp/-/jobs/849924

@aduth aduth merged commit 66dfd14 into main Nov 8, 2023
@aduth aduth deleted the aduth-browser-support-android branch November 8, 2023 14:00
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.

2 participants