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

Switch to PWA in Firefox extension when SW API is unavailable #878

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

mossroy
Copy link
Contributor

@mossroy mossroy commented Aug 4, 2022

This is necessary for Firefox >=103, where the ServiceWorker API has been removed in WebExtensions.
See https://hg.mozilla.org/integration/autoland/rev/3a2907ad88e8

Fixes #877

@mossroy mossroy requested a review from Jaifroid August 4, 2022 13:34
@mossroy mossroy marked this pull request as draft August 4, 2022 13:51
@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

Switched this PR to draft as it's not working properly for now

@mossroy mossroy marked this pull request as ready for review August 4, 2022 14:13
@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

Now tested on Firefox 103.0 on Ubuntu

@Jaifroid
Copy link
Member

Jaifroid commented Aug 4, 2022

Thanks for this PR. I'll test the UX (by installing as a developer-mode extension).

I wonder if there is another way of preventing users of old Firefox editions (I mean really old ones that don't support Service Worker at all) from being invited to switch to SW mode? Is this a case where testing explicitly for (Firefox < 103 AND SW unavailable) is warranted? Or could we test for a proxy API that will assure us that we are in a recent Firefox?

@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

After fighting to disable auto-update of Firefox, I managed to test with version 52.9.0ESR.
When asking for SW mode, it suggests to use the PWA. If I accept, it opens the PWA, which says "The ServiceWorker API is not available on your device" and fallsback to jQuery mode (but stays inside the PWA).
When you close the extension and open it again, it says "The last attempt to launch the PWA appears to have failed. Do you wish to try again?". If you confirm, it switches again to the PWA (same behavior). If you cancel, it stays in local jQuery mode.

So it's not that bad.

If we want to test the browser version, it should only be a "hint", like adding in the systemAlert that it will probably not work because this browser probably does not support ServiceWorkers. But we should avoid making a decision based on this version

@Jaifroid
Copy link
Member

Jaifroid commented Aug 4, 2022

OK, that's good. I think it's enough for now. We might have to introduce something once we switch to SW mode as default (assuming we will apply that default to the Firefox extension version).

I've tested on:

  • Firefox 103 (portable) on Windows 11 in a temporary extension. Works fine.
  • Edge for Windows 11 (running from localhost). It starts automatically in SW mode (running from localhost).
  • IE11 on Windows 11 (yes, there's a trick to be able to launch IE11 still on Windows 11!!), running from localhost. It rightly tells me that SW mode won't work when I try to switch, and falls back to jQuery mode.
  • I haven't tested on old Edge legacy, but it's irrelevant now, and I think the behaviour will just mirror IE11 except that in some desktop versions of Edge legacy SW mode works. In that case it will act the same way as Edge/Chromium.

So I don't think I need to do any more tests. I'll take a look at the code.

Copy link
Member

@Jaifroid Jaifroid left a comment

Choose a reason for hiding this comment

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

Good catch!

Just one small coding-style suggestion below. When you're happy you've done enough testing, feel free to squash/merge.

www/js/app.js Outdated Show resolved Hide resolved
This is necessary for Firefox >=103, where the ServiceWorker API has been
removed in WebExtensions.
See https://hg.mozilla.org/integration/autoland/rev/3a2907ad88e8

Fixes #877
@mossroy mossroy force-pushed the Fix-switch-to-pwa-regression-with-firefox-103 branch from d827c85 to 452fc0d Compare August 4, 2022 15:27
@mossroy mossroy merged commit 53ba099 into master Aug 4, 2022
@mossroy mossroy deleted the Fix-switch-to-pwa-regression-with-firefox-103 branch August 4, 2022 15:52
@Jaifroid Jaifroid mentioned this pull request Oct 18, 2022
5 tasks
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.

Firefox extension does not switch to the PWA any more since Firefox 103.0
2 participants