Bug 1524655 - Remove dom.push.alwaysConnect and connect unconditionally. r=jrconlin,pjenvey

Also, remove a test that's no longer relevant, since we don't need to
fetch all subscriptions at startup.

Differential Revision: https://phabricator.services.mozilla.com/D20085

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lina Cambridge 2019-03-14 04:22:18 +00:00
parent 870c830c5a
commit 84764d6a93
7 changed files with 12 additions and 90 deletions

View File

@ -217,7 +217,6 @@ var PushService = {
this._service.disconnect();
}
let records = await this.getAllUnexpired();
let broadcastListeners = await pushBroadcastService.getListeners();
// In principle, a listener could be added to the
@ -230,13 +229,7 @@ var PushService = {
// getListeners.
this._setState(PUSH_SERVICE_RUNNING);
if (records.length > 0 || prefs.get("alwaysConnect")) {
// Connect if we have existing subscriptions, or if the always-on pref
// is set. We gate on the pref to let us do load testing before
// turning it on for everyone, but if the user has push
// subscriptions, we need to connect them anyhow.
this._service.connect(records, broadcastListeners);
}
this._service.connect(broadcastListeners);
},
_changeStateConnectionEnabledEvent: function(enabled) {
@ -297,7 +290,7 @@ var PushService = {
CHANGING_SERVICE_EVENT)
);
} else if (aData == "dom.push.connection.enabled" || aData == "dom.push.alwaysConnect") {
} else if (aData == "dom.push.connection.enabled") {
this._stateChangeProcessEnqueue(_ =>
this._changeStateConnectionEnabledEvent(prefs.get("connection.enabled"))
);
@ -502,8 +495,6 @@ var PushService = {
// Used to monitor if the user wishes to disable Push.
prefs.observe("connection.enabled", this);
// Used to load-test the server-side infrastructure for broadcast.
prefs.observe("alwaysConnect", this);
// Prunes expired registrations and notifies dormant service workers.
Services.obs.addObserver(this, "idle-daily");
@ -587,7 +578,6 @@ var PushService = {
}
prefs.ignore("connection.enabled", this);
prefs.ignore("alwaysConnect", this);
Services.obs.removeObserver(this, "network:offline-status-changed");
Services.obs.removeObserver(this, "clear-origin-attributes-data");

View File

@ -425,7 +425,8 @@ var PushServiceHttp2 = {
return serverURI.scheme == "https";
},
connect: function(subscriptions, broadcastListeners) {
async connect(broadcastListeners) {
let subscriptions = await this._mainPushService.getAllUnexpired();
this.startConnections(subscriptions);
},

View File

@ -512,7 +512,7 @@ var PushServiceWebSocket = {
}
},
connect: function(records, broadcastListeners) {
connect: function(broadcastListeners) {
console.debug("connect()", broadcastListeners);
this._broadcastListeners = broadcastListeners;
this._beginWSSetup();

View File

@ -1,73 +0,0 @@
'use strict';
const {PushService, PushServiceWebSocket} = serviceExports;
function run_test() {
setPrefs();
do_get_profile();
run_next_test();
}
add_task(async function test_startup_error() {
let db = PushServiceWebSocket.newPushDB();
registerCleanupFunction(() => {return db.drop().then(_ => db.close());});
PushService.init({
serverURI: 'wss://push.example.org/',
db: makeStub(db, {
getAllExpired(prev) {
return Promise.reject('database corruption on startup');
},
}),
makeWebSocket(uri) {
return new MockWebSocket(uri, {
onHello(request) {
ok(false, 'Unexpected handshake');
},
onRegister(request) {
ok(false, 'Unexpected register request');
},
});
},
});
await rejects(
PushService.register({
scope: `https://example.net/1`,
originAttributes: ChromeUtils.originAttributesToSuffix(
{ appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
}),
/Push service not active/,
'Should not register if startup failed'
);
PushService.uninit();
PushService.init({
serverURI: 'wss://push.example.org/',
db: makeStub(db, {
getAllUnexpired(prev) {
return Promise.reject('database corruption on connect');
},
}),
makeWebSocket(uri) {
return new MockWebSocket(uri, {
onHello(request) {
ok(false, 'Unexpected handshake');
},
onRegister(request) {
ok(false, 'Unexpected register request');
},
});
},
});
await rejects(
PushService.registration({
scope: `https://example.net/1`,
originAttributes: ChromeUtils.originAttributesToSuffix(
{ appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
}),
/Push service not active/,
'Should not return registration if connection failed'
);
});

View File

@ -56,7 +56,6 @@ skip-if = os == "linux" # Bug 1265233
[test_retry_ws.js]
[test_service_parent.js]
[test_service_child.js]
[test_startup_error.js]
#http2 test
[test_resubscribe_4xxCode_http2.js]

View File

@ -5234,8 +5234,6 @@ pref("dom.battery.enabled", true);
// Push
pref("dom.push.alwaysConnect", false);
pref("dom.push.loglevel", "Error");
pref("dom.push.serverURL", "wss://push.services.mozilla.com/");

View File

@ -383,6 +383,13 @@ async function test_push_cleared() {
uaid: userAgentID,
}));
},
onUnregister(request) {
this.serverSendMsg(JSON.stringify({
messageType: "unregister",
status: 200,
channelID: request.channelID,
}));
},
});
},
});