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

Assure multi-browser compatibility #11

Open
tomlutzenberger opened this issue Apr 10, 2017 · 1 comment
Open

Assure multi-browser compatibility #11

tomlutzenberger opened this issue Apr 10, 2017 · 1 comment

Comments

@tomlutzenberger
Copy link
Member

tomlutzenberger commented Apr 10, 2017

Make sure that the extension runs in the main browsers: Chrome, FF, Opera and Vivaldi
Best solution for different methods (e.g. deprecated) would be capsulate them and execute depending on what browser it is running.

I think of something like this:

if (mybrowser === 'firefox') {
    browser.runtime.sendMessage(/* params */);
} else {
    chrome.extension.sendRequest(/* params */);
}

This might also be helpful:
https://www.smashingmagazine.com/2017/04/browser-extension-edge-chrome-firefox-opera-brave-vivaldi/

@gagarine
Copy link
Contributor

gagarine commented Apr 10, 2017

For the moment, what I saw is if FF is not supporting a chrome API is habitually because it's deprecated on the chrome side and FF only support the new version. In this case it's better to change the deprecated API call for the new one.

Their is some API that are not supported by Edge or Firefox. So yeah we have to use a subset of the API. If we have to use different API we should test if the function exist instead of the browser I think:

function isFunction(possibleFunction) {
  return typeof(possibleFunction) === typeof(Function);
}

if (isFunction(browser.runtime.sendMessage) {
    browser.runtime.sendMessage(/* params */);
} else {
    chrome.extension.sendRequest(/* params */);
}

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

No branches or pull requests

2 participants