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.
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).
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
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.
# 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*
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).
* 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.