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 popup in private Firefox windows by replacing getBackgroundPage #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OmarWKH
Copy link

@OmarWKH OmarWKH commented Apr 22, 2020

The extension popup fails in a private Firefox window because of getBackgroundPage.

I replaced getBackgroundPage with sendMessage to communicate with the background script.

sendMessage has a different API in Firefox and Chrome. So I had to add a workaround to work in both. It supports the simple case of sending an internal message and getting a response.

It does not support the extensionId and options arguments.

It does not support error handling. Firefox uses promises so it'll need a .catch. Chrome expects you to check runtime.lastError in the response callback. There is currently no error handling when using sendMessage in popup.js or onMessage in background.js.

I tested this in normal and private browsing in Firefox 76.0 and Chrome 80.0.3987.163. I changed the settings in the popup and verified that they persist when I open the popup again.

This fixes ugetdm/uget-integrator#52.

getBackgroundPage does not work in a private Firefox window
sendMessage uses promises in firefox and callbacks in chrome.
This workaround works in the simple case. It is missing:
- extensionId and options arguments.
- Error handling. Firefox uses .catch and chrome uses lastError.
@OmarWKH OmarWKH marked this pull request as ready for review April 22, 2020 13:25
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.

Addon doesn't work in Firefox private window
1 participant