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

fix: syntax error being thrown in Firefox for anonymous objects with computed property names #241

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

nickytonline
Copy link
Member

@nickytonline nickytonline commented Aug 7, 2023

Description

The extension does not currently work in Firefox. This PR does not fix that, but addresses one of the errors that occurs when trying to get the extension to work in Firefox.

Firefox supports objects with computed property names, which allows using a variable as the key, for instance:

{ [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: false }

In Firefox, this syntax requires it to be assigned to a variable, otherwise, it throws an error.

The code { [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: false } throwing the error Uncaught SyntaxError: unexpected token: ':'

The fix involves assigning the object with the computed property name to a variable, like this:

The code const optLogOut = { [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: false } working and setting the variable

Then it can be used in the code, like this:

const optedLogout = { [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: false };

void chrome.storage.local.set(optedLogout);

To test this fix, ensure that things still behave correctly when the browser extension is running in a Chromium based browser (Chrome, Microsoft Edge, Arc Browser etc.)

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Relates to #237

Mobile & Desktop Screenshots/Recordings

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 README.md
  • 📓 docs.opensauced.pizza
  • 🍕 dev.to/opensauced
  • 📕 storybook
  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first Pull Request and thanks for taking the time to improve Open Sauced! ❤️! 🎉🍕
Say hello by joining the conversation in our Discord

@nickytonline nickytonline changed the title fix: fixed syntax error being thrown in Firefox for anonymous objects with computed property names fix: syntax error being thrown in Firefox for anonymous objects with computed property names Aug 7, 2023
Copy link
Member

@Anush008 Anush008 left a comment

Choose a reason for hiding this comment

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

Thank you this contribution.

@bdougie
Copy link
Member

bdougie commented Aug 7, 2023

I submitted these updates to firefox. I am still working through how to test this and uploading a local version as well.

@nickytonline
Copy link
Member Author

I submitted these updates to firefox. I am still working through how to test this and uploading a local version as well.

There's not much to test in regards to Firefox. The login will still fail (no nothing). This is just one of a few errors I've encountered so far. You won't be able to test it locally at the moment in Firefox as there is a branch I have to get Firefox working which includes manifest file changes.

The best bet is to just ensure it still works fine in Chromium based browsers, i.e. the login

Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

there is a branch I have to get Firefox working which includes manifest file changes.

I'm assuming these are manifest changes for things like background which firefox doesn't seem to support the type property. When I've tried to load the extension's manifest locally, I get:

There was an error during the temporary add-on installation.
Error details

Extension is invalid

Reading manifest: Error processing background: Value must either: contain the required "page" property, contain the required "scripts" property, or not contain an unexpected "type" property

which seems that firefox doesn't support the service worker background: https://stackoverflow.com/questions/73440104/failing-to-export-to-background-js-from-a-common-script-under-firefox-with-mv3


Regardless, this looks good to me!!

@nickytonline
Copy link
Member Author

there is a branch I have to get Firefox working which includes manifest file changes.

I'm assuming these are manifest changes for things like background which firefox doesn't seem to support the type property. When I've tried to load the extension's manifest locally, I get:

There was an error during the temporary add-on installation.
Error details

Extension is invalid

Reading manifest: Error processing background: Value must either: contain the required "page" property, contain the required "scripts" property, or not contain an unexpected "type" property

which seems that firefox doesn't support the service worker background: stackoverflow.com/questions/73440104/failing-to-export-to-background-js-from-a-common-script-under-firefox-with-mv3

Regardless, this looks good to me!!

Yeah, like I said, this is one small fix. I'll have my Firefox branch for a while as there's other stuff I need to sort out still, and the manifest I have will need to be copied pre-build for Firefox etc. when it comes to the automated deployment.

@jpmcb
Copy link
Member

jpmcb commented Aug 7, 2023

Ah, I see you mentioned that in the original issue: #237 (comment) 😅 this looks great! Thanks for all the legwork on this so far!

@bdougie
Copy link
Member

bdougie commented Aug 8, 2023

I plan on streaming tomorrow and can take a closer look at this then. At the very least I am learning a lot more about Firefox.

@nickytonline
Copy link
Member Author

I plan on streaming tomorrow and can take a closer look at this then. At the very least I am learning a lot more about Firefox.

I'll push my branch later tonight where I'm experimenting if you want to take a peek at that. I'll tag it in #237

@nickytonline
Copy link
Member Author

I plan on streaming tomorrow and can take a closer look at this then. At the very least I am learning a lot more about Firefox.

I'll push my branch later tonight where I'm experimenting if you want to take a peek at that. I'll tag it in #237

#237 (comment)

@bdougie bdougie merged commit 00ba2c8 into open-sauced:beta Aug 15, 2023
18 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 15, 2023
## [1.14.1-beta.1](v1.14.0...v1.14.1-beta.1) (2023-08-15)

### 🐛 Bug Fixes

* syntax error being thrown in Firefox for anonymous objects with computed property names ([#241](#241)) ([00ba2c8](00ba2c8))
@github-actions
Copy link

🎉 This PR is included in version 1.14.1-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Nov 1, 2023
## [1.14.1](v1.14.0...v1.14.1) (2023-11-01)

### ✅ Tests

* setup playwright for e2e testing ([#262](#262)) ([fc9acca](fc9acca))

### 🔁 Continuous Integration

* bun install, x ([#265](#265)) ([6c765e0](6c765e0))

### 🐛 Bug Fixes

* linkedin projects share ([#264](#264)) ([481472b](481472b))
* login to the website after rename ([1070a0c](1070a0c))
* prevent error when viewing repo and not logged in ([#260](#260)) ([05fcf5e](05fcf5e))
* syntax error being thrown in Firefox for anonymous objects with computed property names ([#241](#241)) ([00ba2c8](00ba2c8))
Copy link

github-actions bot commented Nov 1, 2023

🎉 This PR is included in version 1.14.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants