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

ReferenceError: browser is not defined #194

Closed
huchenhai opened this Issue Mar 13, 2017 · 7 comments

Comments

Projects
None yet
5 participants
@huchenhai

huchenhai commented Mar 13, 2017

Please advise

@wbamberg

This comment has been minimized.

Show comment
Hide comment
@wbamberg

wbamberg Mar 13, 2017

Member

You'll need to give me more information than this, like an actual complete add-on that is giving you this error, and steps to reproduce.

Member

wbamberg commented Mar 13, 2017

You'll need to give me more information than this, like an actual complete add-on that is giving you this error, and steps to reproduce.

@lidel

This comment has been minimized.

Show comment
Hide comment
@lidel

lidel Mar 14, 2017

@huchenhai If you got the error while running one of examples, make sure you are using the latest Firefox (version 52.x).
If problem occurred while running test suite with sinon-chrome,
try stubbing with var browser = browser || chrome or by using https://github.com/mozilla/webextension-polyfill

lidel commented Mar 14, 2017

@huchenhai If you got the error while running one of examples, make sure you are using the latest Firefox (version 52.x).
If problem occurred while running test suite with sinon-chrome,
try stubbing with var browser = browser || chrome or by using https://github.com/mozilla/webextension-polyfill

@wbamberg wbamberg closed this Apr 25, 2017

@SerkanSipahi

This comment has been minimized.

Show comment
Hide comment
@SerkanSipahi

SerkanSipahi Oct 21, 2017

@wbamberg i have tried some of the 'webextensions-examples' on chrome v61 but i get an error browser is not defined! what im doing wrong? is the global 'browser' not available on chrome? should i use webextension-polyfill? i thought that 'webextensions' api by w3c and chrome, opera, etc have already implemented that....

SerkanSipahi commented Oct 21, 2017

@wbamberg i have tried some of the 'webextensions-examples' on chrome v61 but i get an error browser is not defined! what im doing wrong? is the global 'browser' not available on chrome? should i use webextension-polyfill? i thought that 'webextensions' api by w3c and chrome, opera, etc have already implemented that....

@makyen

This comment has been minimized.

Show comment
Hide comment
@makyen

makyen Oct 21, 2017

Contributor

@SerkanSipahi That browser is not defined is expected in Chrome. Chrome implements the APIs using the chrome.* namespace with callbacks. Firefox implements the namespace browser.* with Promises for all APIs, and chrome.* (with callbacks) for almost all APIs (all that are cross compatible with Chrome). If you want cross compatibility with Chrome, then you should do either:

  1. Use the chrome.* namespace and callbacks. These will just work in Chrome and Firefox. Compatibility with Edge is also easier, because Edge implements the browser.* namespace, but uses callbacks, not Promises.
  2. Use a shim/polyfill which converts calls to the browser.* namespace with Promises to chrome.* with callbacks for Chrome. One such shim is: webextension-polyfill. Note that any pollyfill/shim you use will come with it's own set of issues.
Contributor

makyen commented Oct 21, 2017

@SerkanSipahi That browser is not defined is expected in Chrome. Chrome implements the APIs using the chrome.* namespace with callbacks. Firefox implements the namespace browser.* with Promises for all APIs, and chrome.* (with callbacks) for almost all APIs (all that are cross compatible with Chrome). If you want cross compatibility with Chrome, then you should do either:

  1. Use the chrome.* namespace and callbacks. These will just work in Chrome and Firefox. Compatibility with Edge is also easier, because Edge implements the browser.* namespace, but uses callbacks, not Promises.
  2. Use a shim/polyfill which converts calls to the browser.* namespace with Promises to chrome.* with callbacks for Chrome. One such shim is: webextension-polyfill. Note that any pollyfill/shim you use will come with it's own set of issues.
@SerkanSipahi

This comment has been minimized.

Show comment
Hide comment
@SerkanSipahi

SerkanSipahi Oct 21, 2017

@makyen thank you, you help me a lot :)

SerkanSipahi commented Oct 21, 2017

@makyen thank you, you help me a lot :)

@wbamberg

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment