acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
435 stars 46 forks source link

Please consider supporting Firefox's WebExtensions #40

Closed Standard8 closed 7 years ago

Standard8 commented 7 years ago

Firefox is currently implementing web extensions - these are pretty much the same as the chrome.*, although there are a few differences.

Firefox has created the browser.* namespace which is virtually the same as the chrome.* space. There are two differences:

More information:

vitalets commented 7 years ago

@Standard8 great point!

kumar303 commented 7 years ago

One way that would allow this library to keep up with new APIs and API changes (which are probably a bit rare) is to parse schema files. Had you considered that?

Here is an example of the bookmarks API:

All of Firefox's extension schemas:

Parsing schema files would also make the behavior of the mocks very exact.

acvetkov commented 7 years ago

@Standard8 hi.

Why you can not use sinon-chrome for FF web-extensions testing?

global.browser = require('sinon-chrome');

before(function() {
  browser.tabs.query.yields([]);
  // or
  browser.tabs.query.returns(Promise.resolve([]));
});
Standard8 commented 7 years ago

@acvetkov Whilst that is possible, the browser namespace has different APIs to the chrome namespace, so simply duplicating the chrome one isn't likely to be correct - and could lead to code that runs tests fine still being wrong as the API isn't there.

acvetkov commented 7 years ago

@Standard8 Ok. I'll implement schema files for chrome and FF webextensions

acvetkov commented 7 years ago

sinon-chrome has supported webextensions api since 2.1.0 version.