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

VPN-6473: check for OS in addons #9689

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Conversation

mcleinman
Copy link
Collaborator

@mcleinman mcleinman commented Jun 25, 2024

Description

Checking OS via a JS condition.

I don't believe this adds any translations, but perhaps those strings did something weird? I'm not sure why @flodolo got auto-added to this PR.

This PR overrides #9686. However, I'm keeping that one open for now - I asked whether we want to modify that to add the condition in, so that we can use it in the future once enough users are on a version that include that condition.

Also, I might be doing over-defensive code with this check: if (!osVersion || (typeof osVersion !== "string") || osVersion.length === 0). I don't write JS often; please let me know if there is a better way to do this.

Reference

VPN-6473

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed
Copy link
Member

@lesleyjanenorton lesleyjanenorton left a comment

Choose a reason for hiding this comment

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

Nice! Looks right, smells right. Left one question but R+

@@ -4,7 +4,8 @@
"name": "Update to Mozilla VPN 2.23",
"type": "message",
"conditions": {
"max_client_version": "2.22.9"
"max_client_version": "2.22.9",
"javascript": "osCheck.js"
},
"javascript": {
"enable": "enable.js"
Copy link
Member

Choose a reason for hiding this comment

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

Nice! Any reason to not just do this in enable.js where the other show/hide decision making happens?

Copy link
Collaborator Author

@mcleinman mcleinman Jun 26, 2024

Choose a reason for hiding this comment

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

enable is run when the addon is enabled. We use it to modify the data in the addon based on conditions.

There is an addon condition type (conditions are used to decide whether to even show the addon) of javascript, which can enable arbitrary javascript as part of a test as to whether to show the addon. (Other conditions are client version, time, and a handful of others.) It seems more appropriate to use a condition for this, and I'm not sure it's even possible to use an enable js snippet to halt usage of the addon. If you know of a way, I'm happy to explore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed in person, we're all comfortable w/ this. Going to merge.

@flodolo flodolo removed their request for review June 26, 2024 06:11
@mcleinman mcleinman merged commit 943bf76 into main Jun 26, 2024
121 checks passed
@mcleinman mcleinman deleted the vpn-6473-addons-os-check-via-js branch June 26, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants