Commit Graph

57 Commits

Author SHA1 Message Date
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
Federico Brigante ab01b9605b docs: Added build status badge to the README.md (#45) 2017-08-20 13:35:53 +02:00
Federico Brigante 9468773ffe fix: Limit eslint to the project's own rules (#46) 2017-08-20 13:33:56 +02:00
Rob Wu ab0b667ff3 fix: Lock gruntify-eslint version to fix build errors (#42)
* Lock version of gruntify-eslint (and grunt-replace)

The current repository is compatible with gruntify-eslint 3.1.0.
`*` resolves to version 4.0.0., which bumps its eslint dependency
from 3.x to 4.x, which in turn causes linting errors.

To get the default check-out to pass, lock the dependencies to
known-compatible versions.

* Bump gruntify-eslint to 4.0.0 + fix lint error

Bump gruntify-eslint to 4.0.0, which depends on eslint ^4.0.0,
and fix the lint error that appeared.
2017-08-20 13:26:43 +02:00
Luca Greco a1fd64cab1 chore: bump version for release 0.1.1 2017-04-13 15:02:56 +02:00
Luca Greco c5fd6fdf41 chore: Publish tagged releases to npm from travis job 2017-04-13 14:48:04 +02:00
Luca Greco a34f9c71f8 test: run tests for the webpack and browserify bundled files on travis 2017-04-13 14:30:52 +02:00
Luca Greco 46b8f7e583 fix: use babel and transform-es2015-modules-umd to fix the webpack bundling issue 2017-04-13 14:30:52 +02:00
Luca Greco 96cfb9c5c2 test: re-run the test suite on the minified file on travis 2017-04-11 14:24:23 +02:00
Luca Greco 9a38d923e9 fix: use babili to minify ES6 sources. 2017-04-11 14:19:56 +02:00
Luca Greco 31d778c2cd fix: Changes to the UMD built file and npm package publishing
This patch introduces on top of #17 some minor changes from the
review comments, in particular:

- do not replace require("../filename") to include the api-metadata.json
  (restored the original '{/* include("...") */}' placeholder)
- raise an appropriate error message when the source file is used
  by mistake (or the "dist/" file has not been built correctly).
- set the generated UMD wrapped module as the package.json main
  entrypoint
- do not include api-metadata.json and src dir from the files included
  in the published npm package
- run both build and test npm scripts on prepublish
2017-04-11 14:16:15 +02:00
Joseph Frazier f9248e62e7 feat: library wrapped as an UMD module
This addresses [issue 7] by making it possible for users to run:

```sh
npm install webextension-polyfill
```

and download a module that they can use with a bundler as follows:

```js
import browser from 'webextension-polyfill';
```

Also, add a [prepublish script] so that users who clone the repo don't
need to run `grunt` manually. In addition, specify [files] in
package.json so that this module can be published to npm without
including miscellanea. This can be verified by running:

```sh
npm pack && tar -tvf webextension-polyfill-0.1.0.tgz
```

[issue 7]: https://github.com/mozilla/webextension-polyfill/issues/7
[files]: https://docs.npmjs.com/files/package.json#files
[prepublish script]: https://docs.npmjs.com/misc/scripts
2017-04-11 13:32:31 +02:00
Joseph Frazier 52791c8633 fix: normalized package.json properties
When running `npm install` to add new `devDependencies`, `npm` reformats
package.json with these changes, as can be seen [here]. Making these
changes separately allows developers to more easily keep them out of
unrelated commits.

[here]: https://github.com/mozilla/webextension-polyfill/pull/11/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2L22
2017-04-11 13:32:02 +02:00
Luca Greco 77af627d05 Merge pull request #6 from rpl/fix/reduce-ircbot-verbosity
fix: reduced travis irc message verbosity.
2016-11-14 22:41:48 +01:00
Luca Greco 27b71c2e2a fix: reduced travis irc message verbosity. 2016-11-14 22:34:17 +01:00
Luca Greco df71efea17 test: introduced a test suite for unit testing.
Merge pull request #2 from rpl/proposal/unit-testing
2016-11-14 19:20:38 +01:00
Luca Greco d1b0ff929a fix: rename polyfill source into src/browser-polyfill.js 2016-11-07 16:56:48 +01:00
Luca Greco e19cf82332 fix: indentation missed by eslint 2016-11-07 16:34:34 +01:00
Luca Greco 573c438c23 fix: change notified irc channel 2016-11-07 16:34:34 +01:00
Luca Greco 9a04fc3876 fix: pluralize argument in raised error message 2016-11-07 16:34:34 +01:00
Luca Greco 705e93bc2f test: added test case to check that different listeners are wrapped by different wrappers 2016-11-07 16:34:34 +01:00
Luca Greco b28d3d9d74 fix: fixed typos and nits in tests. 2016-11-07 16:34:34 +01:00
Luca Greco 6486e551be fix: bulk fix call expression params indentation using eslint 2016-11-07 16:34:34 +01:00
Luca Greco de50f2047d test: update eslint to version 3.9.1 and add enforced indentation on call expression params 2016-11-07 16:34:34 +01:00
Luca Greco 0517edaa67 fix: refactor runtime.onMessage tests. 2016-11-07 16:34:34 +01:00
Luca Greco 3842bd1693 style: destructure the assert methods to globals 2016-11-07 16:34:34 +01:00
Luca Greco 2853e98546 fix: the test jsdom window doesn't need to be in the shared global. 2016-11-07 16:34:34 +01:00
Luca Greco 6cca044a5c test: add more test cases to reach a full code coverage.
- if the a browser global already exists, it should not be overridden
- use Object.defineProperty on the wrapped browser global
  (and test "has" for cached properties)
- delete a property defined with Object.defineProperty
- methods that are not wrapped are proxied correctly
- the special onMessage wrapper should not wrap a listener that is not
  a function
- test that a returned rejected Promise on the onMessage listener
  is turned in the parameter of the sendResponse callback
2016-11-07 16:34:34 +01:00
Luca Greco 92ccea2e15 test: tweaks on test helpers (support for 'existent browser global' test). 2016-11-07 16:34:34 +01:00
Luca Greco a585b4b07a test: added test case for async function rejection, and arguments length validation. 2016-11-07 16:34:34 +01:00
Luca Greco 7a247f56f2 test: tweak the proxied properties tests. 2016-11-07 16:34:34 +01:00
Luca Greco a1469d6f17 fix: added inline comments to special runtime.onMessage wrapper tests. 2016-11-07 16:34:34 +01:00
Luca Greco f28858961f fix: cleanup async function tests and other minor tweaks on tests. 2016-11-07 16:34:34 +01:00
Luca Greco b0a111cdc7 fix: init fake runtime.lastError to null. 2016-11-07 16:34:34 +01:00
Luca Greco 88e3728c46 fix: removed unused import in test file. 2016-11-07 16:34:34 +01:00
Luca Greco aaca860c2d fix: cleanup tests setup function. 2016-11-07 16:34:34 +01:00
Luca Greco f2c82fcbea fix: relax max-nested-callback eslint rules for tests. 2016-11-07 16:34:34 +01:00