Bug 1250266 - Always send a TTL in the Push mochitests. r=benbangert

MozReview-Commit-ID: 4hoBveTY2pE

--HG--
extra : rebase_source : a1728e6b23c5852d1ca2977fb9d150891568791d
This commit is contained in:
Kit Cambridge 2016-02-22 11:54:54 -08:00
Родитель ff6fdbef17
Коммит 10df43f248
5 изменённых файлов: 21 добавлений и 10 удалений

Просмотреть файл

@ -39,14 +39,21 @@ function handleRequest(request, response)
data.push(bodyStream.readByteArray(available));
size += available;
}
xhr.send(concatUint8Arrays(data, size));
function reply(statusCode, statusText) {
response.setStatusLine(request.httpVersion, statusCode, statusText);
response.finish();
}
xhr.onload = function(e) {
debug("xhr : " + this.status);
}
reply(this.status, this.statusText);
};
xhr.onerror = function(e) {
debug("xhr error: " + e);
}
reply(500, "Internal Server Error");
};
response.setStatusLine(request.httpVersion, "200", "OK");
response.processAsync();
xhr.send(concatUint8Arrays(data, size));
}

Просмотреть файл

@ -107,7 +107,7 @@ http://creativecommons.org/licenses/publicdomain/
function waitForMessage(pushSubscription, message) {
return Promise.all([
controlledFrame.waitOnWorkerMessage("finished"),
webpush(pushSubscription, message),
webpush(pushSubscription, message, 120),
]).then(([message]) => message);
}
@ -167,6 +167,7 @@ http://creativecommons.org/licenses/publicdomain/
headers: {
"X-Push-Method": "POST",
"X-Push-Server": pushSubscription.endpoint,
"TTL": "120",
},
}),
]);

Просмотреть файл

@ -71,6 +71,7 @@ http://creativecommons.org/licenses/publicdomain/
headers: {
"X-Push-Method": "POST",
"X-Push-Server": pushSubscription.endpoint,
"TTL": "120",
},
}),
]);

Просмотреть файл

@ -75,9 +75,10 @@
// Work around CORS for now.
var xhr = new XMLHttpRequest();
xhr.open('GET', "http://mochi.test:8888/tests/dom/push/test/push-server.sjs", true);
xhr.setRequestHeader("X-Push-Method", "PUT");
xhr.setRequestHeader("X-Push-Method", "POST");
xhr.setRequestHeader("X-Push-Server", pushEndpoint);
xhr.send("version=24601");
xhr.setRequestHeader("TTL", "120");
xhr.send(null);
}
function unregisterPushNotification(ctx) {

Просмотреть файл

@ -169,7 +169,7 @@
* parameters.
* @param data The message to send.
*/
function webpush(subscription, data) {
function webpush(subscription, data, ttl) {
data = ensureView(data);
var salt = g.crypto.getRandomValues(new Uint8Array(16));
@ -189,13 +189,14 @@
'X-Push-Method': 'POST',
'Encryption-Key': 'keyid=p256dh;dh=' + base64url.encode(pubkey),
Encryption: 'keyid=p256dh;salt=' + base64url.encode(salt),
'Content-Encoding': 'aesgcm128'
'Content-Encoding': 'aesgcm128',
'TTL': ttl,
},
body: payload,
};
return fetch('http://mochi.test:8888/tests/dom/push/test/push-server.sjs', options);
}).then(response => {
if (response.status / 100 !== 2) {
if (Math.floor(response.status / 100) !== 2) {
throw new Error('Unable to deliver message');
}
return response;