Skip to content

Commit b4b40ee

Browse files
committed
Merge pull request #150 from eoger/node-0.10-upstream
Add support for Node 0.10
2 parents 8432ceb + 5334da3 commit b4b40ee

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ env:
66
- DISPLAY=$(if [[ $TRAVIS_OS_NAME == "linux" ]]; then echo ':99.0'; fi)
77
- MOZ_XVFB=$(if [[ $TRAVIS_OS_NAME == "linux" ]]; then echo 1; fi)
88
matrix:
9+
- NODE_VERSION="0.10"
910
- NODE_VERSION="0.12"
1011
- NODE_VERSION="4"
1112
- NODE_VERSION="stable"
@@ -16,6 +17,8 @@ before_install:
1617
- nvm install $NODE_VERSION
1718
- export NODE=$(nvm which $NODE_VERSION)
1819
- export NPM=${NODE%node}npm
20+
- wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
21+
- java -jar selenium-server-standalone-2.53.0.jar &> /dev/null &
1922
install:
2023
- $NPM install
2124
- $NPM install mocha

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ The [Service Worker Cookbook](https://serviceworke.rs/) is full of Web Push exam
6161

6262
## Running tests
6363

64+
#### Prerequisites:
65+
* Java JDK or JRE (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
66+
* Selenium Server 2.53.0 ([Download](http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar))
67+
68+
### Setup
69+
70+
* Run Selenium Server
71+
72+
e.g. in shell form:
73+
74+
```sh
75+
java -jar selenium-server-standalone-2.53.0.jar
76+
```
77+
78+
To run tests locally with Selenium:
79+
80+
```sh
81+
npm test
82+
```
83+
6484
Selenium tests require Firefox or Chromium/Chrome. You can either use your installed versions or let the tests download the browsers for you.
6585

6686
```

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const https = require('https');
66
const colors = require('colors');
77
const asn1 = require('asn1.js');
88
const jws = require('jws');
9+
require('./shim');
910

1011
var ECPrivateKeyASN = asn1.define('ECPrivateKey', function() {
1112
this.seq().obj(

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@
2525
},
2626
"homepage": "https://github.com/marco-c/web-push#readme",
2727
"dependencies": {
28+
"array.prototype.find": "^2.0.0",
2829
"asn1.js": "^4.5.2",
30+
"bluebird": "^3.3.5",
31+
"buffer-compare-shim": "^1.0.0",
32+
"buffer-equals-polyfill": "^1.0.0",
2933
"colors": "^1.1.2",
30-
"http_ece": "^0.5.0",
34+
"create-ecdh": "^4.0.0",
35+
"http_ece": "^0.5.1",
3136
"jws": "^3.1.3",
3237
"minimist": "^1.2.0",
38+
"semver": "^5.1.0",
3339
"urlsafe-base64": "^1.0.0"
3440
},
3541
"devDependencies": {
@@ -40,14 +46,14 @@
4046
"mocha": "^2.4.5",
4147
"portfinder": "^1.0.2",
4248
"request": "^2.69.0",
43-
"selenium-webdriver": "^2.53.1",
49+
"selenium-webdriver": "~2.47.0",
4450
"semver": "^5.1.0",
4551
"temp": "^0.8.3"
4652
},
4753
"bin": {
4854
"web-push": "bin/web-push.js"
4955
},
5056
"engines": {
51-
"node": ">= v4.0.0"
57+
"node": ">= v0.10.0"
5258
}
5359
}

shim.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var semver = require('semver');
2+
if (semver.satisfies(process.version, '>= 0.12.0')) {
3+
return;
4+
}
5+
6+
global.Promise = require('bluebird');
7+
require('array.prototype.find').shim();
8+
require('buffer-compare-shim');
9+
require('buffer-equals-polyfill');
10+
require('crypto').createECDH = require('create-ecdh');

test/testSelenium.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ if (!process.env.VAPID_PRIVATE_KEY || !process.env.VAPID_PUBLIC_KEY) {
2525
process.env.PATH = process.env.PATH + ':test_tools/';
2626

2727
suite('selenium', function() {
28-
if (semver.satisfies(process.version, '0.12')) {
29-
console.log('selenium-webdriver is incompatible with Node.js v0.12');
30-
return;
31-
}
32-
3328
var webdriver = require('selenium-webdriver');
3429
var firefox = require('selenium-webdriver/firefox');
3530
var chrome = require('selenium-webdriver/chrome');
@@ -52,6 +47,13 @@ suite('selenium', function() {
5247
process.env.SELENIUM_MARIONETTE = true;
5348
}
5449

50+
if (firefoxBinaryPath) {
51+
firefoxBinaryPath = path.resolve(firefoxBinaryPath);
52+
}
53+
if (chromeBinaryPath) {
54+
chromeBinaryPath = path.resolve(chromeBinaryPath);
55+
}
56+
5557
process.env.SELENIUM_BROWSER = params.browser;
5658

5759
return createServer(params.payload, params.vapid)
@@ -80,6 +82,9 @@ suite('selenium', function() {
8082
.forBrowser('firefox')
8183
.setFirefoxOptions(firefoxOptions)
8284
.setChromeOptions(chromeOptions);
85+
if (params.browser !== "chrome") {
86+
builder.usingServer('http://localhost:4444/wd/hub');
87+
}
8388
driver = builder.build();
8489

8590
driver.executeScript(function(port) {
@@ -178,7 +183,7 @@ suite('selenium', function() {
178183

179184
teardown(function(done) {
180185
driver.quit()
181-
.catch(function() {})
186+
.thenCatch(function() {})
182187
.then(function() {
183188
server.close(function() {
184189
done();

0 commit comments

Comments
 (0)