Fix popup in private Firefox windows by replacing getBackgroundPage #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The extension popup fails in a private Firefox window because of
getBackgroundPage
.I replaced
getBackgroundPage
withsendMessage
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
andoptions
arguments.It does not support error handling. Firefox uses promises so it'll need a
.catch
. Chrome expects you to checkruntime.lastError
in the response callback. There is currently no error handling when usingsendMessage
in popup.js oronMessage
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.