Skip to content

Commit 36c55ad

Browse files
committed
Merge pull request #132 from marco-c/update_selenium_webdriver
Update selenium webdriver
2 parents bc2bdc0 + 610e275 commit 36c55ad

File tree

5 files changed

+158
-241
lines changed

5 files changed

+158
-241
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ env:
77
- MOZ_XVFB=$(if [[ $TRAVIS_OS_NAME == "linux" ]]; then echo 1; fi)
88
matrix:
99
- NODE_VERSION="0.12"
10-
- NODE_VERSION="4" FIREFOX="all" CHROME="nightly"
11-
- NODE_VERSION="stable" FIREFOX="all" CHROME="nightly"
10+
- NODE_VERSION="4" CHROME="nightly"
11+
- NODE_VERSION="stable" CHROME="nightly"
1212
before_install:
1313
- rm -rf ~/.nvm
1414
- git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Supports Firefox 44+ and Chromium/Chrome 42+.
55
Notifications with payloads are supported in Firefox 44+ and Chromium/Chrome 50+.
6-
[VAPID](https://tools.ietf.org/html/draft-thomson-webpush-vapid-02) is supported in Firefox 45+ (for notifications without payloads) and in Firefox 46+ for all notifications.
6+
[VAPID](https://tools.ietf.org/html/draft-thomson-webpush-vapid-02) is supported in Firefox 45+ (for notifications without payloads).
77

88
[![NPM](https://nodei.co/npm/web-push.svg?downloads=true)](https://www.npmjs.com/package/web-push)
99

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"mocha": "^2.4.5",
4040
"portfinder": "^1.0.2",
4141
"request": "^2.69.0",
42-
"selenium-webdriver": "2.52.0",
42+
"selenium-webdriver": "^2.53.1",
4343
"semver": "^5.1.0",
4444
"temp": "^0.8.3"
4545
}

test/server.js

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var options = {
1818
cert: pem,
1919
};
2020

21-
function createServer(pushPayload, pushTimeout, vapid) {
21+
function createServer(pushPayload, vapid) {
2222
var server = https.createServer(options, function(req, res) {
2323
if (req.method === 'GET') {
2424
if (req.url === '/') {
@@ -51,40 +51,30 @@ function createServer(pushPayload, pushTimeout, vapid) {
5151

5252
console.log('Push Application Server - Register: ' + obj.endpoint);
5353

54-
server.clientRegistered = true;
55-
if (server.onClientRegistered && server.onClientRegistered()) {
56-
return;
57-
}
54+
console.log('Push Application Server - Send notification to ' + obj.endpoint);
5855

59-
setTimeout(function() {
60-
console.log('Push Application Server - Send notification to ' + obj.endpoint);
61-
62-
var promise;
63-
if (!pushPayload) {
64-
promise = webPush.sendNotification(obj.endpoint, {
65-
TTL: pushTimeout ? 200 : undefined,
66-
vapid: vapid,
67-
});
68-
} else {
69-
promise = webPush.sendNotification(obj.endpoint, {
70-
TTL: pushTimeout ? 200 : undefined,
71-
payload: pushPayload,
72-
userPublicKey: obj.key,
73-
userAuth: obj.auth,
74-
vapid: vapid,
75-
});
76-
}
77-
78-
promise
79-
.then(function() {
80-
console.log('Push Application Server - Notification sent to ' + obj.endpoint);
81-
82-
server.notificationSent = true;
83-
if (server.onNotificationSent) {
84-
server.onNotificationSent();
85-
}
56+
var promise;
57+
if (!pushPayload) {
58+
promise = webPush.sendNotification(obj.endpoint, {
59+
vapid: vapid,
60+
});
61+
} else {
62+
promise = webPush.sendNotification(obj.endpoint, {
63+
payload: pushPayload,
64+
userPublicKey: obj.key,
65+
userAuth: obj.auth,
66+
vapid: vapid,
8667
});
87-
}, pushTimeout * 1000);
68+
}
69+
70+
promise
71+
.then(function() {
72+
console.log('Push Application Server - Notification sent to ' + obj.endpoint);
73+
})
74+
.catch(function(error) {
75+
console.log('Push Application Server - Error in sending notification to ' + obj.endpoint);
76+
console.log(error);
77+
})
8878
});
8979

9080
res.writeHead(200, {
@@ -106,9 +96,6 @@ function createServer(pushPayload, pushTimeout, vapid) {
10696
server.listen(server.port);
10797
});
10898

109-
server.notificationSent = false;
110-
server.clientRegistered = false;
111-
11299
return new Promise(function(resolve, reject) {
113100
server.on('listening', function() {
114101
resolve(server);

0 commit comments

Comments
 (0)