зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1253831 - Don't check actual intervals in the Push backoff test. r=wchen
MozReview-Commit-ID: CUESwtv58LJ --HG-- extra : rebase_source : 600b8baeeea6334726c88bf1cba64b2d5635c405
This commit is contained in:
Родитель
3836b7c35b
Коммит
8943858ebf
|
@ -170,11 +170,6 @@ this.PushServiceWebSocket = {
|
||||||
|
|
||||||
if (timer == this._backoffTimer) {
|
if (timer == this._backoffTimer) {
|
||||||
console.debug("onTimerFired: Reconnecting after backoff");
|
console.debug("onTimerFired: Reconnecting after backoff");
|
||||||
if (this._reconnectTestCallback) {
|
|
||||||
// Notify the test callback once the client reconnects.
|
|
||||||
let actualRetryTimeout = Date.now() - this._lastDisconnect;
|
|
||||||
this._reconnectTestCallback(actualRetryTimeout);
|
|
||||||
}
|
|
||||||
this._beginWSSetup();
|
this._beginWSSetup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -331,9 +326,6 @@ this.PushServiceWebSocket = {
|
||||||
*/
|
*/
|
||||||
_lastPingTime: 0,
|
_lastPingTime: 0,
|
||||||
|
|
||||||
/** The last time the connection was closed. */
|
|
||||||
_lastDisconnect: 0,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A one-shot timer used to ping the server, to avoid timing out idle
|
* A one-shot timer used to ping the server, to avoid timing out idle
|
||||||
* connections. Reset to the ping interval on each incoming message.
|
* connections. Reset to the ping interval on each incoming message.
|
||||||
|
@ -343,15 +335,6 @@ this.PushServiceWebSocket = {
|
||||||
/** A one-shot timer fired after the reconnect backoff period. */
|
/** A one-shot timer fired after the reconnect backoff period. */
|
||||||
_backoffTimer: null,
|
_backoffTimer: null,
|
||||||
|
|
||||||
/**
|
|
||||||
* A function called when the client reconnects after backing off.
|
|
||||||
*
|
|
||||||
* @param {Number} actualRetryTimeout The time elapsed between the last
|
|
||||||
* disconnect and reconnect time. This should be >= the backoff delay for
|
|
||||||
* that attempt.
|
|
||||||
*/
|
|
||||||
_reconnectTestCallback: null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the Push Server through an open websocket.
|
* Sends a message to the Push Server through an open websocket.
|
||||||
* typeof(msg) shall be an object
|
* typeof(msg) shall be an object
|
||||||
|
@ -434,8 +417,6 @@ this.PushServiceWebSocket = {
|
||||||
this._notifyRequestQueue();
|
this._notifyRequestQueue();
|
||||||
this._notifyRequestQueue = null;
|
this._notifyRequestQueue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._lastDisconnect = Date.now();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
uninit: function() {
|
uninit: function() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ function run_test() {
|
||||||
do_get_profile();
|
do_get_profile();
|
||||||
setPrefs({
|
setPrefs({
|
||||||
userAgentID: userAgentID,
|
userAgentID: userAgentID,
|
||||||
pingInterval: 10000,
|
pingInterval: 2000,
|
||||||
retryBaseInterval: 25,
|
retryBaseInterval: 25,
|
||||||
});
|
});
|
||||||
run_next_test();
|
run_next_test();
|
||||||
|
@ -30,9 +30,17 @@ add_task(function* test_ws_retry() {
|
||||||
quota: Infinity,
|
quota: Infinity,
|
||||||
});
|
});
|
||||||
|
|
||||||
let alarmDelays = [];
|
// Use a mock timer to avoid waiting for the backoff interval.
|
||||||
PushServiceWebSocket._reconnectTestCallback = function(delay) {
|
let reconnects = 0;
|
||||||
alarmDelays.push(delay);
|
PushServiceWebSocket._backoffTimer = {
|
||||||
|
init(observer, delay, type) {
|
||||||
|
reconnects++;
|
||||||
|
ok(delay >= 5 && delay <= 2000, `Backoff delay ${
|
||||||
|
delay} out of range for attempt ${reconnects}`);
|
||||||
|
observer.observe(this, "timer-callback", null);
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
let handshakeDone;
|
let handshakeDone;
|
||||||
|
@ -43,7 +51,7 @@ add_task(function* test_ws_retry() {
|
||||||
makeWebSocket(uri) {
|
makeWebSocket(uri) {
|
||||||
return new MockWebSocket(uri, {
|
return new MockWebSocket(uri, {
|
||||||
onHello(request) {
|
onHello(request) {
|
||||||
if (alarmDelays.length == 10) {
|
if (reconnects == 10) {
|
||||||
this.serverSendMsg(JSON.stringify({
|
this.serverSendMsg(JSON.stringify({
|
||||||
messageType: 'hello',
|
messageType: 'hello',
|
||||||
status: 200,
|
status: 200,
|
||||||
|
@ -59,8 +67,4 @@ add_task(function* test_ws_retry() {
|
||||||
});
|
});
|
||||||
|
|
||||||
yield handshakePromise;
|
yield handshakePromise;
|
||||||
[25, 50, 100, 200, 400, 800, 1600, 3200, 6400, 10000].forEach(function(minDelay, index) {
|
|
||||||
ok(alarmDelays[index] >= minDelay, `Should wait at least ${
|
|
||||||
minDelay}ms before attempt ${index + 1}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче