mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1250266 - Always send a TTL in the Push mochitests. r=benbangert
MozReview-Commit-ID: 4hoBveTY2pE
This commit is contained in:
parent
1b3b1cb7d0
commit
95ab483d20
@ -39,14 +39,21 @@ function handleRequest(request, response)
|
|||||||
data.push(bodyStream.readByteArray(available));
|
data.push(bodyStream.readByteArray(available));
|
||||||
size += available;
|
size += available;
|
||||||
}
|
}
|
||||||
xhr.send(concatUint8Arrays(data, size));
|
|
||||||
|
function reply(statusCode, statusText) {
|
||||||
|
response.setStatusLine(request.httpVersion, statusCode, statusText);
|
||||||
|
response.finish();
|
||||||
|
}
|
||||||
|
|
||||||
xhr.onload = function(e) {
|
xhr.onload = function(e) {
|
||||||
debug("xhr : " + this.status);
|
debug("xhr : " + this.status);
|
||||||
}
|
reply(this.status, this.statusText);
|
||||||
|
};
|
||||||
xhr.onerror = function(e) {
|
xhr.onerror = function(e) {
|
||||||
debug("xhr error: " + 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) {
|
function waitForMessage(pushSubscription, message) {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
controlledFrame.waitOnWorkerMessage("finished"),
|
controlledFrame.waitOnWorkerMessage("finished"),
|
||||||
webpush(pushSubscription, message),
|
webpush(pushSubscription, message, 120),
|
||||||
]).then(([message]) => message);
|
]).then(([message]) => message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +167,7 @@ http://creativecommons.org/licenses/publicdomain/
|
|||||||
headers: {
|
headers: {
|
||||||
"X-Push-Method": "POST",
|
"X-Push-Method": "POST",
|
||||||
"X-Push-Server": pushSubscription.endpoint,
|
"X-Push-Server": pushSubscription.endpoint,
|
||||||
|
"TTL": "120",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
@ -71,6 +71,7 @@ http://creativecommons.org/licenses/publicdomain/
|
|||||||
headers: {
|
headers: {
|
||||||
"X-Push-Method": "POST",
|
"X-Push-Method": "POST",
|
||||||
"X-Push-Server": pushSubscription.endpoint,
|
"X-Push-Server": pushSubscription.endpoint,
|
||||||
|
"TTL": "120",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
@ -75,9 +75,10 @@
|
|||||||
// Work around CORS for now.
|
// Work around CORS for now.
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', "http://mochi.test:8888/tests/dom/push/test/push-server.sjs", true);
|
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.setRequestHeader("X-Push-Server", pushEndpoint);
|
||||||
xhr.send("version=24601");
|
xhr.setRequestHeader("TTL", "120");
|
||||||
|
xhr.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unregisterPushNotification(ctx) {
|
function unregisterPushNotification(ctx) {
|
||||||
|
@ -169,7 +169,7 @@
|
|||||||
* parameters.
|
* parameters.
|
||||||
* @param data The message to send.
|
* @param data The message to send.
|
||||||
*/
|
*/
|
||||||
function webpush(subscription, data) {
|
function webpush(subscription, data, ttl) {
|
||||||
data = ensureView(data);
|
data = ensureView(data);
|
||||||
|
|
||||||
var salt = g.crypto.getRandomValues(new Uint8Array(16));
|
var salt = g.crypto.getRandomValues(new Uint8Array(16));
|
||||||
@ -189,13 +189,14 @@
|
|||||||
'X-Push-Method': 'POST',
|
'X-Push-Method': 'POST',
|
||||||
'Encryption-Key': 'keyid=p256dh;dh=' + base64url.encode(pubkey),
|
'Encryption-Key': 'keyid=p256dh;dh=' + base64url.encode(pubkey),
|
||||||
Encryption: 'keyid=p256dh;salt=' + base64url.encode(salt),
|
Encryption: 'keyid=p256dh;salt=' + base64url.encode(salt),
|
||||||
'Content-Encoding': 'aesgcm128'
|
'Content-Encoding': 'aesgcm128',
|
||||||
|
'TTL': ttl,
|
||||||
},
|
},
|
||||||
body: payload,
|
body: payload,
|
||||||
};
|
};
|
||||||
return fetch('http://mochi.test:8888/tests/dom/push/test/push-server.sjs', options);
|
return fetch('http://mochi.test:8888/tests/dom/push/test/push-server.sjs', options);
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.status / 100 !== 2) {
|
if (Math.floor(response.status / 100) !== 2) {
|
||||||
throw new Error('Unable to deliver message');
|
throw new Error('Unable to deliver message');
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
Loading…
Reference in New Issue
Block a user