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(launcher): support Firefox as a snap #21328

Merged
merged 9 commits into from May 5, 2022
Merged

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented May 3, 2022

User facing changelog

  • Fixed an issue causing Linux users with Firefox installed via Snapcraft to encounter errors on launch.

Additional details

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 3, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented May 4, 2022



Test summary

4873 0 61 1Flakiness 2


Run details

Project cypress
Status Passed
Commit a81493d
Started May 4, 2022 6:06 PM
Ended May 4, 2022 6:23 PM
Duration 17:04 💡
OS Linux Debian - 10.10
Browser Electron 94

View run in Cypress Dashboard ➡️


Flakiness

traversal.spec.ts Flakiness
1 cy.origin traversal > #consoleProps > .parent()
screenshot.spec.ts Flakiness
1 cy.origin screenshot > without setting viewport > does not pause timers when disableTimersAndAnimations is false

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@flotwig flotwig marked this pull request as ready for review May 4, 2022 00:26
@flotwig flotwig requested a review from a team as a code owner May 4, 2022 00:26
@flotwig flotwig requested review from jennifer-shehane and BlueWinds and removed request for a team and jennifer-shehane May 4, 2022 00:26
@flotwig flotwig requested a review from tbiethman May 4, 2022 15:31

await fd.close()

return buffer.slice(0, bytesRead).toString('utf8').includes('exec /snap/bin/firefox')
Copy link
Contributor

Choose a reason for hiding this comment

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

Today I learned about reading only the opening bytes of a file! This seemed odd (particularly the slice), so I poked around the docs and command line, and lo, you have done it correctly. :)


async function isFirefoxSnap (binary: string): Promise<boolean> {
try {
return await Bluebird.resolve((async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to avoid Bluebird promises in newly written code when possible. Especially since we're already inside an async function, do we need Bluebird.resolve here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using Bluebird.resolve to get access to .timeout. I could Promise.race/new Promise/setTimeout but I figure that unless we are planning on moving all the code in the code base to not use Bluebird, might as well use the utilities we have. I also generally agree that BB should be avoided in new code.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is something I would like to do at some point, remove bluebird from our existing code. But adding timeout utility functions is beyond the scope of this PR, fair enough.

const binaryPath = await which(binary)

// if the bin path or what it's symlinked to start with `/snap/bin`, it's a snap
if (binaryPath.startsWith('/snap/bin/') || (await fs.realpath(binaryPath)).startsWith('/snap/bin')) return true
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

Copy link
Contributor

@tbiethman tbiethman left a comment

Choose a reason for hiding this comment

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

Verified on my Ubuntu VM that both snap/non-snap firefox installations are launched by Cypress

@flotwig flotwig merged commit 05ef83a into develop May 5, 2022
@flotwig flotwig deleted the issue-19793-firefox-as-snap branch May 5, 2022 16:32
@flotwig flotwig mentioned this pull request May 6, 2022
5 tasks
tgriesser added a commit that referenced this pull request May 13, 2022
* 10.0-release: (22 commits)
  fix: migrate multiples projects when in global mode (#21458)
  test: fix flaky cy-in-cy selector validity test (#21360)
  chore: remove unused codeGenGlobs (#21438)
  fix: use correct path for scaffolding spec on CT (#21411)
  fix: remove breaking options from testing type on migration (#21437)
  fix: test-recording instructions in Component Test mode (#21422)
  feat: distinguish app vs launchpad utm_source when using utm params (#21424)
  chore: update stubbed cloud types (#21451)
  chore: change to yarn registry
  fix(sessions): refactor flows, fix grouping bugs and align validation fail text (#21379)
  chore(sessions): more driver tests (#21378)
  chore: rename domain_fn to origin_fn (#21413)
  chore: release 9.6.1 (#21404)
  fix: ensure that proxy logs are updated after the xhr has actually completed (#21373)
  chore: Re-organize tests in assertions_spec.js (#21283)
  chore: Distribute tests to desktop-gui containers. Make `desktop-gui` tests faster! (#21305)
  chore(sessions): add additional tests (#21338)
  fix: Allow submit button to be outside of the form for implicit submission (#21279)
  fix(launcher): support Firefox as a snap (#21328)
  chore(sessions): break out sessions manager code and add unit tests (#21268)
  ...
@nicktelindertvmw
Copy link

The snap version of firefox and chromium are not detected by cypress for 12.17.2, testing on Ubuntu 22.04 and newer

@jennifer-shehane
Copy link
Member

@nicktelindertvmw Please open a new issue describing the behavior and a reproducible example

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can’t use default Firefox on latest Ubuntu
5 participants