Commit Graph

193 Commits

Author SHA1 Message Date
Luca Greco e17f1e1763 chore: Fixed npm badge in README.md 2018-07-19 16:43:57 +02:00
Luca Greco 440857e5f8
doc: Rewrite README.md and move build and contribution details into a separate doc file (#147) 2018-07-19 15:56:49 +02:00
Stuart Colville 890a99ae62 chore: Updated npm token in the travis config file (#149) 2018-07-16 13:59:40 +02:00
Rob Wu d77a418537 feat: Support promises in privacy namespace 2018-07-11 18:04:32 +02:00
PoziWorld ea82fbf556 chore: Fixed typos in inline comments (#144) 2018-07-07 17:44:19 +02:00
PoziWorld 33c2afb578 chore: Fixed typo in the README file (#143) 2018-07-07 17:43:17 +02:00
ExE Boss 4712d9274d chore: Fixed build and integration tests when installed using pnpm (#127) 2018-07-04 13:47:41 +02:00
Rob Wu d612352bba fix: resolve to undefined instead of an empty array 2018-07-04 13:17:09 +02:00
Simon Lydell 4e1e98add2 fix: sendMessage promise should resolve to undefined when no listeners reply 2018-07-04 13:06:42 +02:00
Rob Wu 7ff6e8a1dc chore: Stop swallowing errors in .sh tests
The Bash shell scripts ignored errors in all but the last line.
This commit adds `set -eo pipefail` to fix the issue:

`set -e` causes the script to exit as soon as any command exits with a
non-zero exit code. When pipes are used, this flag only applies to the
last command in a pipe. The `set -o pipefail` option ensures that the
script is also exited with a non-zero exit code when any command in the
pipe fails.
2018-06-20 15:29:03 +02:00
ExE Boss c0bf94f2eb chore: Fix the `\n` character preceding `echo` output in shell scripts (#136) 2018-06-20 00:33:12 +02:00
ExE Boss 80f4caf453 chore: Use `delete window.browser` in `setupTestDOMWindow` (#128)
This patch remove a workaround introduced in #2, because it has been fixed upstream and the workaround is not needed anymore (when using a nodejs version >= 8).
2018-06-19 23:36:50 +02:00
ExE Boss 3a6d76a88f chore: Cleaned up travis config (#129)
* Removed duplicate `sudo` entry in `.travis.yml`
* Rephrased log message while running cross-browsers integration tests.
2018-06-19 23:29:35 +02:00
Rob Wu 2537b23837 fix: add tabs.discard 2018-06-15 10:49:53 -07:00
Rob Wu 32863899bd style: alphabetically sort methods in tabs namespace 2018-06-15 10:49:53 -07:00
Rob Wu a3cb260c8e fix: Remove non-existing pageAction.getIcon
- Alphabetically sort keys
- Remove non-existing pageAction.getIcon
  (neither Firefox nor Chrome support this method).
2018-06-15 10:49:53 -07:00
Rob Wu e2754582c7 fix: Add missing management.setEnabled
setEnabled is partially implemented in Firefox:
- https://bugzil.la/1282982
- https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/management/setEnabled

The management API has many more methods in Chrome,
Firefox does not support them:
- createAppShortcut
- generateAppForLink
- getPermissionWarningsById
- getPermissionWarningsByManifest
- launchApp
- setLaunchType
- uninstall
2018-06-15 10:49:53 -07:00
Rob Wu 28377724ca style: alphabetically sort history keys 2018-06-15 10:49:53 -07:00
Rob Wu 597788817e fix: Fix downloads schemas
- Alphabetically sort keys
- Add `"fallbackToNoCallback": true` to `open` and `show`
  because these methods do currently not take any callbacks in Chrome:
  https://developer.chrome.com/extensions/downloads#method-open
  https://developer.chrome.com/extensions/downloads#method-show
- Chrome has a `downloads.acceptDanger` method, but Firefox does not,
  so this is not included in the schema.
2018-06-15 10:49:53 -07:00
Rob Wu fc25bd3e4c style: Alphabetically sort keys in contextMenus 2018-06-15 10:49:53 -07:00
Rob Wu 1981c59d94 fix: Add missing browserAction APIs (#99)
Note that the "openPopup" method is only available to the dev channel:
c2b078825a/chrome/common/extensions/api/_api_features.json (178)
https://crbug.com/436489
2018-06-15 10:49:53 -07:00
Rob Wu 5046a3f400 fix: Remove non-existing bookmarks.{export,import}
These APIs are not supported by Firefox:
https://searchfox.org/mozilla-central/rev/292d295d6b084b43b70de26a42e68513bb7b36a3/browser/components/extensions/schemas/bookmarks.json#436-465

In Chrome the APIs are not available either, except to some internal components:
b7963dca6a/chrome/common/extensions/api/_api_features.json (138)

Also moved "getTree" to ensure that the keys are alphabetically sorted.
2018-06-15 10:49:53 -07:00
Rob Wu 4a407da02c feat: Add topSites namespace to metadata
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/topSites#Browser_compatibility
2018-06-15 10:41:08 -07:00
Rob Wu 69e58761a5 feat: Add sessions namespace to metadata
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions#Browser_compatibility

Only `sessions.getRecentlyClosed` and `sessions.restore` are currently
supported by Firefox.

`sessions.getDevices` is included anyway since this method may be added
to Firefox in the future: https://bugzil.la/1308059
2018-06-15 10:41:08 -07:00
Rob Wu f086bc15ac feat: Add permissions namespace to metadata
https://searchfox.org/mozilla-central/rev/292d295d6b084b43b70de26a42e68513bb7b36a3/toolkit/components/extensions/schemas/permissions.json
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/permissions#Browser_compatibility
2018-06-15 10:41:08 -07:00
Rob Wu 9225b2a91b feat: Add browsingData namespace to metadata
The auto-generated output from the metadata generator also includes the
following methods from Chrome. Firefox does not support them, so they
were not included in the metadata:

```
    "removeAppcache": {
      "minArgs": 1,
      "maxArgs": 1
    },
    "removeFileSystems": {
      "minArgs": 1,
      "maxArgs": 1
    },
    "removeIndexedDB": {
      "minArgs": 1,
      "maxArgs": 1
    },
    "removeWebSQL": {
      "minArgs": 1,
      "maxArgs": 1
    },
```

Also see:
https://searchfox.org/mozilla-central/rev/292d295d6b084b43b70de26a42e68513bb7b36a3/browser/components/extensions/schemas/browsing_data.json
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/browsingData#Browser_compatibility
2018-06-15 10:41:08 -07:00
Luca Greco 5d186bae84 test(browsers-smoketests): Run a set of smoke tests on both Chrome and Firefox
This commit introduces tape as the test framework used to define the tests in the
test extension contexts and send them to the nodejs script that orchestrate the
test run.

The nodejs script has also been migrated from mocha to tape, it uses the custom test
helpers provided to setup the test environment (e.g. create a temporary dir
for the test extension, copy the last polyfill build, bundle tape to be used
in the test extension, start the browser which run the test extension
and finally collect the results of the test extension) and then it merges all the
tap logs collected from every test extension into a single "per browser" test suite.

- updated travis nodejs environment to nodejs 8
- uses tape to collect test results from inside the test extension
- added test case to check polyfill 'existing browser API object' detection
- added test for expected rejection on tabs.sendMessage with an invalid tabId
- added test with multiple listeners which resolves to undefined and null
- optionally run chrome smoketests with --enable-features=NativeCrxBindings
2018-06-02 20:59:46 +02:00
Luca Greco 6c8268f6fb feat: Reject sendMessage returned promise when a onMessage listener returns a rejected promise. 2018-06-02 20:59:46 +02:00
Luca Greco 831e355650 fix: print a deprecation warning when sendResponse callback is used for the first time 2018-06-02 20:59:46 +02:00
YFdyh000 314d2c6df7 chore: Always use LF for dist files (#67) 2018-05-31 16:19:46 +02:00
Luca Greco 76eeeaccc9
feat: Added support for the sendResponse callback in the runtime.onMessage listeners (#97) 2018-05-14 20:38:21 +02:00
Federico Brigante 6f9cfdf6cf chore(README): Drop reference to babel for async/await (#50) 2018-04-09 19:24:15 +02:00
Rob Wu bdb07e10cc chore: Added .gitattributes to force eol=lf to fix #101 (#103) 2018-04-09 15:44:30 +02:00
Luca Greco dd180a0907 chore(test): Fixed module bundlers tests on webpack 4 2018-04-09 15:13:35 +02:00
Rob Wu a7cbdcc23e fix: Use browser.storage.local in README (#87) (#90)
Applied fixed to all code snippets in README.md so that they are syntactically valid.
2018-03-19 15:42:40 +01:00
Luca Greco 0fd508671a test: Added smoke test for pageAction.show fallback to no callback on chrome. 2018-03-13 14:27:22 +01:00
Gerben 596f47bcc8 chore: Improve "fallback to no callback" wrapper.
According to review comment https://github.com/mozilla/webextension-polyfill/pull/59/files#r142001949
2018-03-13 14:27:22 +01:00
Luca Greco 917ed413f6 fix: Add a new fallbackToNoCallback metadata property to customize the pageAction.show/hide wrappers behavior 2018-03-13 14:27:22 +01:00
Megaman 0778db93ca fix: pageAction.show/hide should have 1 non-optional parameter in their metadata 2018-03-13 14:27:22 +01:00
Rob Wu 67b3780d38 fix: Lazily initialize API via the original target (#71)
Originally, the polyfill created a Proxy with the original API object as
the target. This was changed to `Object.create(chrome)` because not
doing so would prevent the `browser.devtools` API from working because
the devtools API object is assigned as a read-only & non-configurable
property (#57).

However, that action itself caused a new bug: Whenever an API object
is dereferenced via the `browser` namespace, the original API is no
longer available in the `chrome` namespace, and trying to access the
API through `chrome` returns `undefined` plus the "Previous API
instantiation failed" warning (#58).
This is because Chrome lazily initializes fields in the `chrome`
API, but on the object from which the property is accessed, while
the polyfill accessed the property through an object with the
prototype set to `chrome` instead of directly via chrome.

To fix that, `Object.create(chrome)` was replaced with
`Object.assign({}, chrome)`. This fixes both of the previous issues
because
1) It is still a new object.
2) All lazily initialized fields are explicitly initialized.

This fix created a new issue: In Chrome some APIs cannot be used even
though they are visible in the API (e.g. `chrome.clipboard`), so
calling `Object.assign({}, chrome)` causes an error to be printed to
the console (#70).

To solve this, I use `Object.create(chrome)` again as a proxy target,
but dereference the API via the original target (`chrome`) to not
regress on #58.
Besides fixing the bug, this also reduces the performance impact
of the API because all API fields are lazily initialized again,
instead of upon start-up.

This fixes #70.
2018-03-12 19:23:28 +01:00
Luca Greco 94efb908b8
fix: Pass --no-sandbox chrome CLI option when running the integration tests on travis (#85) 2018-01-09 17:49:56 +01:00
Sébastien Règne 13d0ced89e feat: add identity.launchWebAuthFlow() in metadata. (#39)
Provides the api metadata for the identity.launchWebAuthFlow API method (which fixes #80)
2018-01-09 16:27:33 +01:00
Luca Greco 49ce6ef155 test: Run a minimal set of tests from a test extension running on Chrome (#66)
* test: Run a minimal set of integration/smoke tests on Chrome
* chore: minor tweaks to dependencies version in the package.json
2017-10-23 19:42:01 +02:00
Luca Greco 8914541b81 chore: bump version for release 0.2.1 2017-10-12 14:23:39 +02:00
Luca Greco 47ddfbfddb fix: Prevent 'Previous API instantiation failed' errors on runtime.sendMessage API calls (#64) 2017-10-11 15:51:43 +02:00
Andy McKay 09d05cc073 Merge pull request #62 from tiagomoraismorgado88/patch-1
introducing table of contents
2017-10-06 10:36:37 -07:00
tmm88 390ccbf8b6 introducing table of contents
# Greetings

**the current PR does basically aim at:**
- *introducing table of contents*

---

**the motivation behind such a thing is basically to:**
- *improve accessability of the file*
2017-10-01 11:47:50 +01:00
Luca Greco 318271214f chore: bump version for release 0.2.0 2017-09-29 23:43:59 +02:00
Luca Greco 61d92ea79b feat: Added devtools.inspectedWindow.eval and devtools.panels.create to wrapped APIs.
To be able to wrap the devtools API namespaces, this patch applies the
following changes:

- fix: Prevent Proxy violation exception on the read-only/non-configurable devtools property
  by using an empty object with the `chrome` API object as its prototype
  as the root Proxy target (the Proxy instances returned for the
  `chrome` API object) and add a related test case.

- fix: Added support for a new `singleCallbackArg` metadata property,
  which prevents devtools.panels.create to resolve an array of
  parameters (See the related Chromium issue at
  https://bugs.chromium.org/p/chromium/issues/detail?id=768159)
  and add the related test cases.

- test: Changes to the test case related to proxy getter/setter behavior
  on non wrapped properties:

  in the "deletes proxy getter/setter that are not wrapped" test case from
  the "test-proxied-properties.js" test file, we ensure that when a
  getter/setter is called for a "non-wrapped" property, the getter/setter
  is going to affect the original target object, unfortunately this in
  not true anymore for the root object (the `chrome` API object) because
  we are using an empty object (which has the `chrome` API object as its
  prototype and it is not exposed outside of the polyfill sources)
  as the target of the Proxy instance related to it,
  this change to the target of the Proxy has been needed to prevent the
  TypeError exception raised by the Proxy instance when we try to access
  the "devtools" property (which is non-configurable and read-only on the
  `chrome` API object).
2017-09-25 22:20:07 +02:00
Luca Greco 6b3c6da659 chore: bump version for release 0.1.2 2017-09-25 20:42:56 +02:00