Skip to content

Commit fa55543

Browse files
committed
Simplify test by removing serverAddress (no longer needed, since there's a single server now)
1 parent 4be0599 commit fa55543

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

test/index.html

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,42 @@
1313
});
1414
}
1515

16-
var serverAddress;
16+
navigator.serviceWorker.ready
17+
.then(function(reg) {
18+
var channel = new MessageChannel();
19+
channel.port1.onmessage = function(e) {
20+
window.document.title = e.data;
21+
}
22+
reg.active.postMessage('setup', [channel.port2]);
1723

18-
function go() {
19-
navigator.serviceWorker.ready
20-
.then(function(reg) {
21-
var channel = new MessageChannel();
22-
channel.port1.onmessage = function(e) {
23-
window.document.title = e.data;
24-
}
25-
reg.active.postMessage('setup', [channel.port2]);
26-
27-
return reg.pushManager.getSubscription()
28-
.then(function(subscription) {
29-
if (!subscription) {
30-
return reg.pushManager.subscribe({ userVisibleOnly: true })
31-
.then(function(subscription) {
32-
return subscription;
33-
});
34-
} else {
35-
return subscription;
36-
}
37-
});
38-
})
24+
return reg.pushManager.getSubscription()
3925
.then(function(subscription) {
40-
var key = subscription.getKey ? subscription.getKey('p256dh') : '';
41-
var auth = subscription.getKey ? subscription.getKey('auth') : '';
26+
if (!subscription) {
27+
return reg.pushManager.subscribe({ userVisibleOnly: true })
28+
.then(function(subscription) {
29+
return subscription;
30+
});
31+
} else {
32+
return subscription;
33+
}
34+
});
35+
})
36+
.then(function(subscription) {
37+
var key = subscription.getKey ? subscription.getKey('p256dh') : '';
38+
var auth = subscription.getKey ? subscription.getKey('auth') : '';
4239

43-
return fetch(serverAddress, {
44-
method: 'post',
45-
headers: {
46-
'Content-type': 'application/json'
47-
},
48-
body: JSON.stringify({
49-
endpoint: subscription.endpoint,
50-
key: key ? btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : '',
51-
auth: auth ? btoa(String.fromCharCode.apply(null, new Uint8Array(auth))) : '',
52-
}),
53-
});
40+
return fetch('/', {
41+
method: 'post',
42+
headers: {
43+
'Content-type': 'application/json'
44+
},
45+
body: JSON.stringify({
46+
endpoint: subscription.endpoint,
47+
key: key ? btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : '',
48+
auth: auth ? btoa(String.fromCharCode.apply(null, new Uint8Array(auth))) : '',
49+
}),
5450
});
55-
}
51+
});
5652
</script>
5753
</body>
5854
</html>

test/testSelenium.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ suite('selenium', function() {
9696

9797
driver.get('http://127.0.0.1:' + server.port);
9898

99-
driver.executeScript(function(port) {
100-
serverAddress = 'http://127.0.0.1:' + port;
101-
go();
102-
}, server.port);
103-
10499
return driver.wait(webdriver.until.titleIs(params.payload ? params.payload : 'no payload'), 60000);
105100
});
106101
}

0 commit comments

Comments
 (0)